0 votes

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.

in Engine by (27 points)
edited by

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

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!

I filed this as a bug (at https://github.com/godotengine/godot/issues/41864) and it was confirmed (as a duplicate of https://github.com/godotengine/godot/issues/17238).

Please log in or register to answer this question.

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.