Mobile Game Progression
Adding a cut scene for the beginning of the gameplay (part 1)
If we have been following me since the beginning, you would have known that we have covered Timeline feature and also working with Cinemachine. Although during that application it was within an 3D environment, the same functions can be applied to 2D as well. In this article we will focus on creating a 2 second camera pan animation for the introduction.
Setting up Cinemachine:
If you haven’t already, we need to download the Cinemachine plugin for Unity, or if you need to update to the current patch. In the Package Manager which can be accessed by Window > Package Manager. We are going to check if we have Cinemachine installed in our Unity plugin. On the top bar we are going select Packages: In Project, to check if Cinemachine is within the asset list.
If it isn’t, in the package drop down menu, select Unity Registry and search for Cinemachine to download/and or update.
Once installed, the Cinemachine function would appear on the top of your menu bar.
Creating our Virtual Camera:
Within the drop down menu of the Cinemachine, we can do a lot of things, but we will be focused on the Virtual Camera.
Select “Create Virtual Camera” to start making new cameras. In the Inspector we can start by giving the virtual camera a new name. For my intro animation, I am going to have 3 camera pans that happen across the map. Therefore I will be creating 3 virutal cameras.
Next we can position each individual camera to our desired location within the scene. We will be adding movement later.
Setting Up a Dolly Track for the Camera to follow:
Since we don’t want to have our virtual cameras static nor stationary, we are going to create a new dolly track for the camera to follow. A Dolly Track is what professional movies use for smooth and seamless camera pans from one section to another. In Unity it follows the same principle but for virtual cameras.
To create our first Dolly Track, under the Cinemachine menu we are going to select “Create Dolly Track with Cart”. That option is going to create an extra Virutal camera, but since we already have our own, we can delete the new one.
Drag the Dolly Track as a child object of the Virtual camera. When setting up the Dolly track, you will noticed that there are two nodes of waypoints by default. You might need to adjust their distanced between each other since they might appear overlap. You can also change the view from 2D to 3D just to get a better view of the Dolly Track as seen below.
Once you managed to gain access to the two individual waypoints, we start positioning them to where we want our camera to travel to. Waypoint Zero is the starting point while every other node is next. The more waypoint nodes you add the more directions you can add to the track.
Finally to attach our Virtual camera to our Dolly Track, we need to identify it within the Virtual camera settings. Set the Body type to “Tracked Dolly” and within the Path slot drag and drop the Dolly Track object. You should see the Virtual camera snap into place set by the Dolly Track.
To test the position between the waypoint nodes you set up in the Dolly Track, you can select the Virutal Camera and click “Solo” which will force that camera to be active.
Then in the Path Position depending on how many warpaths points you have up, can be swap in. So in my situation, I have two waypoints, 0 and 1.
In the next article we will work with Timeline to animate the path positions of the camera to transfer during a set timer.