Hi, everyone, I am attempting to make an airplane game that when the player is not pressing the W, S, A and D keys, it slowly rotates back to 0, 0, 0. However, I'm not quite sure how to do this. All help would be appreciated. Here is my code so far:
// move speed
var Speed : float;
//transform vector
private var tv : Vector3 = Vector3.zero;
//rotation vector
private var rv : Vector3 = Vector3.zero;
function Update ()
{
HandleMovement();
//here is where the rotation part will go
}
function HandleMovement()
{
//up & down
var ud : float = Input.GetAxis("Vertical") * Speed;
//left & right
var lr : float = Input.GetAxis("Horizontal") * Speed;
tv = Vector3(lr, ud, Speed);
rv = Vector3(ud, lr, lr);
transform.Translate(tv * Time.deltaTime);
transform.Rotate(rv * Time.deltaTime);
}