Does Area2D.get_overlapping_bodies() only check KinematicBody2Ds?

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

I’m calling the following inside of my Player script, to try and detect nearby objects that can be interacted with:

var candidates = $Area2D.get_overlapping_bodies()

The documentation says that this “Returns a list of intersecting PhysicsBody2Ds”, but the result Array only ever contains KinematicBody2D objects. I was hoping that it would return a list of both KinematicBody2D and StaticBody2D objects, but this doesn’t seem to work.

Is this expected behavior? Is there some way to configure the Area2D or StaticBody2D objects to make this work?

I’ve uploaded a simple example project here.

Have you checked the collision layers? Becaus i just tried and it correctly detects both kinematic and static bodies on my machine.

p7f | 2020-09-07 18:29

Thanks for testing this. I really should have tried making a minimal project before I asked a question here.

You’re right that it detects kinematic and static bodies by default, but it’s nothing to do with the collision layers. It seems like if the Area2D is not set to “Monitorable”, then it cannot detect overlapping StaticBody2Ds!

Pennycook | 2020-09-07 21:52