Pathfinding for Horizontal+Vertical Spline-Based Race Tracks
Hello everyone. Sorry if it's the question that has already been answered somewhere on the forum, but I really couldn't find any more-or-less complete answer to this. So I'm working on Trackmania-style racing game, but with anti-gravity physics (meaning that there's no gravity for a vehicle while it's on track, only a magnetic connection between the track and the vehicle itself). It is a C++-based project, with majority of complex components like the track constructor and anti-gravity vehicles implemented in C++. And now I'm collecting various info I need for vehicles' AI implementation. Based on other posts here on forum, I do know that NavMesh generator volume does not support vertical surfaces - or rather, as I've discovered, surfaces with more than 45 angle to the 'Z' plane. But in the case of my project, the race track may have many vertical/diagonal sections. NavMesh is not generated for them, apparently because Recast algorithm operates on flat surfaces, which these segments are oblviously not. Examples:
Moreover, navmesh generated on some track sections is disrupted:
So from searching through the forum I've found out that my best bet would be to ditch the NavMesh and write something custom instead. Like a custom waypoint system. But I just can't find enough info on how to even approach this task in this specific case. I realize this is kind of super-noob question, but please bear with me and help me put together all the available info on this matter, which may be also be useful for anyone else attempting to implement something similar. Thanks in advance.
asked Nov 06 '18 at 02:21 PM in Using UE4
I've approached this problem with a different perspective. I found a solution which works for me, and if someone ever encounters a problem like this, I thought it would be useful to share my solution for such people. So obviously a built-in NavMesh is not compatible with such surfaces, which is why I instead have come up with custom path resolution, completely relying on checkpoint markers, which are placed relatively densely (about 100 points for a middle-sized track). Each time a vehicle AI tries to guess which direction to go, it looks for next target checkpoint's location, and then steers directly towards it, as if it was on the same flat plane along with the vehicle itself. And all this while performing nessessary turning/acceleration/braking, as well as obstacles avoidance and other interaction with other vehicles, as it goes towards it. This is a base logic, and it can be customized with custom "smart" behaviors, like race goals, priorities, and so on. Densely placed markers (which are also placed in adequate places) also make sure that when AI makes decisions about heading direction, it does not need to count in the track's surface curve. At least in my case this is more than enough.
answered Dec 19 '18 at 09:43 AM
Follow this question
Once you sign in you will be able to subscribe for any updates here