var shape = RectangleShape2D.new()
get_node("StaticBody2D").add_shape(shape)
shape.set_extents(Vector2(70,70))
If i’m not wrong, that is no exactly the same, as you already has a StaticBody2D node and you are just adding a shape. I want to create a collision shape directly from Area2D node, and not from a CollisionShape2D node.
al.glez | 2016-03-05 16:35
When you say:
I want to create a collision shape directly from Area2D node
you meant that your script is attached to a Area2D node?
If your script is attached to an Area2D node, then you can try something like this:
var shape = RectangleShape2D.new()
shape.set_extents(Vector2(70,70))
var collision = CollisionShape2D.new()
collision.set_shape(shape)
add_child(collision)
Hi Sorry, but I didn’t have time to answer before. I tested today that solution and is working, but I’m not sure why only within _process(), I will test further anyway.