Hey,
Im using Unity 2.6x, and Im having a bit of trouble with this script:
var speed: float = 5;
var rotateSpeed : int = 3;
function Start()
{
rigidbody.AddRelativeForce(Vector3.right * speed);}
function Update()
{
if(Input.GetKey (KeyCode.G))
{
transform.Rotate(Vector3.right, rotateSpeed*Time.deltaTime);
}
if(Input.GetKey (KeyCode.T))
{
transform.Rotate(Vector3.right, - rotateSpeed*Time.deltaTime);
}
if(Input.GetKey (KeyCode.F))
{
transform.Rotate(Vector3.up, - rotateSpeed*Time.deltaTime);
}
if(Input.GetKey (KeyCode.H))
{
transform.Rotate(Vector3.up, rotateSpeed*Time.deltaTime);
}
}
The idea is that you are in an airship, and you press the keys to change the rotation of the ship, with a constant speed pushing in one direction RELATIVE to the rotation (i.e if i rotate it 180 degrees, the force will be pushing in the opposite direction). The problem is that it pushes on the global axis, no matter what I change. What am I doing wrong?