I have now completely copied the script from GitLab and they still don’t work, I am getting these errors (in order of how they appeared in the console):
KeyNotFoundException: The given key was not present in the dictionary.
System.Collections.Generic.Dictionary`2[TKey,TValue].get_Item (TKey key) (at <695d1cc93cca45069c528c15c9fdd749>:0)
Pathfinder.Awake () (at Assets/Pathfinding/Pathfinder.cs:31)
NullReferenceException: Object reference not set to an instance of an object
Pathfinder.BreadthFirstSearch () (at Assets/Pathfinding/Pathfinder.cs:75)
Pathfinder.GetNewPath () (at Assets/Pathfinding/Pathfinder.cs:43)
EnemyMover.FindPath () (at Assets/Enemy/EnemyMover.cs:33)
EnemyMover.OnEnable () (at Assets/Enemy/EnemyMover.cs:18)
UnityEngine.Object:Instantiate(GameObject, Transform)
ObjectPool:PopulatePool(GameObject) (at Assets/Enemy/ObjectPool.cs:29)
ObjectPool:Awake() (at Assets/Enemy/ObjectPool.cs:14)
(This second one appeared multiple times)
I also can’t place towers, however when I click the block becomes not walkable, noted by the colour change of the coordinate label.
Could you please upload your project to GitHub without the Temp and Library folder and share a link to the public repository here? I’d like to take a look into this.
Thank you. I’ve downloaded and tested your project in Unity 2021.1.4f1. When I “played” the game scene, the first thing I noticed/heard is my GPU singing. This indicates that there might be a huge problem in your game. Did you do anything special in your game, for example, with shaders? Or did you change the quality settings?
The second thing I noticed was that no enemies got spawned. When I placed the tower, I got this error message:
Unfortunately, I was not able to recreate any of the problems you got. Maybe I did something wrong. Would you mind telling me what I am supposed to do to get the same results as you?
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.
I pushed my changes, however adding the waypoint script did nothing for me and also I have now found that it should not still be in the game at this point. I have tried to delete it however that has not seemed to have worked. I will try to get all the scripts copied across and then push again.
In the Awake method, the Pathfinder object should get assigned to pathfinder:
pathfinder = FindObjectOfType<Pathfinder>();
I was not able to find a Pathfinder component anywhere in the scene. And the EnemyMover object didn’t find any either, hence the NullReferenceException. Gary attached the Pathfinder component to the ObjectPool game object.
Edit: Thanks for reopening the thread
Original reply:
Sorry it’s been a busy few days. Hmmm, it’s strange that there was no pathfinder script on the ObjectPool object. I’ve attached it however I still get the same errors.
Maybe it is a good idea to rewatch the videos. There are too many things missing here and there, and it is probably way faster to simply comparing your project to Gary’s while rewatching the videos instead of individually tracking each single error and fixing it when new errors are expected to pop up whenever you solve a problem.