|Topic was automatically imported from the old Question2Answer platform.
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
I filed this as a bug (at Area2D get_overlapping_bodies only detects StaticBody2D if area is Monitorable · Issue #41864 · godotengine/godot · GitHub) and it was confirmed (as a duplicate of Area/Area2D doesn't detect static bodies if "Monitorable" is disabled (3D issue only when using GodotPhysics) · Issue #17238 · godotengine/godot · GitHub).
Pennycook | 2020-10-02 02:38