Sub topic 10
Extrapolation: what happens outside the keys
A keyframed property has a value at every frame, including frames before the first key and after the last one. Extrapolation is the rule an F-curve uses to produce those values. This chapter covers the two built-in modes, how to make motion repeat, and the mistakes that cause drifting or stalled animation.
This chapter assumes you can insert keyframes, open the Graph Editor, select channels, and change handle types. Those topics come from earlier chapters.
What extrapolation controls
Between its first and last keyframe, an F-curve takes its shape from interpolation and handles. Outside that range there are no neighbouring keys, so Blender needs a separate setting. Each F-curve stores its own extrapolation mode, so X location and Y location can behave differently on the same object.
Blender offers two modes:
| Mode | Behaviour outside the keys | Typical use |
|---|---|---|
| Constant | The value stays equal to the first key before the range and to the last key after it. | Objects that rest before and after an action. This is the default. |
| Linear | The curve continues along the slope at its end and never stops changing. | Steady spinning, constant-speed travel, anything that should keep going. |
Setting extrapolation in the Graph Editor
- Open the Graph Editor and select the channels you want to change. Extrapolation applies to selected curves, so check the selection first.
- Open the Channel menu, then Extrapolation Mode.
- Choose Constant Extrapolation, Linear Extrapolation, Make Cyclic (F-Modifier), or Clear Cyclic (F-Modifier).
The shortcut is Shift+E, which opens the same list at the cursor.
The two Constant and Linear entries change a property on each selected curve. The cyclic entries work differently, as described below.
How the end slope is determined
With Linear extrapolation, the direction depends on the end of the curve:
- If the end keyframe uses Bezier interpolation, the continuing line follows the angle of its handle. Moving the outer handle changes how fast the value grows outside the range.
- If the end keyframe uses Linear interpolation, the line follows the slope of the last segment.
- If the end keyframe uses Constant interpolation, the curve has no slope to continue, so the result looks flat even in Linear mode.
Auto Clamped handles are flat at the end keyframes. A curve with Auto Clamped ends and Linear extrapolation therefore still looks flat. This surprises many people. To get slope, change the end handle to Free, Aligned, or Vector, or use Linear interpolation on the last segment.
Repeating motion with Cycles
Linear extrapolation continues a line. It does not repeat a motion. To repeat, use a Cycles modifier. That is an F-curve modifier, a processing step attached to a curve that changes the values it produces. The next chapter covers modifiers in general. Here you only need this one.
The quickest route is Channel, Extrapolation Mode, Make Cyclic (F-Modifier). Blender adds a Cycles modifier to each selected curve. Clear Cyclic removes it again.
The Cycles modifier has settings for the region before and after the keys:
| Setting | Meaning |
|---|---|
| No Cycles | Do not repeat on this side. The curve falls back to its extrapolation mode. |
| Repeat Motion | Copy the keyed segment again and again. |
| Repeat with Offset | Copy the segment, and add the net change of one pass each time. |
| Repeat Mirrored | Alternate forward and reversed copies. |
Each side also has a Count field. Zero means repeat forever, and a positive number limits the number of repeats.
Choosing the repeat type
- Use Repeat Motion for walk cycles in place, blinking lights, and anything whose last value equals its first value.
- Use Repeat with Offset for a walk cycle that travels. Each pass starts where the previous one ended, so the object advances instead of snapping back.
- Use Repeat Mirrored for pendulum-like back-and-forth motion made from one swing.
A common mistake is using Repeat Motion on a curve whose first and last keys have different values. The value jumps back at every repeat, which looks like a pop. Either make the last key match the first, or switch to Repeat with Offset if the difference is intentional.
Making a loop seamless
A Cycles modifier repeats the segment exactly, so a visible hitch usually comes from the join between the end and the start. Check three things:
- The first and last keys have the same value for Repeat Motion. Copy the first key to the last frame to be sure.
- The handles match. For a smooth join, the slope leaving the last key should equal the slope entering the first key. Auto Clamped handles on both ends give a flat join, which is smooth but can look mechanical for moving parts.
- The cycle length equals the loop you intend. If the loop is frames 1 to 24 and the last key sits on frame 24, frame 1 and frame 24 hold the same pose. A repeat then shows that pose twice in a row and stutters. Many animators place the final key on frame 25 for a 24-frame loop, or accept that the shared pose lasts one frame longer.
Blender can also match the end handles for you. With cyclic extrapolation active, Auto and Auto Clamped handles at the first and last keys are calculated as if the curve continued around the loop. This gives a smooth join without manual handle edits.
Checking the result
The Graph Editor shows extrapolation as a line continuing beyond the last key. Cycles repeats appear as dimmed copies of the curve beyond the keyed range. To see the effect clearly:
- Press Home with the pointer over the editor to frame all keys, then zoom out horizontally with Ctrl+scroll to see more frames.
- Set the scene end frame to the frame range you want to render. Extrapolation affects every frame of the scene, so a Linear curve can send a value very far during a long render.
- Scrub or play past the last key and watch the property in the Properties editor or the N panel.
Doing it from Python
Extrapolation is a property of each F-curve. The Cycles modifier is created through the modifier collection. This code uses action.fcurves, which applies to Blender versions before the slotted-actions change, so check the API docs for your version.
import bpy
obj = bpy.context.object
obj.location = (0.0, 0.0, 0.0)
obj.keyframe_insert(data_path="location", frame=1)
obj.location = (4.0, 0.0, 0.0)
obj.keyframe_insert(data_path="location", frame=24)
fcurve = obj.animation_data.action.fcurves.find("location", index=0)
# Continue along the end slope outside the keys.
fcurve.extrapolation = 'LINEAR'
# Or repeat the motion with an offset on each pass.
fcurve.extrapolation = 'CONSTANT'
cycles = fcurve.modifiers.new(type='CYCLES')
cycles.mode_before = 'NONE'
cycles.mode_after = 'REPEAT_OFFSET'
cycles.cycles_after = 0 # 0 means repeat forever
print(fcurve.extrapolation, [m.type for m in fcurve.modifiers])The valid mode strings for mode_before and mode_after are 'NONE', 'REPEAT', 'REPEAT_OFFSET', and 'MIRROR'. The extrapolation values are 'CONSTANT' and 'LINEAR'.
Common problems
| Symptom | Likely cause | Fix |
|---|---|---|
| Linear extrapolation shows a flat line | The end key has Auto Clamped handles or Constant interpolation | Change the end handle type or the last segment's interpolation |
| Motion pops at every repeat | First and last values differ under Repeat Motion | Match the values, or use Repeat with Offset |
| Loop stutters once per cycle | The first and last frames hold the same pose | Move the last key one frame later |
| Only some properties repeat | Cycles was added to a subset of the channels | Select all relevant channels and add Cycles again |
| Object drifts away forever | Linear extrapolation on a curve that should rest | Switch the curve to Constant |
| Make Cyclic had no effect on a curve | The curve is locked, or it was not selected | Unlock it and check the selection |
Exercise
A cube moves along X from 0 at frame 1 to 4 at frame 24, with Bezier interpolation and Auto Clamped handles on both keys. You switch the curve to Linear extrapolation, but the cube stops at X = 4 after frame 24. Give two ways to make it keep moving, and name the setting you would choose for a walking character who should advance 4 units on every 24-frame step.
Show answer
Auto Clamped handles are flat at the end keys, so Linear extrapolation has no slope to follow. You can change the last key's handle type to Free, Aligned, or Vector and angle the handle upward, or change the interpolation of the last segment to Linear so it follows the segment's slope. For a character that advances 4 units per 24-frame step, add a Cycles modifier with Repeat with Offset after the keys, because it copies the motion and adds the net 4-unit change on each pass.
Exercise
You loop a spinning fan with a Cycles modifier set to Repeat Motion. Its Z rotation goes from 0 degrees at frame 1 to 360 degrees at frame 24. The fan snaps back at the end of each pass. Why, and what is the fix?
Show answer
Repeat Motion copies the keyed segment without adding the change from one pass to the next, so the value returns from 360 to 0 at every repeat. Use Repeat with Offset so each pass begins at the previous end value and the rotation keeps increasing.