Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice

Resolved How change speed via code in Animation States

Discussion in 'Animation' started by unity_GIq64ygEJl9qYw, Feb 1, 2022.

  1. unity_GIq64ygEJl9qYw

    unity_GIq64ygEJl9qYw

    Joined:
    Apr 21, 2019
    Posts:
    13
    Hi, does anyone know how to change the speed of a Animation State in the code?
    I want get state "walking" and change his speed

    upload_2022-2-1_16-30-58.png
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,583
    You can't change the speed directly, but if you make a float parameter and set it as the speed multiplier (the line below Speed) then you can set that parameter using animator.SetFloat("Parameter Name", value) to control the speed.
     
    unity_GIq64ygEJl9qYw likes this.