Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | avencherus | |
Old Version | Published before Godot 3 was released. |
In my scene I’m trying to dynamically add a rigid body with a collision capsule to a spatial scene. I have a static body collision plane below, so it works normally if I add the nodes in the scene tree through the editor, but not with code.
My coded rigid body shows having a collision capsule, but falls right through the plane. I hope that I’m overlooking something.
The code I have looks like this:
var rb = RigidBody.new()
rb.translate(Vector3(0,10,0))
rb.set_mode(2)
var cs = CollisionShape.new()
cs.set_shape(CapsuleShape.new())
rb.add_child(TestCube.new())
rb.add_child(cs)
add_child(rb)
You should write set_mode(RigidBody.MODE_CHARACTER)
instead of set_mode(2)
, it’s easier to understand and maintain
Zylann | 2016-10-08 21:59
Neat, thanks. I see so you can use them like statics. I was wondering if there was a way to reach those constants from outside.
avencherus | 2016-10-09 06:40