You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I followed the custom setup example, but I used FixedUpdate instead of PostUpdate.
I noticed that, sometimes, the bodies/colliders of despawned entities would remain active in the world, when they should have been removed.
After looking into the plugin's setup code, I found
// These *must* be in the main schedule currently so that they do not miss events.// See test `test_sync_removal` for an example of this.ifself.schedule != PostUpdate.intern(){
app.add_systems(PostUpdate,(systems::sync_removals,).before(TransformSystem::TransformPropagate),);}
So, despite using with_default_system_setup(false), self.schedule is still PostUpdate, which means this will not be called and sync_removals will not be placed in the correct schedule. In the example I mentioned, the custom schedule used is PostUpdate, so this issue does not happen.
To fix this, I used with_default_system_setup(false).in_schedule(FixedUpdate), but this feels like a hack since I will still have to register the systems again later.
My use case was I wanted to be able to pause the simulation, so I needed to add the systems and only make them run if the game is in a certain state:
.configure_sets(FixedUpdate,(PhysicsSet::SyncBackend,PhysicsSet::StepSimulation,PhysicsSet::Writeback,).chain().before(TransformSystem::TransformPropagate),).add_systems(FixedUpdate,(RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::SyncBackend).in_set(PhysicsSet::SyncBackend),RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::StepSimulation).in_set(PhysicsSet::StepSimulation),RapierPhysicsPlugin::<NoUserData>::get_systems(PhysicsSet::Writeback).in_set(PhysicsSet::Writeback),).run_if(in_state(GameState::Running))// only run if game is running)
The text was updated successfully, but these errors were encountered:
IVSOP
changed the title
Despawn events missed when using FixedTimestep
Despawn events missed when using FixedUpdate
Feb 14, 2025
I followed the custom setup example, but I used
FixedUpdate
instead ofPostUpdate
.I noticed that, sometimes, the bodies/colliders of despawned entities would remain active in the world, when they should have been removed.
After looking into the plugin's setup code, I found
So, despite using
with_default_system_setup(false)
,self.schedule
is stillPostUpdate
, which means this will not be called andsync_removals
will not be placed in the correct schedule. In the example I mentioned, the custom schedule used isPostUpdate
, so this issue does not happen.To fix this, I used
with_default_system_setup(false).in_schedule(FixedUpdate)
, but this feels like a hack since I will still have to register the systems again later.My use case was I wanted to be able to pause the simulation, so I needed to add the systems and only make them run if the game is in a certain state:
The text was updated successfully, but these errors were encountered: