How to do it...

To use Avatar Masks and Layers, follow these steps:

  1. Import the character and the Crossbow prop to Unity. Make sure to have all the required animations.
  2. Create an Animator Controller and assign it to the character.
  3. Follow the Using root motion to steer a character recipe in Chapter 4Character Movement, to make the character move.
  4. Open the Animator Controller and find the Layers tab.
  1. 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
  1. Drag and drop the AimForward animation to it.
  2. Click on the small gear icon in the Layer. The Layer Properties window will appear.
  3. Find the Weight slider and drag it all the way up to 1.
  4. Right-click on Project View and choose Create |Avatar Mask to create a new Avatar Mask. Name it AimMask.
  5. Click on it and unfold the Humanoid foldout.
  1. Unselect the legs of the character. See the following screenshot for reference:
Avatar Mask with only the upper body turned on
  1. 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
  1. 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).
  2. Play the game to see the effect.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.143.203.96