Course contentsShow
← Unity Game Development
Lesson 120 of 8282. Scripting and LifecycleFree lesson

Scaling Rotational Velocity for Consistent Angular Motion

Calculate frame-independent rotations by multiplying angular speed values by Time.deltaTime to prevent stuttering during high-performance scenarios.

Scaling Rotational Velocity for Consistent Angular Motion

In this lesson, you will learn how to ensure your objects rotate at the same speed regardless of your game’s frame rate.

The Problem with Frame-Dependent Rotation

When you rotate an object inside the Update method, your code runs every single time a frame is rendered. If your game runs at 60 frames per second on one computer but 144 frames per second on another, the object on the faster computer will rotate more than twice as fast. This happens because the rotation is being applied 144 times per second instead of 60, causing inconsistent behavior that can break your game’s physics or design.

Scaling with Time.deltaTime

To achieve consistent angular motion, we must scale our rotation values by Time.deltaTime. This value represents the amount of time (in seconds) that passed since the previous frame. By multiplying your rotational velocity by this value, you are essentially telling Unity: "Rotate this many degrees per second, rather than per frame."

Consider this code snippet for a constant spinning motion:

public float rotationSpeed = 100f;

void Update()
{
    // Rotate the object around the Y axis
    // Multiplying by Time.deltaTime normalizes the speed
    transform.Rotate(0, rotationSpeed * Time.deltaTime, 0);
}

Why it Works

If your frame rate fluctuates—perhaps due to a heavy explosion or a complex scene—Time.deltaTime automatically becomes a larger number for "slow" frames and a smaller number for "fast" frames. When you multiply your rotationSpeed by these values, the rotations balance out perfectly. On a slow frame, the object rotates a larger chunk at once; on a fast frame, it rotates a smaller chunk. The end result is that your object completes its full rotation in the exact same amount of time, no matter how powerful the player's hardware is.

By applying this simple scalar, you transform fragile, frame-dependent rotation into robust, time-based movement that feels smooth and predictable on every machine.

Key Takeaway: Always multiply your rotational speed variables by Time.deltaTime within Update to ensure your object rotates consistently across varying frame rates.