0 votes

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 :

https://prnt.sc/1ur3mmm

Code of the area :

https://prnt.sc/1ur3ql0

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

Godot version 3.3.3 stable
in Engine by (82 points)

1 Answer

+1 vote
Best answer

Propably timing is wrong. You only call getoverlappingbodies 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 ? ;)

by (2,432 points)
selected by

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 !

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.