Create Trimesh Static Body, manually

Godot Version

4.2

Question

Hi There, is it normal that I can create a static body using this option in the editor, but I can’t create the same in the tree manually?, I mean, in the tree I have this:

MeshInstace3D (a plane)
-StaticBody3D
–CollisionShape3D (convave)

which is the same tree than Trimesh Static Body creates.
Doing manually does not detects collisions.

Any idea about the difference between them?

Thanks in advance

I think, take with salt, that the collision shape is not a mesh. The editor converts your mesh into a shape and that’s why it works.

There is a scriptable way to do this. Have a look at the docs.

Hi,

for my understanding, that means that when we create a static mesh from the editor , the program does something internally that we can’t do by simply adding the same nodes in the tree manually, but we can replicate the same via script is that correct?

Sorry, but this is quite confusing to me, if in my tree instead concave in the CollisionShape3D, I use a boxshape3D, collision is detected… I don’t understand why concave only works from the editor not in my tree.

The method called by Create Trimesh Collision Shape is Mesh.create_trimesh_shape(). This method takes a while to run on complex meshes, so make sure to cache its return value whenever possible or save it to a .res file.

1 Like

Another trick is to tag meshes in something like Blender with the “-col” in the name. Godot, when importing, then makes collision meshes from those.

See: Importing 3D scenes — Godot Engine (4.1) documentation in English