Hello, i'm trying to create a MeshInstance with a collision box, all by script.
The mesh is created, but i see the collision box falling (the MeshInstance does not move at all, it's sticked at the creation coordinates)
It seems physics is applied to the collision box, but i don't want this. Is there something to desactivate ?
Thank you for your help.
var cube_mesh = CubeMesh.new()
var rigid = RigidBody.new() # using StaticBody instead !
var coll = CollisionShape.new()
var shape = BoxShape.new()
coll.shape = shape # shape added to the collision shape.
shape.extents = Vector3(2, 2, 2) # grow it (should be visible)
var m = MeshInstance.new()
m.set_mesh(cube_mesh) # add predefined geometry to instance
m.global_transform.origin = Vector3(4, 4, 0)
rigid.add_child(coll,true) # add collision shape to rigid body
m.add_child(rigid,true) # add rigid body (coll.shape) to instance
m.add_child(coll,true) # add instance to scene
add_child(m,true)
Ok i've found it meanwhile: using static body instead of rigid body.
I leave the question here, may be it will be useful for someone else.