Search Unity

Question Adjust Blend Tree speed at RUNTIME

Discussion in 'Animation' started by KarlKarl2000, Nov 8, 2021.

?

Have you wanted to adjust the animation speed of your Blend Tree at runtime?

  1. Yay

    20 vote(s)
    100.0%
  2. Nay

    0 vote(s)
    0.0%
  1. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    hi all
    How can we change the speed of the blend tree at runtime?

    I couldn't find anything in the API docs mentioning this. :(
    https://docs.unity3d.com/ScriptReference/Animations.BlendTree.html

    sped.jpg
    This speed is what I'd like to adjust at runtime.

    sped1.jpg
    I wasn't able to figure out how to use this. Not sure it's the Speed I'm looking for either.
     
  2. subliminole

    subliminole

    Joined:
    Apr 26, 2016
    Posts:
    8
    You make a parameter, set it as the multiplier, then set it through code

    * Create new float parameter
    * Select the blendtree state
    * Check the Parameter checkbox next to multiplier, set it to your new parameter
    * To Set the multiplier in code -> Animator.SetFloat("myNewParameterName", 2f);

    upload_2021-11-9_11-57-50.png
    upload_2021-11-9_11-55-49.png
     
  3. KarlKarl2000

    KarlKarl2000

    Joined:
    Jan 25, 2016
    Posts:
    606
    Thank you! That did it
     
    h765643729 and Sudopia_Games like this.