dimforge / bevy_rapier

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

Despawning MultiBodyJoint handling entities panic #196

Closed LIMachi closed 3 months ago

LIMachi commented 2 years ago

Bevy 0.7, Bevy_Rapier 0.14.1

fn clear_mbjoints(mut commands: Commands, joints: Query<Entity, With<RapierMultibodyJointHandle>>) { for e in joints.iter() { commands.entity(e).despawn(); } }

the above code when used as a system, in a scene with entities that were spawned with a MultibodyJoint component, will result in a panic: thread 'main' panicked at 'called 'Option::unwrap()' on a 'None' value', C:\Users\hugom\.cargo\registry\src\github.com-1ecc6299db9ec823\rapier3d-0.13.0\src\dynamics\joint\multibody_joint\multibody_joint_set.rs:173:74

alexichepura commented 1 year ago

same on bevy_rapier3d 0.18.0 thread 'main' panicked at 'calledOption::unwrap()on aNonevalue', /Users/alexi/.cargo/registry/src/github.com-1ecc6299db9ec823/rapier3d-0.16.0/src/dynamics/joint/multibody_joint/multibody_joint_set.rs:173:29

I couldn't workaround this for a car here https://github.com/alexichepura/bevy-rapier-car-sim Multibody works way cooler for multiple cars, but despawn panics. Workaround is use of impulsejoints with more iterations.

alexichepura commented 1 year ago

can be related to https://github.com/dimforge/rapier/issues/382

Vrixyz commented 3 months ago

more recent duplicate https://github.com/dimforge/rapier/issues/382, gotta choose one to keep, closing this one 😅