-
-
Notifications
You must be signed in to change notification settings - Fork 4k
Description
Bevy version
0.14
What you did
It could be I don't understand the intent behind Time<Virtual>
. I thought it was meant as a gameplay clock separate from the wall clock in Time<Real>
.
There is a footgun for games that want to use Time<Virtual>
but which do not use a fixed update. If you pause Time<Virtual>
then the FixedUpdate
schedule does not run. If the FixedUpdate
schedule does not run, events do not get updated.
This is because the TimePlugin
, by default, sets the event updates to happen on the next FixedUpdate
.
If you use events for UI, for example, and pause your game by pausing Time<Virtual>
those events will start to accumulate until read or the game is unpaused. This is unexpected.
A game that doesn't want to use the FixedUpdate
, but still wants to use Time<Virtual>
for gametime and pausing must do this:
let mut event_registry = app
.world_mut()
.resource_mut::<bevy::ecs::event::EventRegistry>();
event_registry.should_update = ShouldUpdateEvents::Always;
What to do?
Maybe TimePlugin
should have configuration to select the event update strategy. However, I think that FixedUpdate
games that pause the clock will be surprised by events accumulating? Or maybe Time<Virtual>
is not intended to be used as a gameplay clock, just as pacing for FixedUpdate
?