Path being created before isWalkable updated

Hi. So i was wondering if anyones had this problem.
I’m on “Blocking Nodes” in the Realm rush section.
I’ve spent ages over this and finally narrowed down my issue.
When my path is being generated, it seems to be ignoring blocked tiles. I ran debugs and list things out, and finally traced it down that the BreadthFirstSearch() and ExploreNeighbours() and BuildPath() functions were all being run, before the Tile script can go through and check to see if the tiles are blocked and update the Grid dictionary.
Initially i tried called BuildPath() later, but the damage was already done, as all the tiles in the dictionary had their “connectedTo” neighbour nodes linked up already (which is how the Path() function connects them up).
My proof and short term solution was to delay the start of Those functions by 2-3 seconds (through invoke) and then everything worked fine, blocked tiles were recognised through isWalkable/isPlaceable being known, and thus nodes were given the right isConnected nodes for the path to be created.

Now i’m sure there’s a number of complex solutions for this,… but i’ve checked with the courses Git files, and i’m running these all in the right Awake() and Start() places. It seems odd that i’m getting this issue, and the instructor not.
So wondering if it’s just me, or if anyone else suffered this. And also wondering if anyones got any tips or ideas for solving this (beyond using Invoke, to delay the searching and Path finding).
I imagine this is less of an issue soon, as the enemies will be finding their path later then the game being created,…

7 Likes

And the answer is the “script Execution Order” that’s taught a few lectures later.
He has a different problem, but by doing this method, all the issues i had are resolved to, and essentially i have to accept, i was just “unlucky” in how my scripts have decided to order themselves.

7 Likes

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms