Unfortunately not. That’s why I asked. ![:confused: :confused:](https://community.gamedev.tv/images/emoji/twitter/confused.png?v=9)
No enemies got spawned in my case. That’s probably the reason why I didn’t get the NullReferenceException and the KeyNotFoundException.
Updated Sun Apr 25 2021 16:08
I have investigated the problem a bit further. The pool size of the ObjectPool component of the ObjectPool game object was 0, so I set it to 1.
![image](https://community.gamedev.tv/uploads/db2322/original/3X/3/5/35fc2f60a1d9a6cdafebb69102cd34a382a0cd9f.png)
Now I’m getting two error messages:
Then I checked the script execution order. There is no ObjectPool or GridManager object in the list.
![image](https://community.gamedev.tv/uploads/db2322/original/3X/1/b/1bf7b346080e868772e895901f9cab1713e39d8b.png)
I added GridManager and ObjectPool to the list.
![image](https://community.gamedev.tv/uploads/db2322/original/3X/a/9/a9b0d3d199b6b4cd14540eb6f5d2ddf9b582dab0.png)
A Debug.Log in the EnemyMover revealed that the List object existed, but the List object did not contain any elements.
private void ReturnToStart()
{
Debug.Log("path: " + path);
Debug.Log("path.Count: " + path.Count);
transform.position = path[0].transform.position;
}
I checked where elements get added to the list.
foreach (Transform child in parent.transform)
{
Waypoint waypoint = child.GetComponent<Waypoint >();
if (waypoint != null)
{
path.Add(waypoint);
}
}
According to this piece of code, the child gets added only if a Waypoint component is attached to it. There is no Waypoint component attached to any of the children of the Path game object.
![image](https://community.gamedev.tv/uploads/db2322/original/3X/2/7/273e17fb2bddfc8d2b952add302d1cdd08ade70a.png)
After I had added the Waypoint component, the enemy started to move, and no errors got thrown anymore.