Last Input not being properly stored
hi there, my current problem is that when I release the horizontal and vertical buttons ( w and a for example) the player stops on the wrong idle animation; I mean, if i don't release both buttons on the exact moment, the followin idle animation will be either the left or up ( horizontal or vertical ones) in place of the diagonal idle animation that was supposed to happen. If someone could help me, I'd really appreciate. There's the code I'm using:
 public float moveSpeed;
 public Rigidbody2D rb;
 private Vector2 moveDirection;
 public Animator animator;
 
 // Update is called once per frame
 void Update()
 {
     ProcessInputs();
     
     animator.SetFloat("Horizontal", moveDirection.x);
     animator.SetFloat("Vertical", moveDirection.y);
     animator.SetFloat("Speed", moveDirection.sqrMagnitude);
     
     if (moveDirection != Vector2.zero)
     {
         animator.SetFloat("HorIdle", moveDirection.x);
         animator.SetFloat("VerIdle", moveDirection.y);
     }
 }
 void FixedUpdate()
 {
     Move();
 }
 void ProcessInputs()
 {
     
     
         float moveX = Input.GetAxisRaw("Horizontal");
         float moveY = Input.GetAxisRaw("Vertical");
         moveDirection = new Vector2(moveX, moveY).normalized;
        
 }
 void Move()
 {
     rb.velocity = new Vector2(moveDirection.x * moveSpeed, moveDirection.y * moveSpeed);
     
 }
 void OnAnimatorMove()
 {
 }
}
Your answer
 
 
             Follow this Question
Related Questions
My animations started acting weirdly 0 Answers
Input problems in Unity 0 Answers
Animator scripting error C# - Only WalkingRight Movement Animates 0 Answers
3rd person controller- anim parameters are not changing when i press stuff 0 Answers
How to change animator states when a key is held through a C# script for a sprite? 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                