Getting ready

We are going to use the same assets as in the previous recipe. Additionally, we are going to use the CharacterLookAt.cs created in the Using Quaternion.LookRotation() and Animator.SetLookAtPosition() methods to make characters follow an object with their gaze recipe in Chapter 5Character Actions and Expressions.

You can also use the provided example Unity project and go to the Chapter 06 Handling combat\Recipe 08 Using the LookAt method to aim directory. You will find an Example.unity scene there, with a Humanoid character. Play the game to see the aiming effect.

Get Unity 5.x Animation Cookbook now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.