From the reference:
Check whether a point is inside any shape. The shapes the point is inside of are returned in an array containing dictionaries with the following fields:
shape: Shape index within the object the point is in.
metadata: Metadata of the shape the point is in. This metadata is different
from Object.getmeta(), and is set with Physics2DServer.shapeset_data().
collider_id: Id of the object the point is in.
collider: Object the point is inside of.
rid: RID of the object the point is in.
The return value of intersect_point
is an array containing one dictionary per intersecting collision body.
Each one of those dictionaries has a key named collider
that has the colliding CollisionObject2D
(a Node
) as its value.
If the intersecting shape doesn't belong to a Node
, collider
will be null
(should only happen if you work with Physics2DServer
directly).
If you want an array containing just the nodes, you could use this code:
var return_value = direct_space_state.intersect_point(...)
var colliding_bodies = []
for dictionary in return_value:
if typeof(dictionary.collider) == TYPE_OBJECT:
colliding_bodies.push_back( dictionary.collider )