Hi All, Hope you're having a great weekend!
For the past week(2 actually) I've been banging my head over getting the car working correctly and I think looking back I was approaching this wrong, its not the car that should be getting the list of positions its able to move to, but there should be a manager (of sorts) that would provide the car with the information that it needs in order to be able to "properly" traverse and *hint hint* find its path.
So, I'll quickly explain a couple things that I tried (encase you're curious to the process, if not, skip this)
I tried to implement a parent/ child relationship between the spawned roads, e.g -> the starting road would essentially build the list of child roads, and then provide that list to the child nodes so they are aware of all the roads in the list this was.. functional but problematic.. if the road was straight :
A ----- B, it worked fine, but then you started to branch out and link roads together, I was having difficulties with getting the roads to successfully traverse the linked road, if could "join" that road, but it couldn't join back.
A ----- B (worked fine)
~~~X+------ C
A----+------ B (Did not work fine at all :D )
One thing that I was avoiding doing (which I really shouldn't have) was implement my own custom pathfinding (yes - I tried the unity NavMesh System but because there are gaps between the roads it didn't work) however, I caved and did just that, implemented my own path finding. I didn't think I was going to enjoy it as much as I did (I don't have much experience with custom path finding) it was a really good learning experience and the results are fantastic, have a look below.
I started with creating a grid of nodes around the world by spawn in these tiny cubes (they wont be visible) and these cubes will then be used to calculate the path that the cars will need to take in order to be able to successfully traverse the roads.

Followed that up with creating the path finding system itself but using the car as the "end" location for the route.

I then switched my approach where I'm not using the car to calculate the path, but rather the buildings, the car will then be spawned with the information needed to traverse this path (not implemented yet)

I've created so that the path moves as the buildings are moved, I copy/pasted the code I had written for the car but just modified it to work with the building positions. There are a few issues in the math, but all in all I'm quite happy with how its looking at the moment.
I don't want to spend an insane amount of time getting this to work, as I need to focus on some of the other major features of the game so I may optimise it a little and then leave it there. I'll post the final results, hopefully next week.
That's all for this dev blog, excited to see this working and can't wait to get the cars actually traversing!
Rus K
