F-curve extrapolation
Presently, the ball bounces exactly once, which is not very exciting. It also stands still before frame 10
and after frame 90
, which is not a good look either. To fix this, we could simply duplicate the bouncing keyframes a few more times and shorten our scene frame range. There’s a better way, though – one that will keep our ball bouncing and rolling... forever. We can accomplish this quite easily using a feature called extrapolation.
To understand extrapolation, imagine that the F-curve has a finite “main” segment between its first and last keyframes. Now, try to look at the rest of it, where it ends. You’ll be zooming out for a long while. The F-curve is eternal; it has no beginning or end. It can’t disappear just because there are no keyframes left! It must always have a definite value, even before the animation begins, and long after it has ended. Extrapolation is our word for what an F-curve should do for the rest of time.
By default, all F-curves have Constant Extrapolation, which simply extends them flatly, causing the value to stop changing. This is fine for most things but not for our present F-curves. After selecting different extrapolation modes for these, you’ll be able to drag out the End Frame value and make the scene last an hour if you like, letting the ball bounce miles and miles off into the horizon.
Linear extrapolation
Let’s address the first two F-curves that make the ball roll – X Location and Y Euler Rotation. Instead of adding the keyframes for these at the start and end frames of the scene, I asked you to add them on frames 10
and 90
so that the issue would be easier to see.
What if we wanted the ball to keep rolling? We’d have to extend these F-curves with keyframes that go further up and out. How much further out? This can get unruly if you’re not sure exactly when the animation should end. Fortunately, those keyframes are fine exactly where they are.
All we need to do is set a different mode of extrapolation:
- Select the X Location and Y Euler Rotation animation channels.
- Press Shift + E or go to Channel | Extrapolation Mode.
- Choose Linear Extrapolation.
Linear Extrapolation makes the F-curve continue on a linear slope, which is derived from the first two and last two keyframes. Since there are only two keyframes on each of these F-curves, and they both already use Linear interpolation, the F-curves will appear as perfectly straight lines when extrapolated this way:
Figure 2.20: Linear extrapolation for the X Location and Y Euler Rotation F-curves
Note what this does to our animation. Not only does the ball keep on rolling, it now always has been rolling.
Cyclic extrapolation
Let’s now turn to the Z Location F-curve. To make the ball bounce repeatedly, we could use what we already know and duplicate the three bouncing keyframes a hundred times or so... but let’s not. There’s another extrapolation mode available that can do all the work for us much more cleanly.
Let’s look at it now:
- Select the Z Location animation channel.
- Press Shift + E or go to Channel | Extrapolation Mode.
- Choose Make Cyclic (F Modifier).
The F-curve now has what’s called cyclic extrapolation. The keyed segment of the F-curve will now repeat indefinitely. Wait, though! Something’s not right:
Figure 2.21: A bounce-and-roll kind of F-curve
That’s an odd pattern. What’s going on here?
Remember, cyclic extrapolation repeats the entire keyed segment of the F-curve – that is, everything between the first and last keyframes. Where is the last keyframe on this curve? All the way over on frame 90
! We added it at the very beginning of this chapter and forgot about it. This sort of thing happens to animators all the time.
We want to repeat a 20-frame bounce, not an 80-frame bounce-and-roll. That pesky keyframe is messing up the cyclic period of our F-curve! Let’s send it to Hell:
- Select the Z Location keyframe on frame
90
. - Press X to delete it.
Ah, that’s much better.
Figure 2.22: Properly repeating bounces
Now that only our three bouncing keyframes remain, the next bounce happens immediately after the previous one, giving us crisp, clean bounces.
You’re finished with the bouncing ball animation! Continue playing around with it if you like – maybe set your End Frame to 10,000
and watch your creation go out into the world:
Figure 2.23: Come back!
And we’re done!