Resetting timeSinceLastAttack

When I was doing the challenge for this video, I set timeSinceLastAttack = Time.deltaTime, while Sam resets timeSinceLastAttack to 0 after the attack behavior.

I got the same result in the throttling, and I tested the value of timeSinceLastAttack with a print statement using both methods but I’m not sure why it works (I was just trying it out).

Are they functionally the same? Why/why not?

Thanks in advance!

I’ll let Sam answer this one directly:

The TLDR of this is that Time.time is a float, and the larger floats get, the more resolution they lose, so while a timer starting at Zero and adding Time.deltaTime every frame is more accurate than comparing a float to Time.time

This topic was automatically closed after 31 hours. New replies are no longer allowed.

Privacy & Terms