Getting preview of a path and its cost from the Nav System in C++

Hey there,

I am working on a turn-based tactics game in unreal engine 4.
One of the staples of these types of games is that you can preview the path that you will take before you travel there. Further, each possible path has a ‘cost’, and you can only move a certain distance per turn.

I was going to write my own A* implementation, but I would like to give the built in nav a shot so I can have smooth integration with the AI tools.

So, does anyone have any idea how to preview a path for a unit before you travel it, and get that paths associated cost? Not sure if this is supported natively or if I would have to implement it myself.

I am using c++, not blueprints btw.

Cheers!

UNavigationSystem::FindPathToLocationSynchronously might be what you’re looking for. That takes a start and end position and returns a UNavigationPath, which contains a list of points along the path and a function you can call to get the cost. Might take a while if the paths you’re making are long, so just keep that in mind.

thank you! That hit the spot, gives me exactly what I need.

My paths aren’t very long, since they are limited by the characters total action points.

thanks again.

Here, I have created two practical solutions for this. But in blueprints.

Regards,