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:
extends Node2D
var rigidbody
var geometry
var collider
func _ready():
create_rigidbody()
create_geometry()
create_collider()
func create_rigidbody():
rigidbody = RigidBody2D.new()
rigidbody.set_gravity_scale(3)
rigidbody.set_pos(Vector2(100,0))
add_child(rigidbody)
func create_geometry():
geometry = Polygon2D.new()
var points = Vector2Array()
points.push_back(Vector2(0,0))
points.push_back(Vector2(50,0))
points.push_back(Vector2(0,-50))
geometry.set_polygon(points)
geometry.set_color(Color(0,1,0,1))
rigidbody.add_child(geometry)
func create_collider():
collider = CollisionShape2D.new()
var shape = RectangleShape2D.new()
shape.set_extents(Vector2(35,35))
collider.set_shape(shape)
collider.set_pos(Vector2(25,-25))
rigidbody.add_child(collider)
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:
scene.scn
Thanks in advance.