Find rotation direction

Hi folks!

I’m gonna a little crazy with this :)…

http://imageshack.us/photo/my-images/560/howtoi.jpg/

I’ve a wheel and a platform, when I rotate the wheel clockwise I want my platform moving down, and when I rotate the wheel counterclockwise I want my platform goin up.

Now I’m able to only move the platform up with this code

var wheel : Transform;

function Update () {

wheelRotation = wheel.rigidbody.angularVelocity.magnitude;
transform.Translate (Vector3.up * wheelRotation * 0.005);

}

What I need is to know what is the wheel rotation direction as a negative and positive value, and then multiply it to the translate function.

Thanks a lot :slight_smile:

If you want to incrementally determine rotation in relation to some past rotation you will need to potentially store the wheels rotation periodically, possibly once a frame. You could get the axis you care about from rotation.eulerangles and store that down then compare it every frame maybe to determine if something has moved it clockwise or counterclockwise… angles are between 0 and 359. Then use that information to set wheelRotation to -1, 0 or 1. You could use just the Quaternions to determine this too but the angles might be easier for you to work with.