A bit confused about Freezing Rotation Logic

Hi guys i think if we put the

rigidbody.freezeRotation = false

it will not freeze all the axis (x,y, and z) right? but we need to freeze only the x and y axis. I got Z axis rotated if do rigidbody.freezeRotation = false.
So i put this code instead

private void Rotating() {
        if (!Input.GetKey(KeyCode.D) && Input.GetKey(KeyCode.A)) {
            rigidbody.freezeRotation = true;
            transform.Rotate(Vector3.forward);
        }
        if (!Input.GetKey(KeyCode.A) && Input.GetKey(KeyCode.D)) {
            rigidbody.freezeRotation = true;
            transform.Rotate(-Vector3.forward);
        }
        rigidbody.constraints = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY;
    }

i actually didnt know what Bitwise operator is doing, but i found this way on this

By the way this is my result

1 Like

Hi,

It’s no surprise that you are confused about the freezing rotation logic because Ben’s idea doesn’t work anyway. He replaces the current “solution” with an actual solution at the end of lecture “Spit & Polish” (currently #72).

If your solution works as well, that’s great. :slight_smile:

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms