Advertisement
iceman140

Unity Avion Script

Jun 24th, 2013
3,376
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Genero 0.69 KB | None | 0 0
  1. var speed=0;
  2. var Torque=10;
  3. var Gravity=100.0;
  4. var acceleration=2;
  5. var maxspeed=1200;
  6. var minspeed=0;
  7. private var SavedGravity=0;
  8. SavedGravity=Gravity;
  9. function Update(){
  10. if(speed >= maxspeed)speed=maxspeed;
  11. if(speed<=minspeed)speed=minspeed;
  12. if(Input.Getkey(KeyCode.W))speed=speed+1*acceleration;
  13. if(Input.GetKey(KeyCode.S))speed=speed-1*acceleration;
  14. ConstantForce.RelativeTorque.y=Input.GetAxis("Yaw")*Torque*2*Time.deltaTime;
  15. ConstantForce.RelativeTorque.x=Input.GetAxis("Vertical")*Torque*Time.deltatime;
  16. ConstantForce.RelativeTorque.z=-Input.GetAxis("Horizontal")*Torque*Time.deltatime;
  17. Gravity=SavedGravity-speed;
  18. ConstantForce.Force.y=-Gravity/100;
  19. if(Gravity<=0)Gravity=0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement