#Issue with enemy fire

1 messages · Page 1 of 1 (latest)

winged moth
#

Got this strange problem I'm trying to fix, enemies don't seem to be firing like they should be, projectiles appear immediately below the group, and the enemy group never seems to fire again, all this being said prior to this issue I had some code typed put which would've made the firing more random, now it doesn't seem they are consistently firing.

swift rampart
#

You have to post the code

#

!code

old hingeBOT
winged moth
swift rampart
#

Where's the code?

winged moth
#

public float minFireDelay = 0.5f;
public float maxFireDelay = 1.5f;

private float nextFireTime;

void Start()
{
    Debug.Log(gameObject.name + " EnemyShoot STARTED");

    if (bulletPrefab == null)
    {
        Debug.LogError("Bullet Prefab NOT assigned on " + gameObject.name);
    }

    if (firePoint == null)
    {
        Debug.LogError("FirePoint NOT assigned on " + gameObject.name);
    }

    nextFireTime = Time.time + Random.Range(minFireDelay, maxFireDelay);

    Debug.Log(gameObject.name + " first shot scheduled at: " + nextFireTime);
}

void Update()
{
    if (Time.time >= nextFireTime)
    {
        Debug.Log(gameObject.name + " FIRED at time: " + Time.time);

        Shoot();

        nextFireTime = Time.time + Random.Range(minFireDelay, maxFireDelay);

        Debug.Log(gameObject.name + " next shot scheduled at: " + nextFireTime);
    }
}

void Shoot()
{
    if (bulletPrefab == null || firePoint == null)
    {
        Debug.LogError("Cannot shoot — missing references on " + gameObject.name);
        return;
    }

    Instantiate(bulletPrefab, firePoint.position, Quaternion.identity);
}

}

#

theres my enemy shoot code

proven herald
tight ridge
#

If this has yet to be resolved, the issue should be in your inspector. The value of maxFireDelay is set to 0 on your EnemyShoot script