Problem with facing left when going left and facing right when going right (3D)

When I use the attached code, the character rotates again, even though they are already facing right (i.e. ‘facingLeft=false’). This means, that they are constantly rotating when moving right.

If I move left when the character is facing right, the character doesn’t rotate either.

I’m fairly new to all this, so I’m guessing it’s something really simple, but I can’t work it out!

Thanks in advance for any help with this.

[120901-textfile1.txt|120901]

@sandersonphil,

In your code this:

        if (facingLeft = false)
        {
            Debug.Log("Turning Left");
            rotateMove(-180);
            facingLeft = true;
        }

Should be issuing a warning, because with a single ‘=’, this is an assignment.

What you need to test for equality is the double ‘==’, with

        if (facingLeft == false)
        {
            Debug.Log("Turning Left");
            rotateMove(-180);
            facingLeft = true;
        }