- Home /
 
My animation and player movement are messing with each other
So this is the code of a simple Character to move and jump
Blockquote
 void Update()
 {
     //move left and right
     playerRB.velocity = new Vector2(Input.GetAxisRaw("Horizontal") * moveSpeed, playerRB.velocity.y);
     //face left and right (this is the part i'm having touble with)
    if (Input.GetAxisRaw("Horizontal") != 0)
         {
         transform.localScale = new Vector2(Input.GetAxisRaw("Horizontal") * transform.localScale.x, transform.localScale.y);
         }
     //jump
     if (Input.GetButtonDown("Jump"))
         {
             playerRB.velocity = new Vector2(playerRB.velocity.y, jumpForce);
             playerAnimator.Play("Jump");
         }
 }
 
               So my problem is that, my character has an animation where it streches whenever i jump. So, in the animation, I change the localScale from x=0.6 and y=0.6 to x=0.4 and y=0.8 to make the stretch animation. But as you can see in the code (the "face left and right" part), there I also change the localScale from x=0.6 and y=0.6 to x= -0.6 and y= -0.6. Because of this, this problem happens with the way the cube is facing: https://drive.google.com/file/d/1321yKOit1CEORmpQJtuE5Oz9_GFpver6/view?usp=sharing
Is it possible to make the animation also change values from x=0.4 and y=0.8 to x= -0.4 and x= -0.8? Anything you want me to explain better, just ask me.
Your answer
 
             Follow this Question
Related Questions
Animation causes rigidbody to move 0 Answers
How do you move a character with physics when using Animator.setInteger to play the animations? 0 Answers
i have a problem with Movement i need help 0 Answers
Need help with wall cover system(splinter cell like) 0 Answers
Problems with animation and movement 1 Answer