dimforge / bevy_rapier

Official Rapier plugin for the Bevy game engine.
https://rapier.rs
Apache License 2.0
1.22k stars 259 forks source link

Despawning rigidbody panics #111

Closed Alainx277 closed 2 years ago

Alainx277 commented 2 years ago

Despawning an entity with a rigidbody causes the following panic: thread 'main' panicked at 'Attempting to create an EntityCommands for entity 570v0, which doesn't exist.', C:\Users\USER\.cargo\registry\src\github.com-1ecc6299db9ec823\bevy_rapier3d-0.12.0\src\physics\resources.rs:240:26

I think the easiest fix would be to check if the entity still exists, and only remove the components if that is the case.

tylerkayser commented 2 years ago

I ran into this as well. It only seemed to happen when I was despawning an entity with both collider and rigid body components.

Alainx277 commented 2 years ago

I ran into this as well. It only seemed to happen when I was despawning an entity with both collider and rigid body components.

My entities also have both.

sebcrozet commented 2 years ago

I wasn’t able to reproduce the bug based on our despawn examples, but I think that @Alainx277’s suggestion to check if the entity exists is the right solution. Could you please test the despawn-fix branch to see if it works for you?

lain-dono commented 2 years ago

@sebcrozet same error. You patch works.

Alainx277 commented 2 years ago

Yes, fixes the panic for me.

ndarilek commented 2 years ago

Already reported in on Discord, but this fixes it for me as well. Thanks!

sebcrozet commented 2 years ago

Thank you all for checking!