0 votes

The game instantiates this object every frame, this object creates two triangles using surfaceTool. The mesh itself is being created and I can see it runtime, but when i create the collision shape from the mesh it returns null.
Don't focus on vertices, I'm sure they are ok, the problem is that it doesn't create a collision shape from the mesh.

func _ready():

surfTool.begin(Mesh.PRIMITIVE_TRIANGLES)
surfTool.add_vertex(oP1)
surfTool.add_vertex(oP2)
surfTool.add_vertex(nP1)
surfTool.add_vertex(nP2)

surfTool.index()

surfTool.add_index(1)
surfTool.add_index(2)
surfTool.add_index(3)

mesh = surfTool.commit()
get_parent().get_node("CollisionShape").shape = mesh.create_trimesh_shape()

If I create the shape using createconvexshape(), a shape is created and it works, but I guess that this way is slower.

Godot version 3.4 stable
in Engine by (18 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.