Advertisement
Guest User

Untitled

a guest
Jan 27th, 2015
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. public Rotation bodyRotation = null;
  2.  
  3. public float rotationSpeed = 1;
  4. public GameObject projectilePrefab = null;
  5.  
  6. public Transform spawner;
  7.  
  8. void Update () {
  9. CheckInput ();
  10. }
  11.  
  12. private void CheckInput()
  13. {
  14. RotateBodyInput ();
  15. Fire ();
  16. }
  17.  
  18. private void Fire()
  19. {
  20. if(Input.GetKeyDown(KeyCode.Space))
  21. {
  22. GameObject projectile = Instantiate (this.projectilePrefab) as GameObject;
  23. projectile.transform.position = this.spawner.position;
  24. projectile.transform.eulerAngles = this.spawner.eulerAngles;
  25. }
  26. }
  27.  
  28. private void RotateBodyInput()
  29. {
  30. if (Input.GetKey(KeyCode.RightArrow))
  31. {
  32. this.bodyRotation.Rotate(this.rotationSpeed);
  33. }
  34. if (Input.GetKey(KeyCode.LeftArrow))
  35. {
  36. this.bodyRotation.Rotate(-this.rotationSpeed);
  37. }
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement