0 votes

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


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.

Godot version 3.3.2
in Engine by (12 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 Frequently asked questions and 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 [email protected] with your username.