The solution in the lecutre by freezing and unfreezing create another bug that is when we unfreez the rotation, it unfreez all the 3 axis when in fact we want to unfreez only the z axis.
After some research I came up with this solution:
void ApplyRotation(Vector3 rotation)
{
rb.freezeRotation = true;
transform.Rotate(rotation * rotateThrustVelocity * Time.deltaTime);
rb.freezeRotation = false;
rb.constraints =
RigidbodyConstraints.FreezeRotationX |
RigidbodyConstraints.FreezeRotationY |
RigidbodyConstraints.FreezePositionZ;
}
so I just added the last statement which uses the bitwise to combine what we want to freez.
I still don’t understand how does this single pipe works or why it works, if anyone can explain, I would really appreciate it