O'Reilly logo

Unity 5.x Animation Cookbook by Maciej Szcześnik

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

To be able to detect hits for different body parts, follow these steps:

  1. Import your character with all the necessary animations to Unity. Place it on the scene.
  1. Create a new Layer and name it BodyParts. To do so, go to the Layers menu and choose the Edit Layers option, as shown in the following screenshot:
Adding a new Layer
  1. Create a new script and name it BodyPart.cs. Create only one public string bodyPartName variable in this script. We will use it as a dummy script for our body parts. You will be able to implement custom effects of given body part hits in this script layer.
  2. Create an empty game object and name it 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required