Hi everyone!
I have problem with flipping my character, flip is working fine but it changes player position all the time. I’m gonna show you in pics what this does look like.
This is default stance:
If I press right arrow key he will go back to his default stance. Also I observed that when I switch the x all of transform positions stays the same. Any help?
Code I use for moving a player and to flip him:
void Update()
{
movex = Input.GetAxis("Horizontal");
anim.SetFloat("Speed", Mathf.Abs(movex));
rb.velocity = new Vector2(movex * SpeedPlayer, 0f);
if (movex > 0 && !facingRight)
{
Flip();
}
else if (movex < 0 && facingRight)
{
Flip();
}
}
void Flip()
{
facingRight = !facingRight;
Vector3 theScale = transform.localScale;
theScale.x *= -1;
transform.localScale = theScale;
}