bevyengine / bevyengine/bevy

Bevy TimeUpdateStrategy cannot move time backwards

Open
#11,859 0 comments 2 reactions 0 assignees View on GitHub
A-Time C-Feature X-Needs-SME
Dominant language
Rust
Stars
48.2k
Forks
4.8k
Avg merge
3d 22h
Merged PRs (30d)
161

Description

## What problem does this solve or what need does it fill?

Currently it is possible to use [ManualInstant](https://docs.rs/bevy/latest/bevy/time/enum.TimeUpdateStrategy.html#variant.ManualInstant) to set the `Time` to a specific `Instant`.

This can be used to e.g. track which frame you are simulating and step single frames while choosing how much time elapses in-between frames.

However, setting an earlier `Instant` results in no delta (and no change in elapsed) since the [Bevy time implementation](https://github.com/bevyengine/bevy/blob/main/crates/bevy_time/src/real.rs#L93) does subtraction on `Instant`s which saturates to a zero duration if a larger instant is subtracted from a lesser instant.

This prevents uses cases like

- Simulation frame stepping backwards
- Creating a "scrubber" like in video editing software which is able to move backwards

## What solution would you like?

Make setting earlier instants in `ManualInstant` affect the elapsed time.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.