Day #29: Animating GameObjects Using Timeline

Ali Emre Onur
4 min readApr 11, 2021

--

Another week is gone and the first month of this journey is almost over. I am really enjoying this so far, and Unity becomes much more easier to handle as more work has been done.

I’ve spent the past week on the Cinematography field, with the Timeline component that I had no experience at all before. Missing a component like “Timeline” was huge, and I am really happy to getting more familiar with it.

This article will be focused on Timeline and Animation components. Unity really made it easy to handle animation and timeline simultaneously.

Animation Using Timeline: Fading Effect

Funny thing, I was actually really surprised to find out that Blacking out effect is just an animation of black image with different transparency. I will try to demonstrate the way to create fading in and out effects at the beginning and at the end of the cutscenes. First, create an image, set it to color black with maxed Alpha, and make cover the entire screen. by Stretching it from the Rect Transform — and your game view will be compeletly black.

Now, we are ready to create the animation for fading out. Switch to the game object that we set the Cinemachine Brain on (as you remember, you can simply create it by dragging and dropping Main Camera to the Timeline).

As I have mentioned at the end of my Timeline article (click here), we need to add an animation track to the Timeline in order to manipulate our game objects via Animation. Simly click the add button and select Animation Track.

It will ask for an animator component, drag and drop the game object that you want to animate and Unity automatically ask and add the Animator component if it does not exist on the game object.

To add an animation clip, click on the 3 dots on the right of the record button and select “ Add From Animation Clip”, and clip will be added to the timeline.

Now, by simply clicking on the record button on the right hand side, we can start animating.

To create the fade out effect, we need to make Unity to record that the image’s Alpha is set to 255 at the start. So after clicking on Record, at just the starting point, just move back and forth to 255. You will realize the diamond sign, denoting that we have made a change will be added to the corresponding time at the Timeline window. Then, at the point where you want the effect gone, select the image again and set the Alpha to 0.

Alpha setted to 0 for maxed transparency

If you are unhappy with your recording, you can either delete and record again or edit it in the animator. In order to make a change in an animation (including a recording that we completed via Timeline), we can easily reach to the Animation window by right clicking and selecting it. You will notice the same change points at the Animation window.

And that’s it. Just like we have animated the black in and out effect, we can animate and manipulate any game object in our game by using the same way.

--

--