Search Unity

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:
    204
    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:
    657
    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.