How to check the value of angular velocity?

I’m trying to make an airplane/spaceship do a barrel roll, then stop, using AddRelativeTorque (pitch and yaw too, but let’s focus on roll for now). I know I could use angular drag, but I would rather create a script for it. I found a script another poster made, and pulled some bits out that I could use, but I’ve run into a problem.

I can’t work out how to check the angular velocity of the vehicle’s rigidbody, so that the script knows when to apply counter-torque. My current solution (below) gives an error on the “else if” line, and I don’t know how to fix it.

public float pitchFactor;
public float rollFactor;
public float yawFactor;
public Rigidbody controlledShip;

void FixedUpdate ()
	float horizontal, vertical;
	horizontal = Input.GetAxis ("Horizontal");
	vertical = Input.GetAxis ("Vertical");
	Vector3 localAngleVelo = controlledShip.transform.InverseTransformVector (controlledShip.GetComponent<Rigidbody> ().angularVelocity);
	if (horizontal != 0f) {
		controlledShip.AddRelativeTorque (Vector3.forward * (horizontal * (rollFactor * Time.deltaTime)));
	} else if (localAngleVelo.forward > 0.0) {
		controlledShip.AddRelativeTorque (Vector3.forward * (rollFactor * Time.deltaTime));

Any solutions?

Your “localAngleVelo” is already a vector. So “forward” doesn’t make much sense. What you probably want is “localAngleVelo.z” which gives you the amount of angular velocity around the local forward axis.

I figured that out for myself a few hours after posting this question, but thank you for the answer all the same.