Fixed enemy spam spawning if single player
This commit is contained in:
parent
c2928c82d5
commit
9017315bfe
|
@ -86,7 +86,7 @@ public class EnemySpawner : NetworkBehaviour
|
||||||
|
|
||||||
void SpawnWave(float difficulty)
|
void SpawnWave(float difficulty)
|
||||||
{
|
{
|
||||||
if (enemyList.List.Any(x=>x.Difficulty < 0.1f))
|
if (enemyList.List.Any(x => x.Difficulty < 0.1f))
|
||||||
{
|
{
|
||||||
Debug.LogError("Difficulty on prefab too low!", enemyList);
|
Debug.LogError("Difficulty on prefab too low!", enemyList);
|
||||||
return;
|
return;
|
||||||
|
@ -135,7 +135,10 @@ public class EnemySpawner : NetworkBehaviour
|
||||||
GameObject enemy = Instantiate(enemyPrefab, GetRandomPointOnCircle(SpawnRadius), Quaternion.identity, SpawnedEnenmyHolder.transform);
|
GameObject enemy = Instantiate(enemyPrefab, GetRandomPointOnCircle(SpawnRadius), Quaternion.identity, SpawnedEnenmyHolder.transform);
|
||||||
enemy.GetComponent<NetworkObject>().Spawn();
|
enemy.GetComponent<NetworkObject>().Spawn();
|
||||||
|
|
||||||
|
if (players != null)
|
||||||
enemy.GetComponent<EnemyPathFinding>().targets = players.Select(x => x.transform).ToArray();
|
enemy.GetComponent<EnemyPathFinding>().targets = players.Select(x => x.transform).ToArray();
|
||||||
|
else
|
||||||
|
enemy.GetComponent<EnemyPathFinding>().targets = new Transform[] { new GameObject("DummyTarget").transform};
|
||||||
}
|
}
|
||||||
|
|
||||||
// Centrum is SpawnCenter
|
// Centrum is SpawnCenter
|
||||||
|
|
Loading…
Reference in New Issue