Reader small image

You're reading from  Unity 5.x Animation Cookbook

Product typeBook
Published inMay 2016
Reading LevelExpert
PublisherPackt
ISBN-139781785883910
Edition1st Edition
Languages
Tools
Right arrow
Author (1)
Maciej Szczesnik
Maciej Szczesnik
author image
Maciej Szczesnik

Not interested. Too busy with current game project. Source: Linkedin.
Read more about Maciej Szczesnik

Right arrow

Chapter 8. Animating Cutscenes

This chapter explains how to create and play cutscenes in games and covers the following recipes:

  • Using the Animation View to animate the camera
  • Changing cameras with animation
  • Synchronizing animation of multiple objects
  • Importing a whole cutscene from a 3D package
  • Synchronizing subtitles
  • Using root motion to play cutscenes in gameplay

Introduction


In this chapter we will handle cutscenes. These are short animated sequences used mostly to unveil new story events. You can create a lot of them directly in Unity, or import animations from your favorite 3D package (we will be using Blender 3D as an example).

Using the Animation View to animate the camera


In this recipe, we will create camera animation using Unity's built-in Animation View:

Simple vertigo effect created with the Animation View

Getting ready

We don't need anything fancy for this recipe as we will create it from scratch in Unity. You may need some decorations in the scene though. You can also open the provided example Unity project and go to the Chapter 08 Animating Cutscenes\Recipe 01 Using the animation view to animate the camera directory. You can find an animated Camera (1) game object in the Example.unity scene there. If you play the game, the camera will play an animation.

How to do it...

To create camera animation with the Animation View, follow these steps:

  1. Select the camera you want to animate (you can also add a new camera to the scene).
  2. Open the Animation View (go to WindowAnimation).
  3. Create a new Animation Clip and call it CameraAnimation.
  4. Make sure the record button is pressed.
  5. Move and rotate the camera to create the desired...

Changing cameras with animation


Not only can we animate cameras using the Animation View, but we can also change the shots in time.

Getting ready

This recipe will also be created from scratch in Unity. You can download the example Unity project provided and go to Chapter 08 Animating Cutscenes\Recipe 02 Changing cameras with animation directory. You can find a Camera Changer game object in the Example.unity scene there, with three cameras as children. If you play the game, the cameras will change.

How to do it...

To change cameras using animation, follow these steps:

  1. Create an empty game object in the Scene View and name it CameraChanger.
  2. Rename the Main Camera to Camera (1) and copy it two times. You should have Camera (1)Camera (2), and Camera (3) game objects.
  3. Parent all three cameras to the CameraChanger.
  4. Place the cameras as you wish.
  5. Set the Depth of the cameras in increasing order. Every new shot should have a greater Depth value.
  6. Select the CameraChanger game object and open the Animation...

Synchronizing animation of multiple objects


In a cutscene, we have to synchronize animation of multiple objects in time. This recipe shows how to do it.

Getting ready

To follow this recipe, you will need an animated character and an animated object. You can download the provided example Unity project and go to the Chapter 08 Animating Cutscenes\Recipe 03 Synchronizing animation of multiple objects directory. You can find the Example.unity scene there. If you play the game, you will see a character kicking a soccer ball. Both objects are animated and synchronized. You can find the needed animations in the Animations directory:

Synchronized animation of the ball and a the character kicking it

How to do it...

To synchronize animation of multiple objects, follow these steps:

  1. Open both objects in your 3D package (we are using Blender in this example).
  2. Synchronize both objects' animations in the 3D package. In our example, the animation has about 160 frames. Both objects have the same length of animation...

Importing a whole cutscene from a 3D package


The best way of creating cutscenes in Unity is to import whole animations from a 3D package. We did a similar thing in the previous recipe (we synchronized the animations in a 3D package before importing them to Unity). Here we are going to create a full cutscene with camera animations.

Getting ready

For this recipe, we need the same character as in the previous recipe, with a kicking the ball animation. Additionally, we've added three simple cubes to the animation. Those cubes are animated and represent cameras. We used cubes instead of empty objects or cameras because Unity sometimes has trouble with importing the motion of objects that are not rigs nor have mesh renderers:

Cutscene objects in Blender. Red cubes hold camera positions

You can also go to the Chapter 08 Animating Cutscenes\Recipe 04 Importing a whole cutscene from a 3D package directory. You can find the Example.unity scene there. If you play the game, you will see a character kicking...

Synchronizing subtitles


In this recipe, we create subtitles and synchronize them with the animation:

Subtitles synchronized with animation

Getting ready

In this recipe, we will use the same cutscene as in the previous one. You can also open the example Unity project and go to the Chapter 08 Animating Cutscenes\Recipe 05 Synchronizing subtitles directory. If you open the Example.unity scene there and play the game, you will see changing subtitles synchronized with the animation.

How to do it...

To synchronize subtitles with a cutscene, follow these steps:

  1. Import the cutscene the same way as in the previous recipe.
  2. Create a new Image (go to Game ObjectUIImage).
  3. Name it SubtitlesContainer.
  4. Create a new Text game object and parent it to the SubtitlesContainer. To do so, right-click on the SubtitlesContainer and choose UI |Text.
  5. Change the color of the SubtitlesContainer's Image component to semitransparent black. Change the color of the Text component to white. Adjust the position and size of the...

Using root motion to play cutscenes in gameplay


We can also play cutscenes in gameplay without changing the camera, and using smooth transitions to move in and out of a cutscene. This recipe shows an example of that.

Getting ready

In this recipe, we will use the same cutscene as in the previous recipe. You can also open the example Unity project and go to the Chapter 08 Animating Cutscenes\Recipe 06 Using root motion to play cutscenes during gameplay directory. If you open the Example.unity scene there and play the game, you will be able to move the character. Approach the red sphere marker and press the space bar to play the cutscene:

Cutscene played during gameplay

How to do it...

To play cutscenes during gameplay, follow these steps:

  1. Import your cutscene. Make sure to import the character animation as a separate file.
  2. Go to the cutscene asset's Import SettingsAnimation tab.
  3. Rename the Default Take animation to Cutscene.
  4. Create a new Animation Clip, choose the Default Take as the source, and...
lock icon
The rest of the chapter is locked
You have been reading a chapter from
Unity 5.x Animation Cookbook
Published in: May 2016Publisher: PacktISBN-13: 9781785883910
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
undefined
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime

Author (1)

author image
Maciej Szczesnik

Not interested. Too busy with current game project. Source: Linkedin.
Read more about Maciej Szczesnik