A* Pathfinding Project

Agents Controlling a Vehicle


Hi guys,

I am using version 3.8.10 and I have used navmesh for all my levels.

i have setup a navmesh. then created a car with an Agent and car controller - the script that controls the car. The car controller takes in the path.vectorPath[currentWaypoint] and works out the angle to turn the steering wheels and orientate the car along the path. Sometimes the path recalculates before a vehicle has turned to face the right way but thats ok as there is a final destination for it to reach.

With the funnel modifier this works really well and the car will navigate over the course and goes along the path smoothly.

I am stuck with putting obstacles in front of the cars path, the pathfinding is correct and thinks the next waypoint is behind or through the obstacle so the agent is trying to get to the final destination. I can raycast infront of my car and detect an obstacle and tell the car controller to slow down and stop or reverse if its too close but the path recalculation usually determines that it should move through my obstacle again and my car goes into deadlock - unable to go forward too much or reverse back too much.

If i have an agent attached to a vehicle what is a good approach to implement obstacle avoidance ? Do i need to learn how to use the RVOAgent ? or can i move the currentWaypoint and force a recalculation of the path ? Has anyone used the agents like i have to be auto pilots of vehicles so they are confined to the movements of the vehicle and not an free moving things ?

What I think am asking is for a recommendation of an approach to path finding and obstacle avoidance - if agents are constrained to the controls of a simulated vehicle and is this a good idea ?

Thank you.



Are you creating a racing game or something similar?
If so I actually don’t recommend pathfinding at all because the obstacles are usually not complicated at all and some kind of steering behavior will work a lot better (see for example https://www.red3d.com/cwr/steer/).
Pathfinding for a racing game will not work well because it does not take into account the speed and direction of the car, so a reasonable pathfinding path might take the car backwards, but that will look very strange in a racing game.


There is open terrain and the vehicles are moving across the terrain, I am dynamically adding buildings to the terrain and dynamically dropping targets for the vehicles so they act like they are patrolling. If a building is spawned in the path of a vehicle then it will stop it.



Ok, so then your question is about how to handle movement when your agent is constrained to vehicle-like movement (cannot turn too quickly) but the calculated path requires it to do this? Is that correct?


https://www.red3d.com/cwr/steer/ that helped me out. Thanks :slight_smile:


@aron_granberg Hi, I was trying to find out if it was possible to handle a vehicle movement with A* Pathfinding Project and found that post. Could you please answer your own question? :slight_smile: