Hello guys.
TLDR:
What is a solid solution for vehicle pathfinding? AKA pathfinding for agents who have a limited turning radius (possibly considering that they can go in reverse)?
I wrote a replacement to the default NavMesh Agent using agent.Move method and it basically does the same thing as the default NavMesh agent, but instead of rotating and sliding around so much as it follows its path very directly, my custom agent acts more like a wheeled vehicle, only moving forwards and rotating to aim towards the āsteeringTargetā, which is the next point/turn in the path. It is similar to what you can see in this tutorial video:
The idea is to have a dummy navmesh agent that can pathfind through a city, and have the dummy followed by a physics driven car. As the physics driven car moves around in pursuit of the navmesh agent dummy, it allows the navmesh agent to move further along its path.
This lets me use dynamic rigidbody vehicles but also pathfind with the built in navmesh unity offers. Great!
But⦠that is where things get complicated. Sure, now the agent moves in a way more similar to a real car, and the physics car can follow it more easily than if it took hard turns all the time like the regular navmesh agent might do, but it still is hitting some snags.
One drawback to this whole turn rotation limiting on the agent, is that the agent will hit the edges of the navmesh sometimes, and will kind of slide slowly until it rotates enough or slides slowly enough to get back in the open again.
Another drawback is that the actual path is the same as it would be for a regular old navmesh agent, and this doesnāt consider that a vehicle might be travelling too fast or just canāt turn tight enough to make a certain angle of a turn. Even though a vehicle might be able to fit in an alleyway, doesnāt mean the vehicle can come down the street and make a 90 degree turn into the alley - and even if the agent rotates slowly before hitting the wall in that alley, itāll still get the physical car stuck in the alley (Image below for reference shows a red āactual pathā and a yellow āpoints along the path the agent providesā example):
Iāve tried some other approaches like an all raycasting based avoidance system (not reliable enough and crashes frequently), or a system where the ai driver follows normal road waypoints (not robust enough and the driver canāt go offroad or take shortcuts around traffic very well).
These other approaches just donāt seem to work very well though, and the navmesh approach seems to be pretty promising so far because its possible to go on and off the road without a nutty amount of waypoints all over, and allows for obstacle avoidance to be kind of baked in to some extent with navmesh obstacles carving.
What would you suggest might work to pathfind through the navmesh for a vehicle that has a limited turning radius, unlike a humanoid or other typical navmesh agent character might have? If it means a custom pathfinding algorithm instead of taking a path from a navmesh agent Iād be open to trying that out, but Iām not sure if Iād be able to still use the built in navmesh component and still hack out my own ācurve-y A starā or something, or if that is even possible using these tools (to use your own pathfinding algorithm to find a path on the nav mesh).
Obviously this isnāt a trivial problem to solve - but Iād like to hear some advice about what might work for cars pathfinding on a navmesh. I know there isnāt going to be an āout of the boxā solution to this, but what sort of things might help push me in the right direction to solve this type of problem? Has anybody ever done something this complex on the navmesh in unity and lived to tell the story? Iāve seen vague references to this ācorridor map methodā but I canāt find a good implementation anywhere. Iād scrap the idea of a navmesh in favor of a smarter approach if somebody knows one - just working off that because it has had promising results so far, and I think a proper solution that also takes advantage of the navmesh would be really cool.
USEFUL ARTICLES/SITES:
ftp://ftp.math.ucla.edu/pub/camreport/cam09-74.pdf (A Practical Path-planning Algorithm for a Vehicle with a Constrained Turning Radius: a Hamilton-Jacobi Approach)
Scrapsgame.com: Fighting Games Reviews, Tips, and News

