I want it to work so that if the player reaches the startzone or is past it spawn one minion then stop
checking if the player is in the startZone or not.
it’s not doing that it’s spawns as many minions as it can if I am in the area or past the start of it.
using UnityEngine;
public class Flying2EyeEnemy : MonoBehaviour
{
public Transform startZone;
public GameObject minions;
public Transform minionSpawn;
public Transform player;
public bool spawnMinions;
void Start()
{
}
void Update()
{
if (player.position.x >= startZone.position.x)
{
spawnMinions = true;
if (spawnMinions)
{
SpawnMinion();
}
else
{
spawnMinions = false;
}
}
}
void SpawnMinion()
{
Instantiate(minions, minionSpawn.position, minionSpawn.rotation);
}
}