Freezing Rotation

Hey all,

I can’t seem to get freezing rotation to work. I have a sphere with a rigidbody on it, and I have pressed the ‘freeze rotation - z’ checkbox on it.

I want the sphere to be able to rotate in y for changing direction (I rotate it around the global up axis) and rotate along its own x (around axis transform.right) to roll forward. I don’t want it to rotate along z, because then the transform.right axis moves and rolling forward no longer works properly.

However, when I run my script, it seems like rotation along z is still happening without any change. Can anyone help me figure out why? Here is my control code:

	void FixedUpdate () {
		
		//SPHERE MOVEMENT
		float hor = Input.GetAxis("Horizontal");
		float ver = Input.GetAxis("Vertical");
		
		//turning
		if (Mathf.Abs(hor) > deadZone) {
			rigidbody.AddTorque (Vector3.up * hor);	
		}
		
		//forward
		if (Mathf.Abs(ver) > deadZone) {
			//add torque around right-hand axis
			rigidbody.AddTorque(transform.right.normalized * ver);			
		}

Ah, I think I see the problem (although not the solution). I think freezing the x or z rotations freezes them in world-space, rather than local? Is that possible? The behavior seems to be that I can only roll forward (ie, rotate around the ‘transform.right’ axis) when I’m facing the appropriate direction, but not if I’m facing 90-degrees in another direction around the global up axis.

Can I get it to freeze only the local x, y, or z, instead of global?

Up