I've got a space ship and I'm going for a starfox type look, so that when you move left or right it leans one way or the other. This is what I have to so far
var speed : float = 20.0;
var rotatespeed : float = 10.0;
var target : Transform;
function Update () {
var controller : CharacterController = GetComponent(CharacterController);
//you can go up or down
transform.Translate(Input.GetAxis("Horizontal") *Time.deltaTime * speed, -Input.GetAxis("Vertical") * Time.deltaTime * 0, 0);
//always moving forward
transform.Translate(0,0,1 * Time.deltaTime);
//lean left right, up down
transform.Rotate(0, Input.GetAxis ("Horizontal") * 20*Time.deltaTime, 0);
transform.Rotate(Input.GetAxis ("Vertical") * 30 * Time.deltaTime, 0,0);
}
I'm okay with it continually rotating left and right so they can turn I think, but if you hold up or down the ship just continues to rotate all the way around (lol) I was thinking about using an if statement to tell it to stop at a certain degree but Im not sure how to go about that, If(rotateamount = this much) stop rotating; ???