- Home /
This post has been wikified, any user with enough reputation can edit it.
Question by
CrilleStyles · Apr 08, 2014 at 02:48 PM ·
vector3.positionvector3 operations
Tilt an object with arrowkeys
Is it possible to tilt my vehicle tilt and then restore the position? This is the code I got so far, try to edit it please. static var selectedId : int; static var speed : int = 90;
function Update () {
if (selectedId==GetInstanceID()) {
if (Input.GetKey (KeyCode.UpArrow)) transform.Translate (Vector3(0,0,1) * Time.deltaTime*speed);
if (Input.GetKey (KeyCode.DownArrow)) transform.Translate (Vector3(0,0,-1) * Time.deltaTime*speed);
if (Input.GetKey (KeyCode.Space)) transform.Translate (Vector3(0,1,0) * Time.deltaTime*speed);
if (Input.GetKey (KeyCode.LeftControl)) transform.Translate (Vector3(0,-1,0) * Time.deltaTime*speed);
if (Input.GetKey(KeyCode.RightArrow))
transform.Rotate(Vector3.up * speed * Time.deltaTime);
if (Input.GetKey(KeyCode.LeftArrow))
transform.Rotate(-Vector3.up * speed * Time.deltaTime);
}
}
function OnMouseDown () {
selectedId = GetInstanceID();
}
Comment