- Home /
 
               Question by 
               DariusdXm · Mar 26 at 12:59 AM · 
                animationanimatoranimator controllerblend tree  
              
 
              Velocity not changing value in Blend Tree
So I have this blend tree with a Walking and Jogging animation. 
I wrote a code so the velocity increases when "w" is pressed and decreases when released. The velocity increases and decreases on the script (I serialized field to check), but the Velocity on the animator does not change its value. How do i fix this? Here is the code and another photo.
 ![public class AnimationStateController : MonoBehaviour
 {
     public Animator animator;
     [SerializeField]
     float Velocity = 0.0f;
     public float acceleration = 0.1f;
     public float deceleration = 0.5f;
     int VelocityHash;
     
     // Start is called before the first frame update
     void Start()
     {
         //set reference for animator
         animator = gameObject.GetComponent<Animator>();
     }
 
     // Update is called once per frame
     void Update()
     {
         //get key input from player
         bool forwardPressed = Input.GetKey("w");
         bool runPressed = Input.GetKey("left shift");
 
         if (forwardPressed && Velocity < 1.0f)
         {
             Velocity += Time.deltaTime * acceleration;
         }
 
         if (!forwardPressed && Velocity > 0.0f)
         {
             Velocity -= Time.deltaTime * deceleration;
         }
 
         if (!forwardPressed && Velocity < 0.0f)
         {
             Velocity = 0.0f;
         }
         
         animator.SetFloat(VelocityHash, Velocity);
     }
 }
[2]: /storage/temp/194456-animation-script.png
 
                 
                blend-tree.png 
                (23.5 kB) 
               
 
                
                 
                animation-script.png 
                (8.5 kB) 
               
 
              
               Comment
              
 
               
              Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
               
 
			 
                