x

Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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!

dan

Product Version: UE 4.10
Tags:
more ▼

asked Jan 08 '16 at 03:19 PM in C++ Programming

avatar image

HGG_Dan
18 3 4 6

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

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.

more ▼

answered Jan 08 '16 at 04:18 PM

avatar image

kgamble
934 44 62 211

avatar image HGG_Dan Jan 08 '16 at 04:26 PM

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.

avatar image navid100 Jul 22 '17 at 07:58 PM

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

Regards,

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question