script
var movespeed = 0;
var turn = 0;
var noseup = 0;
var F22Model : GameObject;
var explosion : GameObject;
var crashed = 1;
var maxspeed = 600;
var abletomove = 1;
var eject = 0;
var stopeject = 0;
var gravity = 1;
function Start() {
movespeed = 550;
}
function Update () {
var lift = movespeed * 0.5;
transform.Translate(Vector3.right * Time.deltaTime * movespeed);
transform.Rotate(Vector3.left * Time.deltaTime * turn);
transform.Translate(Vector3.up * Time.deltaTime * lift);
transform.Rotate(Vector3.forward * Time.deltaTime * noseup);
transform.Translate(Vector3.up * Time.deltaTime * eject);
transform.Translate(Vector3.down * gravity);
stopeject += eject;
if (Input.GetKey("up"))
if (abletomove == 1)
movespeed += 1;
if (Input.GetKey("down"))
if (abletomove == 1)
movespeed -= 0.01;
if (Input.GetKey("a"))
if (abletomove == 1)
turn -= 15;
if (Input.GetKey("d"))
if (abletomove == 1)
turn += 15;
if (turn <= 0)
turn += 5;
if (turn >= 0)
turn -= 5;
if (turn >= 360){
turn = 360;
}
if (turn <= -360){
turn = -360;
}
if (noseup <= 0)
noseup += 5;
if (noseup >= 0)
noseup -= 5;
if (Input.GetKey("s"))
if (abletomove == 1)
noseup += 10;
if (Input.GetKey("w"))
if (abletomove == 1)
noseup -= 10;
if (movespeed >= maxspeed){
movespeed = maxspeed;
}
if(stopeject >= 300){
eject = 0;
}
}
function OnCollisionEnter(thing : Collision) {
if (thing.collider.tag == "Terrain") {
if (crashed == 1) {
Destroy (F22Model);
Instantiate (explosion, transform.position, transform.rotation);
crashed = 0;
movespeed = 0;
eject = 20;
stopeject += eject;
turn = 0;
noseup = 0;
maxspeed = 0;
abletomove = 0;
transform.Rotate(Vector3.forward * -90);
}
}
}
function OnGUI () {
GUI.Label (Rect (Screen.width * 0.9, Screen.height * 0.9, 300, 60), movespeed * 2 + " KPH");
GUI.Label (Rect (Screen.width * 0.9, Screen.height * 0.87, 300, 60), Transform.position.y + " Meters");
GUI.HorizontalScrollbar(Rect (20,40,200,20), 0, turn + 360, 20, 720);
}
there is an error at Transform.position.y doen the bottom, does anyone know why?