I think the subject line is basically the question, but I'll try to elaborate.
For checking object collisions (like players touching enemies, for example) I've been using the body_entered()
and body_exited()
signals. This works great in general but causes a problem for stationary objects (like spikes, for example) because the player can just stand still and avoid any further damage.
This is of course because the signal functions only get called when the player enters the specified Area2D
, and don't get called again unless the player leaves and re-enters. I'm hoping there's something that can still use the same general logic of body_entered(body)
but rather than checking for the entering body, I can verify whether the body
is currently overlapping with the Area2D
so that it would get called without having to exit/re-enter.
Is there such a thing? I feel like I've missed an obvious solution here.
EDIT: I was looking for get_overlapping_bodies()
. There's an example in a reply below.