Fixed enemy spam spawning if single player

This commit is contained in:
BOTAlex 2024-05-26 03:07:59 +02:00
parent c2928c82d5
commit 9017315bfe
1 changed files with 6 additions and 3 deletions

View File

@ -135,7 +135,10 @@ public class EnemySpawner : NetworkBehaviour
GameObject enemy = Instantiate(enemyPrefab, GetRandomPointOnCircle(SpawnRadius), Quaternion.identity, SpawnedEnenmyHolder.transform);
enemy.GetComponent<NetworkObject>().Spawn();
if (players != null)
enemy.GetComponent<EnemyPathFinding>().targets = players.Select(x => x.transform).ToArray();
else
enemy.GetComponent<EnemyPathFinding>().targets = new Transform[] { new GameObject("DummyTarget").transform};
}
// Centrum is SpawnCenter