Godot: Area2D doesn't detect static bodies if "Monitorable" is disabled

Created on 4 Mar 2018  路  20Comments  路  Source: godotengine/godot

Godot version:
184b2fe

Issue description:
This could also affect the 3D version of it, but I just tested in 2D.

If an Area2D's Monitorable property is disabled, it will fail to detect static bodies.

bug discussion documentation physics

Most helpful comment

https://github.com/godotengine/godot/issues/17238#issuecomment-370192809
@Ranoller

http://docs.godotengine.org/en/3.0/tutorials/physics/physics_introduction.html

Static body and area should not report contact

Then how would you detect StaticBody2Ds ?

All 20 comments

@Ranoller Well, then the bug is that is detecting static bodies when Monitorable is enabled then?

If you trust documentation... Yes

Monitorable seems wonky in other cases too: https://github.com/godotengine/godot/issues/17330

Please do not fix this "bug" !!!

So, story is: I was migrating my (very large) project from 2.x to 3.x, it was hard, OK, and now I think everything is fine, except that I used a RigidBody2D as a "collider detector" and it shouldn't physically collide with other objects (rigid & statics), so it had "trigger" enabled. I had this problem when migrated because in 3.0 there isn't a "trigger" boolean in CollisionShape2D's. Area2D wouldn't do the job because Area2D can't detect static bodies (I had thought so until now), unless Monitorable is enabled.

tldr: I was looking how to detect static bodies with a non-physical colliders and ENABLING MONITORABLE in Area2D is the only way.

It shouldn't even be called a bug since area2D isn't monitorable anyway(except by others Area2D, I know, but it can be handled with collision_mask bits).
So, if Area2D isn't supposed to be detecting static bodies in any way, please let this "bug" continue

like, I found a solution to my problem in a "bug" topic ... cool thanks btw

Why is this and the referenced issue #20364 closed? Is it intended that area2D shouldn't detect static bodies and tilemaps?
I just encountered this issue in Godot 3.1.1 and its bugging me because I don't understand why it behaves like this. Performance also drops by over 50% if I enable monitorable.

Edit: Sorry @YeldhamDev ! Not so experienced with github..
But it also applies for tilemap, not only staticbody2D

@fossegutten This issue is currently open, the other one was closed for being a duplicate of this one.

So.... what is the best way of detecting static bodies?
Like, let say I want a character to jump BEFORE running off a ledged, then I want some kind of detector running in front of them that says when there isn't any ground. I don't want the detector to have any physics in it (hence shouldn't be a body), I want it to only be a zone of detection.

This seems like something that "area2d" should do, or at least, have the ability to do.
If not, then, what type of object should have that behavior.

I'm all for fixing some other thing that is a bug, but ... if you do I'm not sure how to implement the thing I'm imagining.

https://github.com/godotengine/godot/issues/17238#issuecomment-370192809
@Ranoller

http://docs.godotengine.org/en/3.0/tutorials/physics/physics_introduction.html

Static body and area should not report contact

Then how would you detect StaticBody2Ds ?

What's the status on this issue? I'm still experiencing it in 3.2.2 stable.

Experiencing this in 3.2.3 stable.
It's confusing enough that it took me quite a while to understand what was going on in my project.
In my case I was trying to detect tiles from a TileMap.

http://docs.godotengine.org/en/3.0/tutorials/physics/physics_introduction.html

Static body and area should not report contact

In my case I was trying to detect tiles from a TileMap.
The documentation for Area2D says:

body_entered(body: Node)
_Emitted when a physics body enters.
The body argument can either be a PhysicsBody2D or a TileMap instance (while TileMaps are not physics body themselves, they register their tiles with collision shapes as a virtual physics body)._

But it doesn't work unless you switch "monitorable" on, on the detector, which makes no sense.

The problem is with the way the physics engine is designed. To make things efficient, StaticBodies are not checked if they're colliding with anything, because they don't move. Instead it relies on the other CollisionObjects moving and detecting collisions with it. Similarly, to make things efficient, Areas that are not monitorable are not checked if they're colliding with anything. The problem arises when moving Areas that are not monitorable collide with StaticBodies. Neither is checking for collisions, so nothing is detected.

@madadam So it's a quirk, rather than a bug? If so, it should be documented.

No, it's definitely a bug. It's just not an easy one to fix, because of the way the physics engine was designed.

@madadam So it's a quirk, rather than a bug? If so, it should be documented.

It is a bug, please see https://github.com/godotengine/godot/issues/17238#issuecomment-703217265

The problem arises when moving Areas that are not monitoring collide with StaticBodies. Neither is checking for collisions, so nothing is detected.

No. The problem arises even when Areas that are monitoring collide with StaticBodies, or at least with tiles, in my case. Nothing is detected until your Areas have monitorable _On_, which doesn't make sense, and that's the bug, for what I'm able to understand.

In other words, to solve the bug, either:

  • nothing should be detected also when Area has monitorable On, but in this case you couldn't detect tiles, so something would have to be done for making tiles detectable by Areas

OR

  • An Area should always detect StaticBodies if the Area has the monitoring parameter On (not the monitorable parameter).

@char0xff Thanks. I've corrected the typo.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

testman42 picture testman42  路  3Comments

bojidar-bg picture bojidar-bg  路  3Comments

blurymind picture blurymind  路  3Comments

ducdetronquito picture ducdetronquito  路  3Comments

EdwardAngeles picture EdwardAngeles  路  3Comments