Search Unity

Question Set speed of all animation states in a single sub state machine or layer?

Discussion in 'Animation' started by GrayedFox, Nov 29, 2020.

  1. GrayedFox

    GrayedFox

    Joined:
    Jan 28, 2014
    Posts:
    70
    Hey all, I must be blind but I cannot figure out how to get all the animation states of a sub state machine.

    There's Animator.speed which doesn't work, since that would also slow down the base layer which controls walking and running (which is allowed during some character actions and some casting animations).

    Setting AnimationState.speed seems like the perfect solution, but so far none of the Animator's public methods seem able to return animation states?

    The Animation component seems to let one loop through every single state machine attached to that animation, but I also can't see where or how I can get an "Animation" from an "Animator". My Animator is attached to the player game object.

    Would really appreciate some help here - I need to be able to speed up or slow down animations based on the characters move, attack, and cast speed and I have different layers dedicated to each of those tasks.

    Thanks!
     
  2. GrayedFox

    GrayedFox

    Joined:
    Jan 28, 2014
    Posts:
    70
    But of course, the moment I post a question I find an answer to my problems.

    As discussed here: I can just use a parameter and use it as a multiplier of each specific state.

    This is exactly what I needed!
     
  3. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,570
    AnimationState and the Animation component are from the legacy animation system.

    Using a multiplier parameter is the correct way to do it in an Animator Controller.
     
    GrayedFox likes this.