Could someone help me why my transform.Rotate isn't working as I expect

In my platform game there are 2 arrows that change the character’s gravity. When the gravity is changed, I wanted that when the gravity was negative (upwards) the character would have a 180 degree rotation, which is working perfectly. The problem is when there is an interaction with the arrow that changes the gravity to normal, because the character simply does not rotate to 0 degrees as in the beginning.

The “PlayerController” script has a function that does those things:

public void GravityChange(bool up)
    {
        if (up == true)
        {
            transform.Rotate(0, 0, 180);
            rb.gravityScale = -4;
            normalGravity = false;
        }
        else if (up == false)
        {
            transform.Rotate(0, 0, 0);
            rb.gravityScale = 4;
            normalGravity = true;
        }
    }

As the severity was changed to normal, then “rb.gravityScale = 4;” was called and then that whole block must have been too. However, it seems that the rotation did not occur.

Can anyone help me solve this?




5538751--569731--upload_2020-3-1_15-23-5.png

Ok, nevermind. I just realized that I could use transform.eulerAngles to do this correctly and that’s working fine right now.