Skip to content

Setting the timer duration to zero panicks #8463

Closed
@MWFIAE

Description

Bevy version

bevy 0.10.1

What you did

I set a repeating timers duration to 0. I did so accidentally using the egui_inspector, but is also reproducible if setting it via code.

What went wrong

Bevy panicked, because it can't divide by 0.

thread 'Compute Task Pool (3)' panicked at 'attempt to divide by zero', C:<redacted>.cargo\registry\src\index.crates.io-6f17d22bba15001f\bevy_time-0.10.1\src\timer.rs:228:21

Caused by this line of code:

                self.times_finished_this_tick =
                    (self.elapsed().as_nanos() / self.duration().as_nanos()) as u32;```

## Additional information

While in my case it happened for a repeating timer, similar panics can and will happen if for example the percent function of the timer is used, while the duration is set to 0.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-TimeInvolves time keeping and reportingC-BugAn unexpected or incorrect behaviorD-TrivialNice and easy! A great choice to get started with Bevy

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions