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 

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.