Spinning up my own path system for traffic. Probably better way to do this, but I figure this should work well enough.


Basically whenever I've tried to use Nav meshes or A* I've hit performance problems when you start dealing with lots of agents or large distances. On top of this, the procedural nature of the scene would mean continuously modifying any routing.
To get around this I'm hoping to apply the same concept as computer routers, where each local 'router' will tell you the available direction to other routers (visualised above for testing, but ultimately this is stored in a singleton dict, not each node).
That way my other flying traffic (which doesn't need to be 'smart') can simply have a desired direction of N,NE,E...etc. and just do a hash lookup of it's closest node to understand what is available, picking something in the general direction of travel.
If it hits a dead end, obviously turn around, but also invert your desired direction vector. That way the vehicle should fly continuously while basic lerping should sort out cornering if I tweak it right.
This way no shortest path lookups are required and I feel like this should have a relatively tiny overhead, only needing to be performed once or twice a second per vehicle. Also the process of mapping all the available directions between nodes only generates once per block, with about a 0.5ms overhead, so no issues adding new blocks procedurally.
Then will just need to add some local avoidance logic and set a Y value for each vehicle, along with an offset depending on direction of travel to create 'lanes' of traffic either side and above the 'routers'.
Doubt I will get this fully realised tonight as for some reason my buildings are slightly shifting relative to the routing nodes the further I travel, which I need to fix first, or cars will be directed into walls .