Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public Rotation bodyRotation = null;
- public float rotationSpeed = 1;
- public GameObject projectilePrefab = null;
- public Transform spawner;
- void Update () {
- CheckInput ();
- }
- private void CheckInput()
- {
- RotateBodyInput ();
- Fire ();
- }
- private void Fire()
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- GameObject projectile = Instantiate (this.projectilePrefab) as GameObject;
- projectile.transform.position = this.spawner.position;
- projectile.transform.eulerAngles = this.spawner.eulerAngles;
- }
- }
- private void RotateBodyInput()
- {
- if (Input.GetKey(KeyCode.RightArrow))
- {
- this.bodyRotation.Rotate(this.rotationSpeed);
- }
- if (Input.GetKey(KeyCode.LeftArrow))
- {
- this.bodyRotation.Rotate(-this.rotationSpeed);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement