C++ Navigation System Movement (GetNextMove)?

I feel like I am missing something, but how am I suppose to (in C++, not Blackboard/Blueprints) get the FVector for the “current move”?

I’ve searched through UNavigationSystem,UNavigationComponent, and PathFollowingComponent with no luck.

Update: My code
Just showing my code as the answer for using GetCurrentDirection is producing an empty vector.

ABLTAI::ABLTAI(const FObjectInitializer& ObjectInitializer)
:Super(ObjectInitializer)
{
	//Setup Navigation
	NavigationComponent = ObjectInitializer.CreateDefaultSubobject<UNavigationComponent>(this, TEXT("NavigationComp"));

	PathFollowingComponent = ObjectInitializer.CreateDefaultSubobject<UPathFollowingComponent>(this, TEXT("PathFollowingCom"));
	 //PathFollowingComponent->OnMoveFinished.AddUObject(this, &AAIController::OnMoveCompleted); //Delegate additions??

	bDebugVision = true;
	bDebugPaths = true;
}

void ABLTAI::Tick(float DeltaTime)
{
	Super::Tick(DeltaTime);
	
	//Pawn related ticks
	if (GetPawn())
	{
		VisualTick();

		if (bDebugVision)
			DrawDebugVision();
		if (bDebugPaths)
			DrawDebugPathing();
	}

	WhatToDoNext();

}

void ABLTAI::WhatToDoNext()
{
	if (NavigationComponent && PathFollowingComponent)
	{
		FString TestString = PathFollowingComponent->GetCurrentDirection().ToString();
		GEngine->AddOnScreenDebugMessage(-1,0.1f,FColor::White,TestString);
		

	}
}

void ABLTAI::VisualTick()
{
	
	for (TActorIterator<ABLTPlayerPawn> ItrPawn(GetWorld()); ItrPawn; ++ItrPawn)
	{
		if (CanSee(*ItrPawn)) //Visual Check
		{
			if(HasDetectedPawn(*ItrPawn))
				DetectedPawn(*ItrPawn);

			if (Target == *ItrPawn)
				SetNavigationGoal(Target);

		}
		else //Can't see player
		{
			if (*ItrPawn == Target)
				Target = NULL;
		}
	}
}

//==============================================================
//========================= Navigation =========================
//==============================================================

void ABLTAI::InitNavigationControl(UNavigationComponent*& PathFindingComp, UPathFollowingComponent*& PathFollowingComp)
{
	PathFindingComp = NavigationComponent;
	PathFollowingComp = PathFollowingComponent;
}

void ABLTAI::SetNavigationGoal(AActor* ActorGoal, FVector VectorGoal)
{
	if (!NavigationComponent)
		return;

	if (ActorGoal != nullptr)
		NavigationComponent->FindPathToActor(ActorGoal);
	else
		NavigationComponent->FindPathToLocation(VectorGoal);
}

If I understand you correctly closest to what you’re looking for is UPathFollowingComponent.GetCurrentDirection (returning current path segment direction) and UPathFollowingComponent.GetCurrentTargetLocation (returning the end of current path segment).

Cheers,

–mieszko

So if I understand, there is no longer the UDK/UE3 Equivalent of NavHandler.GetNextMoveLocation();? Instead it produces a Direction that can be a little more dynamic as it updates?

However, calling that produces an FVector(0,0,0) even though I see the path debugging. (AI is right behind the box)

I also updated my original post with my code

You need to play around with it. Function I’ve mentioned work only when AI has a valid move request, but it seems that might be the case for you since you are drawing a path. Have you tried using GetCurrentTargetLocation?

What UE4 version are you using? May I suggest switching over to 4.7, even a preview build? The main reason I’d do that is because NavigationComponent just went away, ceased to be, gone to meet his maker :wink:

Also FVector(0,0,0) (which is the function that I was originally trying to use). Seeing that there is nothing working, I did a little investigation and checked to see if NavigationComponent and PathFollowingComponent saw each other. NavigationComponent sees PathFollowingComponent per its variable “PathFollowComp” but PathFollowingComponent’s variable “NavComp” == none.

Being I haven’t modified any of the initialization code, I’m not sure why PathFollowingComponent can’t find it, which is probably why everything isn’t working.

Haha, I was hoping that would be the case. I was actually holding off as I heard that things were being transitioned. I am using 4.6 and I will look into downloading 4.7 and using that version instead.