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);
}