I am trying to calculate one of the intersection points between 2 Area2D. I am following these instructions:
So I have to use the method collide_and_get_contacts
from a Shape2D node.
But right now I only have the 2 Area2D nodes.
I am detecting the intersection on the signal Area2D.entered_area and this signal is only sending me the other Area2D, not the Shape2D.
What is the way of getting the CollisionShape2D from a random Area2D? (It is ok if the Area2D has many CollisionShape2D and I get the first one)
Instead of area_entered
you can use area_shape_entered
. I quote from the documentation:
area_shape_entered ( RID area_rid, Area2D area, int area_shape_index, int local_shape_index )
Emitted when one of another
Area2D
'sShape2D
s enters one of thisArea2D
'sShape2D
s. Requiresmonitoring
to be set totrue
.
area_rid
theRID
of the otherArea2D
'sCollisionObject2D
used by thePhysics2DServer
.
area
the otherArea2D
.
area_shape_index
the index of theShape2D
of the otherArea2D
used by thePhysics2DServer
. Get theCollisionShape2D
node witharea.shape_owner_get_owner(area_shape_index)
.
local_shape_index
the index of theShape2D
of thisArea2D
used by thePhysics2DServer
. Get theCollisionShape2D
node withself.shape_owner_get_owner(local_shape_index)
.