When you wish to make a simple, basic animation of an object within your scene, changing its position, size, or simply rotating it can all be done easily through the Timeline Editor window using keyframe animation. In this tutorial, you'll create a basic animation by recording the changing properties of a GameObject as keyframes in Timeline.
In the Timeline window, you can easily record animations and set keyframes. You do this with what’s called an Infinite clip. An Infinite clip is a clip that contains basic keyframe animation recorded through the Timeline Editor window. When you wish to make a simple, basic animation of an object within your scene, changing its position, size, or simply rotating it can all be done easily through the Timeline Editor window using keyframe animation. Keyframe animation records the state of the object and then interpolates between the changes of each keyframe. This ends up being a useful tool for quickly making animations without having to import a custom animation clip or open the Unity Animation Editor window.
Open the Timeline Window
To open the Timeline window:
Click the Window dropdown on the main Editor window.
Click Sequence > Timeline.
A new window will open; this is the Timeline Editor window. (Figure 01)
Setting Up to Record
Before you can begin recording a keyframed animation, you must add an animation track to the Timeline Editor window. Once you’ve added a track, you’ll notice a red circle on the right side of the track. (Figure 02)
This is the Record button on the track. Clicking it will enable Record mode for the selected track. When a track is in Record mode, the clip area of the track is drawn in red with the “Recording…” message displayed in the track and the Record button blinking. (Figure 03)
When you are in Record mode, any modification to an animatable property of the GameObject sets a key at the location of the Timeline Playhead, for example if you are recording on a GameObject and you change its position, a key will automatically be set with the changes you made. Animatable properties include transforms and the animatable properties for all components added to the GameObject.
Recording a Basic Animation
To begin recording a basic animation through Timeline:
Move the Timeline Playhead to where you wish to set the first key.
In the Inspector window, right-click the name of the property you wish to key. (Figure 04)
Click Add Key from the context menu. This will add an animation key for the property without changing its value. A white diamond will appear in the clip to show the position of the key on your playhead. Whenever you create a key, it will always appear on your playhead’s position. (Figure 05)
You can also set the animation keyframe in two other ways:
In the Inspector window, change the value of the animatable property of the GameObject. This automatically adds an animation key for the property with its changed value.
In the Scene view, move, rotate, or scale the GameObject to add a key. This automatically adds a key for the properties that you change.
To continue animating, move the playhead to a different position on the timeline and add a new keyframe. Keep doing this until you have the animation desired. When you finish the animation, click the blinking Record button to disable Record mode. This will stop the recording and make the Infinite clip appear as an animation track in the Timeline Editor window. (Figure 06)
Although you can’t edit the keyframes in the Timeline Editor window, it’s useful to be able to create basic animations when you’re working on larger projects. This allows you to quickly add animations when needed without having to go through a whole different window to record and animate.