Using Time.deltaTime instead of passing in deltaTime as parameter

I noticed that PlayerTestState can just use Time.deltaTime in the Tick() function instead of passing in deltaTime as a parameter. Why are we doing that?

2 Likes

It’s a design choice. You absolutely can use Time.deltaTime. Nathan is using the classic construction of a State class which is engine independent. You may find yourself writing state machines in settings other than Unity. While Unreal Engine has some form of globally accessible deltaTime, this may not be the case in every circumstance. It’s not a bad habit to pass in the delta time to a State, even if it’s not strictly neccessary in Unity.

3 Likes

Thanks, Brian! Got it!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms