appsinacup / godot-rapier-physics

Godot Rapier Physics – 2D and 3D physics engine for the Godot game engine. with better stability, performance, liquids, determinism, state serialization and no ghost collisions.
https://godot.rapier.rs
MIT License
428 stars 22 forks source link

Removing collision does not update Area2D #290

Closed Changryy closed 2 weeks ago

Changryy commented 1 month ago

Describe the bug

If you remove a collision shape that is a child of an Area2D while that collision shape is overlapping with other bodies, the Area2D will keep reporting that those bodies are inside it.

To Reproduce

Steps to reproduce the behavior:

  1. Add an Area2D with a collision shape or polygon
  2. Add any type of body and make sure it overlaps with the area
  3. During runtime remove the collision shape of the Area2D. This can be done by either area.remove_child(collider), collider.queue_free() or collider.disabled = true
  4. Area is still overlapping with the body despite having no collision shape

Expected behavior

When a CollisionShape2D or CollisionPolygon2D is disabled or removed from an Area2D the bodies that were inside that collision shape should no longer be in the array returned by get_overlapping_bodies(). For each body that was previously inside said collision shape the area should emit the body_exited signal. This of course does not apply if the area is still overlapping with those bodies through a different collision shape.

Environment:

Example project(zip) AreaBug.zip

Ughuuu commented 2 weeks ago

The event is called on rapier side, but it looks like im not updating state correctly in the wrapper.