0 votes

Here is the deal:

extends MeshInstance


func _ready():

  var st = SurfaceTool.new()

  st.begin(Mesh.PRIMITIVE_TRIANGLES)

  st.add_normal(Vector3(0, 0, -1))
  st.add_color(Color(1, 0, 0, 1))
  st.add_vertex(Vector3(-1, 0, 0))

  st.add_normal(Vector3(0, 0, -1))
  st.add_color(Color(0, 1, 0, 1))
  st.add_vertex(Vector3(1, 0, 0))

  st.add_normal(Vector3(0, 0, -1))
  st.add_color(Color(0, 0, 1, 1))
  st.add_vertex(Vector3(0, 2, 0))

  st.add_index(0)
  st.add_index(1)
  st.add_index(2)

  var my_mesh = Mesh.new()
  st.commit(my_mesh)

  $Surface_Tool_Triangle.mesh = my_mesh

SurfaceToolTriangle is a child of Spatial, root node

I wanted to create a simple mesh, but instead I got:

  Invalid set index 'mesh' (on base: 'null instance') with value of type 'ArrayMesh'.

~_~

in Engine by (12 points)

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.