summaryrefslogtreecommitdiff
path: root/Assets/Scripts/Player/PlayerShootingScript.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Assets/Scripts/Player/PlayerShootingScript.cs')
-rwxr-xr-xAssets/Scripts/Player/PlayerShootingScript.cs33
1 files changed, 33 insertions, 0 deletions
diff --git a/Assets/Scripts/Player/PlayerShootingScript.cs b/Assets/Scripts/Player/PlayerShootingScript.cs
new file mode 100755
index 0000000..45c6aca
--- /dev/null
+++ b/Assets/Scripts/Player/PlayerShootingScript.cs
@@ -0,0 +1,33 @@
+using UnityEngine;
+using System.Collections;
+
+public class PlayerShootingScript : MonoBehaviour {
+
+ public bool canShoot;
+ public GameObject Bullet;
+ public float Firerate = 1f;
+ float fireCounter = 0;
+
+ // Use this for initialization
+ void Start () {
+
+ }
+
+ // Update is called once per frame
+ void Update ()
+ {
+ if (canShoot)
+ {
+ if (Input.GetAxis("Fire") == 1)
+ {
+ if (fireCounter > Firerate)
+ {
+ fireCounter = 0;
+ gameObject.GetComponent<AudioSource>().Play();
+ Instantiate(Bullet, gameObject.transform.position, Quaternion.identity);
+ }
+ }
+ fireCounter += Time.deltaTime;
+ }
+ }
+}