Our game wants to rotate something at 3 radians/second on every device. Let's see how this works at different framerates.
For a device running at 60 FPS:
Delta time (time for 1 frame) = 0.0167 seconds
Rotation covered in 1 frame = 0.0167 * 3 (radians/second) = 0.05 radians
Total rotation in 60 frames = 0.05 * 60 = 3 radians
For a device running at 30 FPS:
Delta time (time for 1 frame) = 0.033 seconds
Rotation covered in 1 frame = 0.033 * 3 (radians/second) = 0.1 radians
Total rotation in 30 frames = 0.1 * 30 = 3 radians
The key insight here is that based on FPS, the amount of rotation that happens in a single frame changes. For higher FPS it's lower (smaller steps), and for lower FPS it's higher (bigger steps).
But the total rotation over one second remains the same: 3 radians.
This is why we use delta time - it ensures consistent motion regardless of the device's frame rate. Instead of applying rotation (3 radians/second) directly per frame, we calculate the appropriate rotation for each frame by multiplying our desired rate by delta time (seconds/frame).
So time dependency becomes frame dependency that resolves itself on each device.
Top comments (0)