I'm trying to create a dynamic (that is, through a gdscript) rigidbody, including sprite and collider. The Rigidbody and the geometry works fine, but I have trouble with the collider.
I have set up a 2d scene like this:
Blue rectangle is a static body, the red box is a normal rigidbody.
I then attach a gdscript to the root node. The script creates a rigidbody, then add it as a child of the scene node. Then it creates a polygon (green triangle), and add it as a child of the rigidbody. Finally it creates a box-shaped-collider, and also makes it a child of the rigidbody.
The code is here:
rigidbody = RigidBody2D.new()
geometry = Polygon2D.new()
var points = Vector2Array()
collider = CollisionShape2D.new()
var shape = RectangleShape2D.new()
When run (with debug->show colliders turned on), the game shows:
(I made the colliders a bit larger than the geometry, so they are easier to identify)
I can see my code has generated everything as I wanted, and that the rigidbody fall with the triangle and the box-collider.
However, the collider doen't react when hitting the blue static body - it just passes through.
I can't figure out why. Is there a setting or something on the collider I need to check for this to work?
Any help is greatly appreciated.
The scene i made is here:
Thanks in advance.