#How do I properly use delta time?
12 messages · Page 1 of 1 (latest)
You should use it in apply_velocity.
In apply_gravity, it would probably be better to modify the velocity instead, since you're resetting force every frame, at least what you're doing there is wrong: gravity * time is not a force.
not sure what you're trying to do in apply_friction
I’m trying to slow down the object, otherwise it keeps moving forever. Also gravity is an acceleration and the objects mass is 1, so I thought applying it to force was correct
You should use delta time when applying things that indicate a change over time. In other words, their unit is "x per second".
Another way you can think of it is to ask yourself "if delta time was twice as big, should this have twice as big effect?"
Example: If delta time is twice as big, would velocity affect position twice as much?
Makes sense, my main concern is that a lot of these things are being multiplied by delta time multiple times over
I changed it a bit
ignore ACCELERATION its just a constant for the movement
It appears to work as expected but I'm really not sure. I wish bevy had a way to control framerate so I could be sure that the velocity is working independently
If there are multiple things changing over time, it makes sense to apply delta time multiple times. For example: acceleration is changing velocity over time and velocity is changing position over time. So it makes sense that delta time is applied twice.
It looks correct to me, but I'm not really that knowledgeable on physics so don't trust me on that.
Since you are using FixedTime, are you running it on fixed timestep schedule? If so I think you should be able to change the time step.
You might also take a look at https://github.com/aevyrie/bevy_framepace
I’ll take a look, thanks