Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We’re making changes to the Unity Runtime Fee pricing policy that we announced on September 12th. Access our latest thread for more information!
    Dismiss Notice
  3. Dismiss Notice

Resolved how to add an avatar mask to an animation that was made in unity?

Discussion in 'Animation' started by kij_od_miotly, Mar 10, 2023.

  1. kij_od_miotly

    kij_od_miotly

    Joined:
    Jan 27, 2022
    Posts:
    25
    all the tutorials i have seen use animations made in other programs
     
  2. Rukhanka

    Rukhanka

    Joined:
    Dec 14, 2022
    Posts:
    163
    Create new AvatarMask from code:
    Code (CSharp):
    1. var avatarMask = new AvatarMask();
    Add bone transform hierarchy:
    Code (CSharp):
    1. avatarMask.AddTransformPath(boneRoot, true)
    Mask out the required bones:
    Code (CSharp):
    1. avatarMask.SetTransformActive(...);
    Use created mask in Avatar:
    Code (CSharp):
    1. var animatorController = new AnimatorController();
    2. ...
    3. animatorController.layers[0].avatarMask = avatarMask;
     
    SolarianZ and Homicide like this.
  3. Homicide

    Homicide

    Joined:
    Oct 11, 2012
    Posts:
    638
    but its really the same thing no matter where an animation has come from.

    Look in the Animator window, and look at the layer. Theres a cog wheel. You can apply masks per layer. You can create more layers.

    That should get you tinkering.

    Rukhanka just provided the ins and outs.