- Home /
How to make animations match movement direction
Sorry if I explain this poorly, I have a character and a Blend tree with animations. The game is a top down shooter and I am having trouble with getting the animations to match the movement direction. The animations work fine when the character is looking forwards but if I turn to the right or left and move the wrong animation is played.
And here is the code
 void Update()
     {
 
 
         MoveDirection.x = MoveJoystick.Horizontal;
         animator.SetFloat(HorizontalAnim, MoveDirection.x );
         MoveDirection.z = MoveJoystick.Vertical;
 
          animator.SetFloat(VerticalAnim, MoveDirection.z  );
 
         
          
 
         
 
        
 
         if (RotateJoystick.Vertical != 0 || RotateJoystick.Horizontal != 0)
         {
             RotDirection.x = RotateJoystick.Horizontal;
             RotDirection.y = RotateJoystick.Vertical;
             
             this.transform.eulerAngles  = new Vector3(0, Mathf.Atan2(RotDirection.x, RotDirection.y) * 180 / Mathf.PI, 0);
            
            
 
         }
         
 
         Controller.SimpleMove(MoveDirection * Speed);
         
     }
Apologies if I explained it poorly.
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
Animation in android game not working 2 Answers
Tank Wheels and Treads 1 Answer
Animations don't work with humanoid avatars 0 Answers
How to add movement to animations? 1 Answer
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                