So I’ve gotten as far as adding the broadcast message to fire the recalculate path method once placing down a tower.
When I pass true into the NotifyReceivers parameter it works but obviously the enemies will reset back to the start coordinate
{
BroadcastMessage("RecalculatePath", true, SendMessageOptions.DontRequireReceiver);
}
}
When i use …
{
BroadcastMessage("RecalculatePath", false, SendMessageOptions.DontRequireReceiver);
}
}
When placing my tower the game will hang and I have to close it and reopen which looks to me like an infinite loop.
I’ve debugged enough to find that once the path is recalculated, the path.Count keeps going up and never stops which led me to believe there was an issue with this code block
{
List<Node> path = new List<Node>();
Node currentNode = destinationNode;
path.Add(currentNode);
currentNode.isPath = true;
//go back through the nodes and add them to the path
while (currentNode.connectedTo != null)
{
currentNode = currentNode.connectedTo;
path.Add(currentNode);
currentNode.isPath = true;
Debug.Log(path.Count);
}
path.Reverse();
return path;
}
But to me, everything here matches with the rest of the lecture changes?
Once I remove the Broadcast message all is fine but the enemies won’t recalculate their path on tower placement.
Here is my Repo & branch im working on for reference https://github.com/cozrodgers/TowerDefenseV2/tree/feature/improving-the-path
I would very much appreciate the help!
Thanks