#When to actually use Time.deltaTime?

1 messages · Page 1 of 1 (latest)

jaunty forge
#

So I've been making (mediocre) games a decent amount of time and I still don't exactly understand this aspect of coding.
When should I be using "Time.deltaTime"?

For example, do I use it within fixedUpdates? And what about jumps? Should the force used for those be multiplied by it or no? I just really am confused on when it should and shouldn't be used lol! If anyone can explain, that would be awesome!

nova hearth
# jaunty forge So I've been making (mediocre) games a decent amount of time and I still don't e...

if you're changing a value over a series of frames you typically want to to do it independent of framerate, thats when you usually would use it .. In update , say you got a timer value that increases timer += 1, to not make people with higher frames increase timer faster than people with lower frame rates, you would add timer += 1 * Time.deltaTime
it would account for the frame rate difference "delta" in time

jaunty forge
nova hearth
#

when used inside FixedUpdate it turns it already into Time.fixedDeltaTime which is instead using fixed rate, same as FixedUpdate

jaunty forge
#

oh, so it turns into is own new thing entirely?

jaunty forge
#

oh sweet! thanks!

nova hearth
jaunty forge
#

Okay! That is actually really helpful! Thanks a ton!

upbeat mountain
foggy hedge
#

another perspective: it's a conversion factor between "x per second" and "x per frame"
if you have a value in "x per seconds" and you need to convert to "x per frame" (such as changing a value over time in Update) then that's where you would use deltaTime
fixedDeltaTime is similar, but for "x per physics tick" instead

errant ruin