diff options
author | nirav <nirav@airmail.cc> | 2020-12-12 07:18:36 +0000 |
---|---|---|
committer | nirav <nirav@airmail.cc> | 2020-12-12 07:18:36 +0000 |
commit | 115f77bda0246a00f6e17469685c67746bdbd29d (patch) | |
tree | 4bbea1e59109bb1d1fddc71736f89289bab03073 /Assets/Scripts/Player/PlayerShootingScript.cs | |
download | 01-master.tar.gz 01-master.zip |
Diffstat (limited to 'Assets/Scripts/Player/PlayerShootingScript.cs')
-rwxr-xr-x | Assets/Scripts/Player/PlayerShootingScript.cs | 33 |
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; + } + } +} |