Animation Fundamentals

8.Frames & Time

Understand animation as discrete frames. Use the per-frame scripting hook.

§RRead

An animation is a list of still images shown fast.

To make motion, we write a function that takes the current time and returns the state of the scene at that moment. The simulator calls this function roughly 60 times per second. Each call is one frame. The time between frames is dt — usually about 0.016 seconds (1/60th of a second).

The simplest motion: position = velocity * time. A constant velocity means constant speed in a straight line. Change the formula, change the motion.

§TTry

Step through frames manually.

The particle below starts at rest. Press "Step 1 Frame" to advance time by dt. Each step updates position by velocity * dt. Press "Play" to run continuously.

fig. 8-1
pos:
vel:
change values, then Reset
fig. 8-1 — frame-stepper — step or play, watch t increment
§PPredict

What if velocity isn't constant?

If x = t * t, the particle accelerates — it moves faster each frame. What does the trail look like?

Reveal

The dots in the trail get further apart over time — the particle speeds up. This is acceleration, and it is what gravity does to a falling ball.

§VVerify

Verify: add gravity.

Press Play below. With gravity enabled, the vertical velocity increases each frame. The trajectory curves — a parabola.

fig. 8-2
pos:
vel:
change values, then Reset
fig. 8-2 — frame-stepper — with gravity enabled
§MModify

Explore oscillation.

Challenge: Can you make the particle oscillate back and forth? Toggle the spring force on (next lesson previews this). The particle will bob around the anchor point.

fig. 8-3
pos:
vel:
change values, then Reset
k:4.0
fig. 8-3 — frame-stepper — spring oscillation preview
Checkpoint

You now understand frames and dt. Animation is position updated in a loop. Mark this lesson complete to continue.