I’m making a tower defense game and explaining what I want is rather simple. Enemies enter via a door and exit via a gate. When I press Tab, I want to see the path the enemies will take. This is a dynamic path since building towers can alter the path the enemies take.
I’m using a nav mesh to query the path since I want to show the exact same path as in the game. But when I ask for a path, it doesn’t seem bothered by elevation changes. So if there’s a path in a straight line that goes up and down, I’ll only get a point at the start and one point at the end of the straight path.
I’m using a spline mesh component to show the path. Having the spline go through and under the road isn’t a good look.
I’ve thought about using a FInterpCurveVector and sampling points along the curve to get the proper elevation. But that could add delays and help people cheat. Maybe it won’t be a problem. I think knowing where the road changes elevation is the tough part.
I do have an in-memory map of the grid and paths. I use it to check if the path would be blocked when building a tower. But using it here is not so obvious.
Here’s a screenshot of some of the points on the path.
There are 3 paths. The green spheres show points on the path (elevated by 50cm). You can see all 3 paths have ZERO points when the elevation changes. It knows the elevation changes. But it doesn’t care. The middle path (yellow borders) is especially bad. You can see the blue preview spline goes completely under the road.
The nav mesh itself follows the elevation changes perfectly.
Anyone have any ideas how to make the preview path follow the surface of the roads?
After writing it all out, my best idea right now is to compare heights of every pair of points. If the heights are different, then I need to do some line traces in between the points to add points at their proper heights. The problem is I have a path that goes down and back up. So both endpoints are at exactly the same height and that means this idea won’t work for that segment.

