using System.Collections; using UnityEngine; using UnityEngine.InputSystem; public class GunControl : MonoBehaviour { private InputSystem_Actions controls; [SerializeField] float gunShotDelay = 0.25f; private bool hasGunFired = false; private void Awake() { controls = new InputSystem_Actions(); controls.Player.Attack.started += ctx => StartShot(); controls.Player.Attack.started += ctx => EndShot(); } void Start() { } private void OnEnable() { controls.Enable(); } private void OnDisable() { controls.Disable(); } void StartShot() { if (hasGunFired == false) { StartCoroutine(FireTheGun()); } } void EndShot() { Debug.Log("Shot ended"); //count shots, reload } IEnumerator FireTheGun() { hasGunFired = true; yield return new WaitForSeconds(gunShotDelay); hasGunFired = false; Debug.Log("Shot Fired"); } }