Combining Cinemachine and Timeline to Open a Treasure Chest in Unity
--
Objective: To combine both Cinemachine and Timeline to create a cinematic opening of a treasure chest.
I have recently posted a couple days ago the article the showed how to open a treasure chest using Timeline. Well this one is going to be super quick and show you how to incorporate Cinemachine to give it that added cinematic touch.
Existing Scene
Using the existing scene I have already setup:
Let’s add a Cinemachine camera to our existing Timeline that is going to be used to zoom in on the treasure chest when it is opened, and zoom back out once it’s closing.
Adding Cinemachine Camera to Scene
Head to the Cinemachine tab → Add Virtual Camera.
Adjust the ‘Field of View’ option in the Inspector so it looks something like this:
Add Cinemachine Virtual Camera to Timeline
Let’s now drag and drop this Cinemachine Virtual Camera game object into the existing Timeline, and let’s choose ‘Add Clip With Cinemachine Track’:
The Cinemachine Track is also looking for a Cinemachine Brain, so make sure to drag your game object into this field — more than likely this will/should be sitting on your Main Camera game object. Look for this symbol in your Hierarchy:
It’s That Simple! Let’s Test it Out!
It’s a little bit rough around the edges and I don’t quite like how sharply it cuts to the Cinemachine Track so let’s add some Ease In/Out to the track:
Let’s Try Again!
Much Better!!!