Godot: Area2D get_overlapping_bodies only detects StaticBody2D if area is Monitorable

Created on 8 Sep 2020  路  7Comments  路  Source: godotengine/godot

Godot version:
3.2.1-stable_x11.64

OS/device including version:
Ubuntu 18.04

Issue description:
I'm using get_overlapping_bodies() to detect all PhysicsBody2D objects that are overlapping an Area2D. I disabled the Monitorable property of the Area2D because I don't need other areas to be aware of it. Unexpectedly, this causes get_overlapping_bodies() to ignore StaticBody2D objects.

I couldn't see anything in the documentation to suggest that the function and property are related. The documentation for get_overlapping_bodies() says that it "Returns a list of intersecting PhysicsBody2Ds", and the documentation for Monitorable only says "If true, other monitoring areas can detect this area."

This may be related to https://github.com/godotengine/godot/issues/41621, but the StaticBody2D in my example is not moving.

Steps to reproduce:

  1. Play Test.tscn in the attached minimal reproduction project.
  2. Each time space is pressed, the output shows both a KinematicBody2D and a StaticBody2D:
    [[KinematicBody2D:1174], [StaticBody2D:1176]]
  3. Turn off the Monitorable property of the Area2D
  4. Repeat 1. and 2.; the output shows only a KinematicBody2D:
    [[KinematicBody2D:1174]]

Minimal reproduction project:
Area2DBodies.zip

archived bug confirmed physics

Most helpful comment

The RigidBody2D not being detected when the monitorable property is changed is fixed with #41698.

All 7 comments

I tested it with RigidBody2d, doesn't work as well. So far, RigidBody2d and StaticBody2d aren't getting detected.

This is definitely a bug, and it happens in 3D Godot physics too.

The RigidBody2D is weirder. It's detected when the scene is loaded, but it stops being detected if the Area2D's monitorable property is changed. In 3D Godot physics RigidBody is always detected.

The RigidBody2D not being detected when the monitorable property is changed is fixed with #41698.

The RigidBody2D not being detected when the monitorable property is changed is fixed with #41698.

So, I think the bug now only revolves around StaticBody2D not being detected.

@madmiraal Does this #41698 also fixes the issue of StaticBody2d not being detected? If not, I'd like to fix this, and could you point to the direction from where I can get started?

Closing as it's a duplicate of #17238.

@theoway #41698 does not fix this issue. It's a difficult one to solve, so probably not the best one to get started with.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

bojidar-bg picture bojidar-bg  路  3Comments

rgrams picture rgrams  路  3Comments

SleepProgger picture SleepProgger  路  3Comments

testman42 picture testman42  路  3Comments

blurymind picture blurymind  路  3Comments