# Is there an example of finding path asynchronously in navigation system

**URL:** <https://forums.unrealengine.com/t/is-there-an-example-of-finding-path-asynchronously-in-navigation-system/338635>\
**Category:** AI\
**Tags:** ai-navigation, unreal-engine, UE4, question\
**Created:** [November 16, 2015, 9:14am UTC](https://forums.unrealengine.com/t/is-there-an-example-of-finding-path-asynchronously-in-navigation-system/338635 "2015-11-16T09:14:44Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![riskdark](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@riskdark](https://forums.unrealengine.com/u/riskdark)\
**Post date:** [November 16, 2015, 9:14am UTC](https://forums.unrealengine.com/t/is-there-an-example-of-finding-path-asynchronously-in-navigation-system/338635/1 "2015-11-16T09:14:44Z")

</div>

I’m recently studying the source code about AI in UE4, and I notice UE4 seems to have a navigation System supporting finding path asynchronously(Because I find a function called “FindPathAsync” in NavigationSytem.cpp), but I can not find any places using this function in source code or a simple example about this, even in Blueprint I can not find any related functions, so I want to know how to use it, Is there a simple example about it?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_e94eba37](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_e94eba37](https://forums.unrealengine.com/u/anonymous_user_e94eba37)\
**Post date:** [February 14, 2016, 9:44am UTC](https://forums.unrealengine.com/t/is-there-an-example-of-finding-path-asynchronously-in-navigation-system/338635/2 "2016-02-14T09:44:02Z")

</div>

Still there’s nothing out there. Can anyone provide an example?

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_a6661c981](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_a6661c981](https://forums.unrealengine.com/u/anonymous_user_a6661c981)\
**Post date:** [May 11, 2016, 6:39pm UTC](https://forums.unrealengine.com/t/is-there-an-example-of-finding-path-asynchronously-in-navigation-system/338635/3 "2016-05-11T18:39:02Z")

</div>

This is a snippet of my code used to get path from a character to a mission objective:

```
void AHeroCharacterBase::ShowPathToObjective()
{
	FObjectiveBase lastObjective;
	bool isObjectiveFound = false;

	AChroniclesGameMode* gameMode = Cast<AChroniclesGameMode>(GetWorld()->GetAuthGameMode());
	if (gameMode)
	{
		if (IsValid(gameMode->GetObjectivesManager()))
		{
			TArray<FObjectiveBase> objectives = gameMode->GetObjectivesManager()->GetVisibleObjectivesWithLocation();
			if (objectives.Num() > 0)
			{
				lastObjective = objectives[objectives.Num() - 1];
				isObjectiveFound = true;
			}
		}
	}

	if (isObjectiveFound)
	{
		FNavAgentProperties navAgentProperties;
		navAgentProperties.AgentHeight = 100;
		navAgentProperties.AgentRadius = 10;
		navAgentProperties.bCanWalk = true;
		navAgentProperties.bCanFly = false;

		FPathFindingQuery navParams;
		navParams.EndLocation = lastObjective.GetLocation();
		navParams.StartLocation = GetActorLocation();
		ANavigationData* navData = GetWorld()->GetNavigationSystem()->MainNavData;
		navParams.QueryFilter = UNavigationQueryFilter::GetQueryFilter<UNavigationQueryFilter>(navData);
		navParams.NavData = navData;

		FNavPathQueryDelegate del;
		del.BindUObject(this, &AHeroCharacterBase::PathToObjectiveFound);

		GetWorld()->GetNavigationSystem()->FindPathAsync(navAgentProperties, navParams, del, EPathFindingMode::Regular);	
	}
}

void AHeroCharacterBase::PathToObjectiveFound(uint32 aPathId, ENavigationQueryResult::Type aResultType, FNavPathSharedPtr aNavPointer)
{
	FNavPathPoint lastNavPoint;
	bool isFirstPoint = true;
	for (FNavPathPoint navPoint : aNavPointer->GetPathPoints())
	{
		DrawDebugPoint(GetWorld(), navPoint.Location, 10, FColor::Red, false, 100);
		if (!isFirstPoint)
		{
			DrawDebugLine(GetWorld(), lastNavPoint.Location, navPoint.Location, FColor::Red, false, 100);
		}
		lastNavPoint = navPoint;
	isFirstPoint = false;
	}
}

```
