Hey, everyone.
I’ve been trying to create a method to draw/render a Navigation Path using Splines for… Let’s say “a while” and leave it at that.
On a flat surface, this is actually really easy—just set the Spline points to be the same as the Navigation Path points and you’re all set. The problem I’ve been struggling with only really applies to uneven terrain (slopes/ramps/landscapes); when a path runs straight up or down a slope, the Navigation System places no points on that slope.
This is fine for keeping paths simple, sure, but it means that a spline constructed from those points clips through the terrain:
[SPOILER]
This is making things kinda… Tricky, because I’m using the generated Spline to display the limited distance the player character can move, so naturally it needs to accurately show the distance covered *on the ground. *
The (hopefully temporary) solution I’ve come up with is to flatten the Spline to the player’s Z position, and crawl along it at 5UU intervals, running vertical Line Traces to check for changes in slope and elevation underneath it and update the Spline with new points as it goes. Essentially brute-forcing it.
The result is a line that looks like this:
[SPOILER]
[/SPOILER]
…Which… *Technically *works. It freaks out a bit on lumpier terrain such as Landscapes, and of course running so many Line Traces *every single frame *the Spline is displayed isn’t exactly fantastic, especially as it gets longer.
So is there a better way to do this, short of overhauling the NavMesh pathfinding for a grid? I’ve been hoping to adapt it (Eventually) into a gridless turn-based movement system, but this has seriously been slowing me down.
Thanks in advance!