// Update is called once per frame void FixedUpdate() { if (!enemyEntity.IsEnemyDying()) { // always check if the player is within range CheckIfPlayerWithinRange(); for (int i = 0; i < enemyMissiles.Length; i++) { //if (!enemyMissiles[i].HasAmmo()) //{ // enemyMissiles[i].SetReloading(true); //} if (enemyMissiles[i].isReloading()) { ReloadGun(i); } } if (playerWithinRange && !enemyMissiles[GetGunIndexFromPosition()].isReloading()) { timeSinceShot = 0.0f; //Debug.Log($"Aiming and shooting"); // do not shoot if player dead if (player.health > 0) { AimGunAtPlayer(); Shoot(); enemyMissiles[GetGunIndexFromPosition()].SetReloading(true); } } } }
// Update is called once per frame void Update() { if (!enemyEntity.IsEnemyDying()) { // always check if the player is within range CheckIfPlayerWithinRange(); for (int i = 0; i < enemyGuns.Length; i++) { if (!enemyGuns[i].HasAmmo()) { enemyGuns[i].SetReloading(true); } if (enemyGuns[i].isReloading()) { ReloadGun(i); } } if (playerWithinRange && !enemyGuns[GetGunIndexFromPosition()].isReloading()) { if (timeSinceShot >= timeBetweenShots) { //Debug.Log($"Aiming and shooting"); AimGunAtPlayer(); Shoot(); timeSinceShot = 0.0f; } else { timeSinceShot += Time.deltaTime; } } } }