The Unity Timeline tool allows us to create simple animations, cinematic cutscenes, gameplay sequences, complex particles, and audio queues. Timeline uses a standard key frame system, if you have ever used video editing software or Flash then the keyframe may be familiar to you already.
In Unity 2021 the Timeline is accessed a little differently than previous versions. It is now found in Window > Sequencing > Timeline.
With the timeline open we can drag any game object to the time line and choose what we want to control. For our example we are going to roll a sphere on the screen without creating any animations in animator.
Steps to follow along:
- Create a sphere in the hierarchy.
- Drag it into the timeline.
- Choose Animation Track
Once the Timeline has an animation track for the sphere it should look like it does in the left image.
We can now click the red record button and add a timeline animation to our sphere.
Keyframing involves making changes at key moments in the timeline. Our ball above moves to the right and rotates over five seconds. To pull this off we provide two keyframes, one at the start and one at the five second mark.
To create a key frame we move the white scrub bar to our intended location and then adjust the spheres properties in the inspector, we move to our next location and again adjust the inspector properties.
My first key frame has the sphere at position 1,0,0 and rotation at 0,0,0. The second (and last) keyframe has the position at 3,0,0 and the rotation at 360, 360, 360. This moves the ball from 1 to 3 on the X axis while rotating.
While rolling a ball is not the most awesome thing we can do, we need to understand the Timeline allows us to create hundreds of tracks with various types of animations. Now we can make cutscenes for our games directly inside of the game engine itself.