get_overlapping_bodies() in Area2D doesn't detect anything, why ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Rensae

Hi, I’m using the said function to detect if a body is inside the area when it’s spawned (for an AOE skill), but it returns an empty array

Collision layers and collision masks are set, so I don’t understand why it isn’t working at all

Code used for spawning the area :

Code of the area :

I did use the Debug : Visible collision layer to see if the radius was too small (and tried to change it to 9999 too) but it still doesn’t detect any bodies, even the body of the one summoning it if I put it on the same collision layer.

I also used it to make an arrow that follows the closest body in range, using the same function, and it works totally fine. I don’t see the issue and that’s bugging me.

Thanks in advance for every answer

:bust_in_silhouette: Reply From: Inces

Propably timing is wrong. You only call get_overlapping_bodies once, at the moment of explosion. I guess at this frame collision shape is not done yet. Try to debug it by calling overlapping bodies after yield. If it works, than You will have to yield few frames or call deferred to fix the problem.

I hope You are detecting bodies, not areas ? :wink:

Omg thank you so muuuuch ! I did a yield and created a timer of 0.5 secondes, and now the bodies are detected ! I do have a little frame stuttering on the spawn though, I might need to look into that.

And yes, I was looking for Kinematic bodies !

Rensae | 2021-10-04 15:52