To use Avatar Masks and Layers, follow these steps:
- Import the character and the Crossbow prop to Unity. Make sure to have all the required animations.
- Create an Animator Controller and assign it to the character.
- Follow the Using root motion to steer a character recipe in Chapter 4, Character Movement, to make the character move.
- Open the Animator Controller and find the Layers tab.
- Click on the plus button near the Layers tab to create a new Layer and name it Aim. See the following screenshot for reference:
Layers tab
- Drag and drop the AimForward animation to it.
- Click on the small gear icon in the Layer. The Layer Properties window will appear.
- Find the Weight slider and drag it all the way up to 1.
- Right-click on Project View and choose Create |Avatar Mask to create a new Avatar Mask. Name it AimMask.
- Click on it and unfold the Humanoid foldout.
- Unselect the legs of the character. See the following screenshot for reference:
Avatar Mask with only the upper body turned on
- Go back to the Animator Controller, open the Layer Properties of the Aim Layer, and assign the AimMask to the Mask field. See the following screenshot for reference:
Avatar Mask assigned to the Aim Layer
- Assign the RootMotionSteering.cs script to the character to make the character walk. You can find it in the Using root motion to steer a character recipe (Chapter 04 Character movementRecipe 03 Using root motion to steer a characterScripts).
- Play the game to see the effect.