Hubs-Foundation / hubs

Duck-themed multi-user virtual spaces in WebVR. Built with A-Frame.
https://hubsfoundation.org
Mozilla Public License 2.0
2.13k stars 1.42k forks source link

BG - Deleting an entity that should trigger an `On Collision Exit` event causes crash #6441

Open j-conrad opened 8 months ago

j-conrad commented 8 months ago

Description I have an empty with a Rigidbody/Shape component on it. There is a behavior graph that looks for On Collision Enter & On Collision Exit events. If I put a spawned media object into the empty but then delete it, I get the following crashes/errors, although not always and not always the same one:

index.mjs:925 Uncaught Error: bitECS - entity does not exist in the world.

physics-system.js:333 Uncaught TypeError: Cannot read properties of undefined (reading 'collisions')

NOTE: This only occurs as a result of the behavior graph setup. If no On Collision Exit event is there, no errors occur.

To Reproduce Steps to reproduce the behavior:

  1. Open the attached .blend file
  2. Note the graph on the Empty object with the Rigidbody/Shape components
  3. Run in Hubs
  4. Spawn in 2d or 3d media and drop it inside the object (atop the hexagon).
  5. Hold spacebar and delete the object
  6. Crash (if not, try again)

Expected behavior The entity should be removed and should also trigger any On Collision Exit events. This is integral for things like keeping count of items in a trigger.

Hardware

ColliderDeletion_bug.zip