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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.