#Should I use time.delta_seconds() or FixedUpdate

3 messages · Page 1 of 1 (latest)

golden citrus
#

Hello, I'm pretty new to Bevy and game dev in general, so I'm just learning the basics.

While doing this, I came upon the FixedUpdate schedule which allow to run at a fixed rate and the Res<Time> that allow me to update my physics depending on the time elapsed.
So my question is, which one do you use for physics update ? Or more generally, what are the use cases of these two ?

Thank you for reading !

#

Ok so while searching for answers, I came upon this :
.with_run_criteria(FixedTimestep::step(TIMESTEP_1_PER_SECOND))

So I am now more confused than ever, another choice 😨

wind flume
#

I haven't used it before, but FixedUpdate is what you should be using for physics.
I believe the idea is that using normal delta_seconds() has the issue that if a frame takes a very short amount of time or a very long amount of time then some physics calculations can behave badly, so FixedUpdate gives you more consistent steps.
The FixedTimestep::step is from an outdated bevy version.
https://github.com/bevyengine/bevy/blob/v0.12.1/examples/ecs/fixed_timestep.rs is one of the examples for that
Also see https://docs.rs/bevy/latest/bevy/time/struct.Fixed.html