I have been working on creating a script that rotates a object using the mouse along it’s y and x axis but i want it’s z axis to return to zero after turning, does any one have any suggestions.
this is what i have so far.
#pragma strict
var xspeed = 4.0;
var yspeed = 4.0;
//var zspeed = 4.0;
function FixedUpdate ()
{
//Ignore this stuff it was leftovers from my earlier attempts//
// var z : float;
// if(transform.eulerAngles.z > 0.5f)
// {
// z = -zspeed;
// }
// if(transform.eulerAngles.z < -0.5f)
// {
// z = zspeed;
// }
var x = xspeed * Input.GetAxis("Mouse Y");
var y = yspeed * Input.GetAxis("Mouse X");
rigidbody.AddTorque(x, y, z);
// Debug.Log(z);
}