Open rewin123 opened 1 year ago
Hey, I was experiencing a similar issue, having an object that only gains a collider after some amount of time.
If you change the sleeping value of the Sleeping
component (from bevy_rapier
) to false, then it will "wake up".
Example:
fn make_dynamic(
mut commands: Commands,
mut bodies: Query<(Entity, &mut Sleeping), With<WantsToBeDynamic>>,
) {
for (entity, mut sleeping) in &mut bodies {
commands.entity(entity).insert(RigidBody::Dynamic);
sleeping.sleeping = false;
}
}
Or maybe instead of setting sleeping.sleeping
to false, just insert a new Sleeping
component when you insert the RigidBody, although I haven't tried that way.
If you use the debug renderer for Bevy Rapier, see if the colour changes after waking it up, then you at least know Rapier is noticing your change.
If the above doesn't work, then I'm sorry, I don't know how to help you.
I noticed that if I first add a Collider component to an object, and then I add a RigidBody::Dynamic component to the same object in another render frame, then the added Collider is not used when calculating the Rigidbody. (Or created rigidbody is static)