Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Daniel Mircea | |
Old Version | Published before Godot 3 was released. |
I have two area2d objects. I’m interested in determining where they collide.
area_enter_shape
doesn’t appear to return any collider objects.
Is there a way of retrieving this value without using ray intersect?
You’ll have to define the problem a bit more than that. Areas don’t collide, they’re allowed to overlap, so they can report what enters them. However, when shapes overlap, you’re going to have more than one point of intersection.
avencherus | 2017-02-26 22:16
The phrasing is unfortunate, but the question is valid still. Just as intersect_shape
returns collision data, one would assume that internally area_enter
and area_enter_shape
use this data as well.
Daniel Mircea | 2017-02-26 22:40
Which intersect_shape
-function are you referring to? There isn’t one in GDscript.
Warlaan | 2017-02-27 09:31
Zylann | 2017-02-27 13:38
intersect_shape
returns the shapes overlapping.
Area nodes have the get_overlapping_areas
and get_overlapping_bodies
that work just like intersect_shape
.
Is that what you are looking for?
eons | 2017-02-27 14:29
You’re right, intersect_shape isn’t good either. The provided collider object in the Dictionary response is actually the other area. Get get_overlapping_bodies
returns PhysicsBody2D objects, which I have none of …
After doing some research on polygon intersection I came to the conclusion that these methods don’t provide intersection points, also evidenced here http://docs.godotengine.org/en/stable/tutorials/vector_math.html#some-examples-of-planes
Daniel Mircea | 2017-02-27 18:23
Maybe this Shape2D method Shape2D — Godot Engine (latest) documentation in English
With that, you need to test shape against shape with the transforms of the nodes, but may be better to do it only after a positive overlap.
eons | 2017-02-27 20:02
eons, thank you so much! That worked great.
Daniel Mircea | 2017-02-27 22:01