Pathfinding and two-laned roads

Hello, I’m trying to implement vehicle AI that follows traffic rules on a road network in city map, but I’m having some troubles. I’m not sure how to implement the pathfinding for the cars, since navmeshes can’t make the cars stay in their own lane. The internals of the Unreal Engine navigational system isn’t that well documented, so I thought I’d ask for some help.

I have spline based roads and I’m thinking of having each lane have their own one-way waypoints on each spline end, which are then connected to the correct socket on the next road spline. Road network will be modified on runtime. The waypoint grid would probably need to be extended from ANavigationData, and possibly I’ll have to write pathfinding from scratch myself.

Is there a simpler way? Can NavMeshes be built programmatically, if I know which points are connected to which points? Or could Nav Link proxies be used for this? Am I even thinking this from the correct direction? Ideally I’d like to reuse as much Unreal Engine core functionalities as possible. Also, it would be cool if I’ll manage this with the physics engine instead of having vehicles follow the waypoint path like they are on tracks but it’s not necessary.

Any thoughts or input would be appreciated. Either Blueprints or C++ is fine for me, though Blueprints are preferred.

This may sounds stupid, but can you not simply use ‘the Ai move to’ node, set the destination, then redo it with a new destination to kind of map out waypoints for the car? It is a boring and slow workflow, but I would say that would be a vary simple way of setting up way points for a car Ai. I can’t say I have ever made that, but I did something similar with my zombies, except my destination would be random within an accepted radius.

Hey murgo,

I´m also very interested in a solution for the car pathfinding. At the moment I´m trying it with a work around… i try to use the navmesh and block out everything except the streets… there are splines on the street wich the car is following… buuuuut this is a very annoying and static solution…
I would love to know a better way…

I´m doing something like this at the moment… but this is a very static way of doing it… so at the moment my biggest problem is to define which one is the next waypoint… so for example you have a big city with a lot of crossroads… how would you define the way the car should drive? if the car should go from a to b… an normal npc can run around and use the navmesh, but a car needs to stay on the roads…