From 115f77bda0246a00f6e17469685c67746bdbd29d Mon Sep 17 00:00:00 2001 From: nirav Date: Sat, 12 Dec 2020 07:18:36 +0000 Subject: Initial commit --- Assets/Scripts/Player/PlayerShootingScript.cs | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100755 Assets/Scripts/Player/PlayerShootingScript.cs (limited to 'Assets/Scripts/Player/PlayerShootingScript.cs') 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().Play(); + Instantiate(Bullet, gameObject.transform.position, Quaternion.identity); + } + } + fireCounter += Time.deltaTime; + } + } +} -- cgit v1.2.3