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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

How do you get a Navigation path in UE4 4.20 in C++?

I'm currently trying to figure out how to get a Navigation path for my pawn in C++.The way I've seen people get the path is by using GetWorld()->GetNavigationSystem()->FindPathToLocationSynchronously(). But, in UE4 4.2, GetWorld()->GetNavigationSystem() returns a NavigationSystemBase which doesn't have the find path functionality. Does anyone know how I can find a path in 4.2 in c++?

Also the documentation online is out of date for the include for NavigationSystem.h, its now located in Runtime/NavigationSystem/Public/NavigationSystem.h

Any help would be appreciated!

Product Version: UE 4.20
Tags:
more ▼

asked Aug 24 '18 at 07:35 PM in C++ Programming

avatar image

LDOGLONDON
105 5 7 8

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

1 answer: sort voted first

I think I figured it out.

include "Runtime/NavigationSystem/Public/NavigationSystem.h"

then

UNavigationSystemV1* navSys = UNavigationSystemV1::GetCurrent(GetWorld()); UNavigationPath* path = navSys->FindPathToLocationSynchronously()

more ▼

answered Aug 24 '18 at 07:42 PM

avatar image

LDOGLONDON
105 5 7 8

avatar image LDOGLONDON Aug 24 '18 at 09:05 PM

Just kidding, in 4.2 you have to add "NavigationSystem" to your projects Build.cs

and to get the path finding system and nav points

UNavigationSystemV1* navSys = FNavigationSystem::GetCurrent(GetWorld());

UNavigationPath* path = navSys->FindPathToLocationSynchronously(GetWorld(), GetPawn()->GetActorLocation(), position, NULL);

avatar image LDOGLONDON Sep 08 '18 at 01:07 AM

So my first answer worked on my work project and my second answer worked when I was in the UE4 Advanced Car template project. I'm pretty sure they are both engine version 4.20, so idk whats up with that.

(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