Sub topic 1
Animation as values changing over time
Every animation in Blender comes down to one idea: a property has a different value at different moments. An object's location, a light's strength and a material's color can all change as the playhead moves. This chapter builds that working model. The later chapters cover the tools that create and edit the data.
Prerequisites
This chapter assumes you can already do the following:
- Navigate the 3D Viewport and select and move objects.
- Find values such as location, rotation and scale in the Properties editor and the Sidebar.
- Change an editor's type and resize areas in the interface.
You do not need any animation experience. The one Python example is optional, and the rest of the chapter works without it.
A property is a value at a moment
A still scene has one value for each property. A cube sits at X = 0, and that is all there is to say. An animated scene stores a rule for how the value depends on time. You can write this as a function:
location_z = f(frame)
You never write f yourself. You give Blender a few sample points, and it works out the values between them.
Blender calls the unit of time a frame, which corresponds to one rendered image. The current frame is the moment the scene is evaluated at. Whenever it changes, Blender recomputes every animated property for the new frame and redraws the viewport. If you scrub the playhead, you are only changing the input to f.
Why you do not store every frame
Storing a value for every frame would be tedious to author and painful to change. A three-second move at 24 frames per second would need 72 values. If you wanted the motion to be slower, you would have to redo all of them.
Blender stores only the values you care about. A keyframe records one property's value at one frame. For a rise from 0 to 2 units over 23 frames, you store two keyframes:
| Frame | Location Z |
|---|---|
| 1 | 0.0 |
| 24 | 2.0 |
For every frame between and around those two keyframes, Blender computes the value itself. The rule it uses is the interpolation mode. The default is Bézier, which eases in and out. Linear and Constant are also available. The Interpolation modes chapter covers the choices.
Outside the first and last keyframe, the value is held constant by default. Before frame 1 the object stays at 0, and after frame 24 it stays at 2.
Animation overwrites the stored value
This model explains the most common surprise for newcomers. Once a property has keyframes, its displayed value is an output of the animation system. It is no longer something you set directly.
Suppose a cube has keyframes on its location. You move it by hand in the viewport without keying anything, then change the frame. The cube jumps back to the animated position. Blender re-evaluated the animation and overwrote your manual edit, because you never stored it as a keyframe.
The same rule applies in reverse. If you want a manual change to last, you must record it as a keyframe (the next chapters cover how). Otherwise the next evaluation discards it.
Frame rate turns frames into seconds
Frames are a count and not a duration. The scene's frame rate, in frames per second (fps), converts one to the other. At 24 fps, frame 25 is one second after frame 1. At 30 fps the same frame is only 0.8 seconds in.
Two consequences follow:
- The same keyframes play faster or slower if you change the frame rate. The keys do not move, but a frame now lasts a different amount of time.
- The frame range (start and end) only decides which part of the timeline plays and renders. It does not delete keys outside it. A keyframe at frame 200 still exists if the end frame is 48. You just do not see it play.
The Frames, frame range, and frame rate chapter covers these settings in detail.
Worked example: watching the value change
This script creates the two keyframes from the table above and then reads the property back at three frames. Select an object in the 3D Viewport first. The script uses the active object.
import bpy
scene = bpy.context.scene
obj = bpy.context.active_object
obj.location = (0.0, 0.0, 0.0)
obj.keyframe_insert(data_path="location", frame=1)
obj.location = (0.0, 0.0, 2.0)
obj.keyframe_insert(data_path="location", frame=24)
for frame in (1, 12, 24):
scene.frame_set(frame)
print(frame, round(obj.location.z, 3))Run it from the Text Editor or the Python Console. The output at frames 1 and 24 is exactly 0.0 and 2.0, because a keyframe is stored there. At frame 12 you get a value close to, but slightly below, 1.0. The frame is just under the midpoint of the 1 to 24 span, and Bézier easing bends the curve. If you switch the keys to linear interpolation, the value at frame 12 is 11/23 of the way from 0 to 2, which is about 0.957.
scene.frame_set(frame) is what makes Blender re-evaluate the animation. Without it, reading obj.location returns whatever value the property held last.
Common errors
These are the mistakes this model predicts:
- Edits that vanish. You change an animated property without keying it, change the frame, and the value reverts. The fix is to insert a keyframe after the edit.
- Values that seem wrong at a key frame. The property shows a stale value in a script because the frame was never set. Call
frame_setbefore reading. - A move that is "too fast" or "too slow". This is usually a frame rate mismatch, or two keys that sit fewer or more frames apart than you intended. It does not mean the animation data is broken.
- Animation that stops early. The end frame is lower than your last keyframe. The keys are intact, so raise the end frame.
- Keys that appear to do nothing. A keyframe holds the same value as its neighbours, so interpolation produces no change.
What comes next
The remaining chapters of this tutorial follow the path of the data. You will set frames and the frame range, then create keyframes. The Timeline and Dope Sheet let you view and edit them. You will finish with interpolation, actions and a bridge to the Graph Editor. Keep the function f(frame) in mind throughout, since each tool is a different way to author or inspect its sample points.
Exercise
A cube has keyframes at frame 1 (X = 0) and frame 25 (X = 4), with the scene at 25 fps and linear interpolation. You are on frame 13 and drag the cube to X = 10 without inserting a keyframe, then move to frame 14. What X value does the cube have at frame 14, and why? Also, how many seconds apart are the two keyframes?
Show answer
At frame 14 the cube is at X = 2.1667 (13/24 of the way from 0 to 4), not 10. Blender re-evaluates the animation when the frame changes and overwrites your unkeyed edit with the interpolated value. The keyframes are 24 frames apart, which at 25 fps is 0.96 seconds.