Hello!
I would like to create a system where the player can build walkways at runtime for a building type game I’m working on. Very similar to Rollercoaster Tycoon (3) or roads in SimCity or Cities Skylines if you’re not familiar with Rollercoaster Tycoon.
My pathway system will however be fairly simple, as it will only be used as walkways for AI pedestrians. The system will also be grid based on a flat 3D plane so there will be no need to handle curves or terrain.
Something I’ve also encountered a lot while reading is procedural mesh generation which I feel might be overkill in my case. Instead my current solution would be to create all the different pieces that is needed (straight, turn, crossroad, end) and simply instantiate the correct one on one cell of the grid. Is this a good approach? My main concern with this is clipping, something I encountered during some testing of this idea.
Which leads me into my first real issue which is how to handle and update the pieces on the grid. The best solution I’ve found myself while reading is to alert the 4 neighbouring cells (up, down, left, right) to the one placed or removed and that way update (remove and replace i assume) those cells so they fit with the new cell. This seems like a good solution but I don’t know how to implement this in a way that makes sense. You could check all directions manually one at a time, is there a walkway above me? is there one to the left on me? but this seems incredibly inefficient.
The second problem has to do with navigation. I thought I could use unity’s navmesh system initially but with instantiating prefabs I have yet to found a solution that works with unity’s navmesh system as it has to be baked before runtime. This leaves me to look at other options, what I’ve found so far and think is the best solution would be a node based navigation system with A* or Dijkstra’s algorithm. Which probably could be it’s own thread but something I thought I would include as I am unsure how to implement this with my walkway building system. Or if there is a simpler better system all together?
With that said hopefully I’ve explained myself and the problems I am having well enough for you guys to understand. If anything is unclear please let me know.
Any help is much appreciated.
Thanks