appsinacup / godot-rapier-physics

Godot Rapier Physics – A 2D and 3D drop-in replacement for the Godot engine that adds stability and fluids.
https://godot.rapier.rs
MIT License
314 stars 16 forks source link

Area2D child of CharacterBody2D parent constantly throws 'on_body_enter: Body is already being monitored' error on movement #169

Closed PleaseJustWork777 closed 1 month ago

PleaseJustWork777 commented 1 month ago

Describe the bug

Moving a CharacterBody2D with child Area2D using move_and_collide() constantly throws the following error from rapier:

E 0:00:00:0664 godot_rapier::bodies::rapier_area::RapierArea::on_body_enter: Body is already being monitored <C++ Source> src\bodies\rapier_area.rs:199 @ godot_rapier::bodies::rapier_area::RapierArea::on_body_enter()

To Reproduce

Steps to reproduce the behavior:

  1. Create CharacterBody2D and add CollisionPolygon2D child
  2. Create Area2D as child of CharacterBody2d and add identical CollisionPolygon2D child
  3. Move CharacterBody2D using move_and_collide()
  4. Set Rapier2D as 2D Physics engine in project settings
  5. Run project

Expected behavior

Error about Body already being monitored not constantly thrown

Environment:

*rapier error repro.zip

Please attach a zip with project where issue occurs.

  1. I had to delete the godot-rapier2d from addons to make the zip small enough to upload
PleaseJustWork777 commented 1 month ago

I get the same issue with the Cross Platform Determinism build too.

Grateful for any assistance

Ughuuu commented 1 month ago

Will check and let you know. Thanks for reporting it.

Ughuuu commented 1 month ago

Investigated and interestingly enough what happens is it's possible aparently for an object to both enter and exit and event same time and both exit and enter an event same time. In this case they should probably cancel out.

Ughuuu commented 1 month ago

Indeed, canceling the event in this case fixes it! Will put a PR.