Advertisement
MrFastDie

Untitled

Dec 7th, 2016
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class PlayerShooting : MonoBehaviour {
  5.  
  6.     public GameObject bulletPrefab;
  7.  
  8.     public float fireDelay = 0.25f;
  9.     public  float cooldownTimer = 0f;
  10.  
  11.     void Update () {
  12.         cooldownTimer -= Time.deltaTime;
  13.         if (gameObject.tag == "Player1" && RandomKeys.player1trigger) {
  14.             RandomKeys.player1trigger = false;
  15.             //shoot
  16.             cooldownTimer = fireDelay;
  17.  
  18.  
  19.             Vector3 offset = transform.rotation * new Vector3(0, 0.7f, 0);
  20.  
  21.             Instantiate(bulletPrefab, transform.position + offset, transform.rotation);
  22.  
  23.         } else if (gameObject.tag == "Player2" && RandomKeys.player2trigger) {
  24.             RandomKeys.player2trigger = false;
  25.             //shoot
  26.             cooldownTimer = fireDelay;
  27.  
  28.  
  29.             Vector3 offset = transform.rotation * new Vector3(0, 0.7f, 0);
  30.  
  31.             Instantiate(bulletPrefab, transform.position + offset, transform.rotation);
  32.  
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement