Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Order of motion layers within an animation layer

Discussion in 'Scripting' started by Bonnate, Nov 23, 2022.

  1. Bonnate

    Bonnate

    Joined:
    May 30, 2021
    Posts:
    5
    Hi, sorry for my bad english

    I'm implementing a feature that automatically switches multiple Idle animations using BlendTree in Unity. All features work perfectly.

    But the script can't understand the index reference of the array that goes into:
    Code (CSharp):
    1. AnimatorController animatorController = ... ;
    2. BlendTree tree = (BlendTree)animatorController.layers[mLayerIndex].stateMachine.states[ {{ HERE }} ].state.motion;
    I know for sure that layers[mLayerIndex] is the order of the layers in the animation controller, but I don't know how it relates to the order of the StateMachines within the layers.

    Can you tell us about this relationship?

    The image below is an image of an animation controller in action.
    Layer 0 is clear, but the layers of the internal state machines are not regular. motion[id] is the number actually assigned.

     
    Last edited: Nov 23, 2022