Is there are way to specify a BoxShape3D as the collision object for a mesh, and have it set automatically to fit the mesh like a bounding box? I can manually pull the bounds around in the editor, but I’d rather it was lined up perfectly and quickly.
@mrcdk that works the aabb uses a start position while the boxshape uses the center of the node, but with a small calculation it works fine. Here is a function that does it for static bodies.
## creates a minimal static BoxShape3D collision shape around the given mesh
## and attaches it to the given Node3D.
static func add_box_collider( node:Node3D, mesh:Mesh )->void:
var coll_obj:CollisionObject3D = StaticBody3D.new()
var coll_shape = CollisionShape3D.new()
var box = BoxShape3D.new()
var aabb:AABB = mesh.get_aabb()
var center:Vector3 = aabb.position + aabb.size/2
coll_obj.position = center
box.size = aabb.size
coll_shape.shape = box
coll_obj.add_child( coll_shape )
node.add_child( coll_obj )