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"

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);
 }
Product Version: Not Selected
Tags:
more ▼

asked Feb 16 '15 at 11:55 PM in C++ Programming

avatar image

IrishKilter
84 13 15 26

(comments are locked)
10|2000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered Feb 17 '15 at 12:32 PM

avatar image

MieszkoZ STAFF
7.3k 223 56 410

avatar image IrishKilter Feb 17 '15 at 01:11 PM

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)

alt text

aidebug.jpg (230.1 kB)
avatar image IrishKilter Feb 17 '15 at 01:36 PM

I also updated my original post with my code

avatar image MieszkoZ STAFF Feb 17 '15 at 01:57 PM

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?

avatar image IrishKilter Feb 17 '15 at 02:19 PM

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.

avatar image MieszkoZ STAFF Feb 17 '15 at 02:30 PM

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

avatar image IrishKilter Feb 17 '15 at 02:37 PM

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.

(comments are locked)
10|2000 characters needed characters left
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