UnassignedReferenceException: The variable pathPrefab of WaveConfig has not been assigned.
You probably need to assign the pathPrefab variable of the WaveConfig script in the inspector.
WaveConfig.GetWaypoints () (at Assets/Scripts/WaveConfig.cs:20)
EnemySpawner+d__3.MoveNext () (at Assets/Scripts/EnemySpawner.cs:20)
UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <4a31731933e0419ca5a995305014ad37>:0)
UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator)
EnemySpawner:Start() (at Assets/Scripts/EnemySpawner.cs:13)
the enemy prefab is stacking and dont know what’s going on
PS Im new thanks!
here is my code
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnemySpawner : MonoBehaviour
{
[SerializeField] List waveConfigs;
int startingWave = 0;
// Use this for initialization
void Start()
{
var currentWave = waveConfigs[startingWave];
StartCoroutine(SpawnAllEnemiesInWave(currentWave));
}
private IEnumerator SpawnAllEnemiesInWave(WaveConfig waveConfig)
{
for (int enemyCount = 0; enemyCount < waveConfig.GetNumberOfEnemies(); enemyCount++)
{
var newEnemy = Instantiate(
waveConfig.GetEnemyPrefab(),
waveConfig.GetWaypoints()[0].transform.position,
Quaternion.identity);
newEnemy.GetComponent<EnemyPathing>().SetWaveConfig(waveConfig);
yield return new WaitForSeconds(waveConfig.GetTimeBetweenSpawns());
}
}
}