![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | epord |
![]() |
Old Version | Published before Godot 3 was released. |
Hi, I want to get a list of bodies inside an Area2D (or any other node, but I thought an Area2D was the correct one). I was trying to use get_overlapping_bodies() but I get 0 elements every time. I don’t know if this function does something else or maybe I am using it wrong. Or maybe there is another way to do it.
Are you trying to detect PhysicBody2D overlaps just after adding the Area2D to the tree or the area was already there?
eons | 2016-12-25 16:35
I have my character and I want to get all bodies near him. I have an Area2D following him and when I press a key I want to get all bodies in that area.
epord | 2016-12-25 18:13
Then, get_overlapping_bodies
should work…
Can you specify your collision layers, masks, of the area and bodies, also the structure in the scene (of the area and the undetected bodies)?
And show the portion of code that is not working.
eons | 2016-12-25 19:06
I found the issue. Apparently a have to use a CollisionShape2D with the Area2D. Now it’s working fine, thanks!
epord | 2016-12-26 12:57