Hello,
I have a gun script. There is a function that is not being called, even though I am calling the method. Here is my code:
using System.Collections;
using UnityEngine;
public class Gun : MonoBehaviour {
public int clipAmmo = 30;
private int ammo;
public int playerAmmo = 270;
public float rateOfFire = 1;
bool canFire = true;
public bool isFullyAutomatic = true;
void Start () {
ammo = clipAmmo;
}
void Update () {
if (isFullyAutomatic)
{
if (Input.GetButton("Fire1"))
{
if (canFire)
{
canFire = false;
Shoot();
}
}
}
}
IEnumerator Shoot()
{
Debug.Log("PEW");
yield return new WaitForSeconds(rateOfFire);
canFire = true;
}
}
Why is it not being called?