I'd like to use a mesh I generated in Blender (using the convex hull node) as the collision mesh for a vehicle. I've imported the mesh as an OBJ, but I can't find a way to use it as a collision mesh. I've tried the "Mesh" button above the viewport, but every option either loses a great deal of accuracy or it assumes it's a concave shape and won't allow it for dynamic objects.

In short, is it possible to use a convex shape generated outside of Godot as a collision shape without using "collision sibling" options?

Edit: I ended up using the decimate modifier on the convex hull shape in Blender, then attempted to use the "Create Single Convex Collision Sibling", and this time it did manage to replicate the shape I imported. I'm not sure what determines when Godot will estimate the shape. So this is solved, but I'd still be interested in knowing if there is a more appropriate way to apply purpose-made collision meshes aside from letting Godot generate them.

  • xyz replied to this.

    OffLuffy You can use ConcavePolygonShape3D as a shape in CollisionShape3D. You can then copy mesh faces from any mesh resource to the shape. I'm not aware of a way to do this via gui. It's one line of script code though:

    collision_shape.shape.set_faces(mesh.get_faces())

      xyz Thanks for the input. In retrospect, I should have mentioned I'm using Godot 4.1.1

      I don't see a set_faces function in Shape3D, although that could have been removed in this version. I could also be wrong about this, but I think I need to use ConvexPolygonShape3D as concave shapes are typically only supported on colliders for static objects (mine needs to move). I'd suspect the same method would work regardless if it weren't for the missing function.

      • xyz replied to this.

        OffLuffy set_faces() is method in ConcavePolygonShape3D. Shape3D is its base class. You asked about arbitrary meshes which are concave in general. You can let godot decompose concave meshes into multiple ConvexPolygonShape3D shapes via "Create Multiple Convex Collision Siblings", similarly to what you already did with a single convex mesh.

          xyz Ah, I see the function now. The code collsion_shape.shape was returning a Shape3D, so got a little thrown off.

          I suppose Godot can't assume an arbitrary mesh is convex, but I was hoping for a way to tell it this specific mesh was already convex and simply apply it as a convex collider shape. Might be able to simply copy the mesh's vertices as points into a ConvexPolygonShape3D.