Advertisement
LittleAngel

Untitled

Sep 27th, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. // Input Math Transform Fire
  2.  
  3. #pragma strict
  4.  
  5. var speed : float;
  6. var tilt : float;
  7. var xMin : float;
  8. var xMax : float;
  9. var zMin : float;
  10. var zMax : float;
  11.  
  12. var shot : GameObject;
  13. var shotSpawn : Transform;
  14. var fireRate : float;
  15. private var nextFire : float;
  16.  
  17. function Awake () {
  18. nextFire = 0.0;
  19. }
  20.  
  21. function Update () {
  22. var moveHorizontal = Input.GetAxis ("Horizontal") * speed * Time.deltaTime;
  23. var moveVertical = Input.GetAxis ("Vertical") * speed * Time.deltaTime;
  24.  
  25. var movement = Vector3 (moveHorizontal, 0.0, moveVertical);
  26. transform.Translate (movement, Space.World);
  27.  
  28. transform.position.x = Mathf.Clamp (transform.position.x, xMin, xMax);
  29. transform.position.z = Mathf.Clamp (transform.position.z, zMin, zMax);
  30.  
  31. transform.eulerAngles.z = -Input.GetAxis ("Horizontal") * tilt;
  32.  
  33. if (Input.GetButton ("Fire1") && Time.time > nextFire) {
  34. nextFire = Time.time + fireRate;
  35. // var clone : GameObject =
  36. Instantiate(shot, shotSpawn.position, shotSpawn.rotation); // as GameObject;
  37. }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement