Nicholas Yang (nyanginator)

2 answers · asked · Lesson: Controlling a Tank Turret · Course: C# Bootcamp for Unity

What does (Time.deltaTime*smooth) actually do?

The Unity manual says the 3rd parameter of Quaternion.Lerp() is a value between 0.0f and 1.0f (https://docs.unity3d.com/ScriptReference/Quaternion.Lerp.html).

Setting smooth to a high value like 100 would contradict this.

So I'm not understanding the purpose of (Time.deltaTime*smooth), or exactly what it's doing for the rotation transitions.

  • crew

    Time.deltaTime is used for these things to ensure that movement is time based and not frame rate dependent. If we just used smooth directly it would work fine, but then if someone has a higher frame rate they'd get faster rotation versus someone who has a lower frame rate. By using time it's the same for both. The smooth value is a multiplier for that, so we can still use time but we increase how fast that time is by multiplying it by smooth.