How can I change this script for rotations?

How can I change the script below to work with rotations? I want to use the same technique to lock the rigidbody’s rotations.

var xMotion : boolean = true;
var yMotion : boolean = true;
var zMotion : boolean = true;

@script AddComponentMenu("Physics/Constrain Motion")
function FixedUpdate () {
	var relativeSpeed : Vector3 = transform.InverseTransformDirection (rigidbody.velocity);
	
	if (!xMotion)
		relativeSpeed.x = 0;
	if (!yMotion)
		relativeSpeed.y = 0;
	if (!zMotion)
		relativeSpeed.z = 0;
		
	rigidbody.AddRelativeForce (-relativeSpeed, ForceMode.VelocityChange);
}

Thanks for any help!

Hi!
conceptually what would you do?

in order to make it not rotate you would neet to add torque to the rigidbody to counteract any torques or rotations present. So instead of using
AddRelativeForce maybe addTorque?

on a side note, we have got good results from using a configurable joint to do the job.

Hello!
Well I would just lock the Y and Z rotations so that my vehicle only rotates on the X axis. Would I only have to change “AddRelativeForce” to “AddRelativeTorque”? Do I still calculate the relativeSpeed var the same way?

Do configurable joint work on iPhone?
Thanks!