Skip to content

Pausing the virtual clock stops event updates. #14152

@brandon-reinhart

Description

@brandon-reinhart

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-ECSEntities, components, systems, and eventsA-TimeInvolves time keeping and reportingC-BugAn unexpected or incorrect behaviorD-ModestA "normal" level of difficulty; suitable for simple features or challenging fixesS-Ready-For-ImplementationThis issue is ready for an implementation PR. Go for it!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions