My character seems to flip on certain areas

Video showing the problem:

Code for moving:

movementInputDirection = Input.GetAxisRaw("Horizontal");

Code for flipping:

private void Flip()
    {
        isFacingRight = !isFacingRight;
        transform.Rotate(0f, 180f, 0f);
    }

He rotates normally. When I press to go left he will rotate for 180 and when I press to go right he will rotate to 0. When I’m moving and this happens with a head he doesn’t change his rotation.

Hi janjicm,

More code is needed to find the problem. For example the code around where you call the Flip function.

The movie shows a character walking to the right. During this movement it seems to be vibrating the whole time, as if constantly flipping, is this desired?

No it’s not, in unity it doesn’t look that bad but when you build it it’s very noticeable. That vibrating is problem I guess, it looks like it’s flipping

Here is code where I call Flip

 private void CheckMovementDirection()
    {

        if(isFacingRight && movementInputDirection < 0)
        {
            Flip();
        }
        else if(!isFacingRight && movementInputDirection > 0)
        {
            Flip();
        }

More code is needed. But maybe you can try:

if(isFacingRight && movementInputDirection < -0.01f)
{
    Flip();
}
else if(!isFacingRight && movementInputDirection > 0.01f)
{
    Flip();
}

still same, I mean I can give you my whole code but you are wasting your time

try to change transform rotate to

transform.localScale *= new vector3(-1,0,0);