Announcement

Collapse
No announcement yet.

Question on FindPathToActorSynchronously

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Question on FindPathToActorSynchronously

    I am following a course on Udemy and am now stuck on an issue.

    Below is the code in the course that we are using for the sphere to track and move to the player. When I launch the game I am getting a Breakpoint Error on "if (NavPath->PathPoints.Num() > 1)"

    I am thinking it is because there are no path points on the level for the sphere to go to. But with it supposed to be finding a path to the Player Character, it should be moving the location and getting a path to follow in the Nave Mesh correct?


    FVector ASTrackerBot::GetNextPathPoint()
    {
    APawn* PlayerPawn = UGameplayStatics::GetPlayerPawn(this, 0);

    UNavigationPath* NavPath = UNavigationSystemV1::FindPathToActorSynchronously(this, GetActorLocation(), PlayerPawn);

    if (NavPath->PathPoints.Num() > 1)
    {
    return NavPath->PathPoints[1];
    } //Failed to find path
    return GetActorLocation();
    }

    When I do Simple Move to Actor in BP it works and goes right to the Player character. In BP GetPathPoints is an array, so with nothing in the array or to find, it keeps Breakpointing in my code.

    Any help would be gladly appreciated.
Working...
X