UPathFollowingComponent

Windows
MacOS
Linux

Inheritance Hierarchy

References

Module

AIModule

Header

/Engine/Source/Runtime/AIModule/Classes/Navigation/PathFollowingComponent.h

Include

#include "Navigation/PathFollowingComponent.h"

Syntax

class UPathFollowingComponent :
    public UActorComponent,
    public IAIResourceInterface,
    public IPathFollowingAgentInterface

Variables

Name Description

Protected variable

float

 

AcceptanceRadius

Min distance to destination to consider request successful.

Protected variable

uint8: 1

 

bCollidedWithGoal

Set when agent collides with goal actor

Protected variable

uint8: 1

 

bIsDecelerating

True if pathfollowing is doing deceleration at the end of the path.

Protected variable

uint8: 1

 

bIsUsingMetaPath

If set, path following is using FMetaNavMeshPath

Protected variable

uint8: 1

 

bLastMoveReachedGoal

Set when last move request was finished at goal

Protected variable

float

 

BlockDetectionDistance

Detect blocked movement when distance between center of location samples and furthest one (centroid radius) is below threshold

Protected variable

float

 

BlockDetectionInterval

Interval for collecting location samples

Protected variable

int32

 

BlockDetectionSampleCount

Number of samples required for block detection

Protected variable

uint8: 1

 

bMoveToGoalOnLastSegment

If set, target location will be constantly updated to match goal actor while following last segment of full path

Protected variable

uint8: 1

 

bReachTestIncludesAgentRadius

Increase acceptance radius with agent's radius

Protected variable

uint8: 1

 

bReachTestIncludesGoalRadius

Increase acceptance radius with goal's radius

Protected variable

uint8: 1

 

bStopMovementOnFinish

If set, movement will be stopped on finishing path

Protected variable

uint8: 1

 

bUseBlockDetection

If set, movement block detection will be used

Protected variable

uint8: 1

 

bWalkingNavLinkStart

Gets set when agent starts following a navigation link.

Protected variable

float

 

CachedBrakingDistance

Braking distance for acceleration driven path following

Protected variable

float

 

CachedBrakingMaxSpeed

Max speed used for CachedBrakingDistance

Protected variable

float

 

CurrentAcceptanceRadius

Min distance to end of current path segment to consider segment finished

Protected variable

FWeakObjectPtr

 

CurrentCustomLinkOb

Currently traversed custom nav link

Protected variable

FBasedPosition

 

CurrentDestination

Destination for current path segment

Protected variable

FVector

 

CurrentMoveInput

Last MoveInput calculated and passed over to MovementComponent.

Public variable

uint8: 1

 

DEBUG_bMovingDirectlyToGoal

Protected variable

int32

 

DecelerationSegmentIndex

Index of path point for starting deceleration

Protected variable

TWeakObjectPtr<...

 

DestinationActor

Destination actor. Use SetDestinationActor to set this

Protected variable

const INavAgent...

 

DestinationAgent

Cached DestinationActor cast to INavAgentInterface.

Protected variable

FCustomMoveShar...

 

GameData

Game specific data

Protected variable

float

 

LastSampleTime

Timestamp of last location sample

Protected variable

TArray< FBasedP...

 

LocationSamples

Location samples for stuck detection

Protected variable

FVector

 

LocationWhenPaused

Agent location when movement was paused

Protected variable

float

 

MinAgentHalfHeightPct

Part of agent height used as min acceptable height difference

Protected variable

float

 

MinAgentRadiusPct

Part of agent radius used as min acceptance radius

Protected variable

UNavMovementCom...

 

MovementComp

Associated movement component

Protected variable

FVector

 

MoveOffset

Relative offset from goal actor's location to end of path

Protected variable

FVector

 

MoveSegmentDirection

Direction of current move segment

Protected variable

int32

 

MoveSegmentEndIndex

Index of path point being current move target

Protected variable

NavNodeRef

 

MoveSegmentEndRef

Reference of node at segment end

Protected variable

int32

 

MoveSegmentStartIndex

Index of path point being current move beginning

Protected variable

NavNodeRef

 

MoveSegmentStartRef

Reference of node at segment start

Protected variable

float

 

MyDefaultAcceptanceRadius

Value based on navigation agent's properties that's used for AcceptanceRadius when DefaultAcceptanceRadius is requested

Protected variable

ANavigationData...

 

MyNavData

Navigation data for agent described in movement component

Protected variable

int32

 

NextSampleIdx

Index of next location sample in array

Public variable

FMoveComplete

 

OnRequestFinished

Delegate for move completion notify

Protected variable

FVector

 

OriginalMoveRequestGoalLocation

This is needed for partial paths when trying to figure out if following a path should finish before reaching path end, due to reaching requested acceptance radius away from original move goal Is being set for non-partial paths as well

Protected variable

FNavPathSharedP...

 

Path

Requested path

Protected variable

float

 

PathTimeWhenPaused

Timestamp of path update when movement was paused

Public variable

FPostProcessMov...

 

PostProcessMove

Delegate for modifying path following velocity

Protected variable

int32

 

PreciseAcceptanceRadiusCheckStartNodeIndex

Indicates a path node index at which precise "is at goal" tests are going to be performed every frame, in regards to acceptance radius

Protected variable

FAIResourceLock

 

ResourceLock

Used to keep track of which subsystem requested this AI resource be locked

Protected variable

TEnumAsByte< EP...

 

Status

Current status

Protected variable

FTimerHandle

 

WaitingForPathTimer

Timer handle for OnWaitingPathTimeout function

Protected variable

float

 

WaitingTimeout

Timeout for Waiting state, negative value = infinite

Constructors

Name Description

Public function

UPathFollowingComponent

(
    const FObjectInitializer& ObjectIn...
)

Functions

Name Description

Public function Virtual

void

 

AbortMove

(
    const UObject& Instigator,
    FPathFollowingResultFlags::Type Abo...,
    FAIRequestID RequestID,
    EPathFollowingVelocityMode Velocity...
)

Aborts following path

Public function Virtual

void

 

Cleanup()

Cleanup component before destroying

Protected function Const

void

 

DebugReachTest

(
    float& CurrentDot,
    float& CurrentDistance,
    float& CurrentHeight,
    uint8& bDotFailed,
    uint8& bDistanceFailed,
    uint8& bHeightFailed
)

Debug point reach test values

Public function Virtual Const

void

 

DescribeSelfToVisLog

(
    FVisualLogEntry* Snapshot
)

Protected function Virtual

int32

 

DetermineCurrentTargetPathPoint

(
    int32 StartIndex
)

Protected function Virtual Const

int32

 

DetermineStartingPathPoint

(
    const FNavigationPath* Conside...
)

Checks if this PathFollowingComponent is already on path, and if so determines index of next path point

Public function Const

bool

 

DidMoveReachGoal()

Public function Virtual Const

void

 

DisplayDebug

(
    UCanvas* Canvas,
    const FDebugDisplayInfo& DebugDisp...,
    float& YL,
    float& YPos
)

Protected function Const

int32

 

FindPreciseAcceptanceRadiusTestsStartNodeIndex

(
    const FNavigationPath& PathInstanc...,
    const FVector& GoalLocation
)

For given path finds a path node at which PathfollowingComponent should start doing precise is-goal-in-acceptance-radius tests

Public function Virtual

void

 

FinishUsingCustomLink

(
    INavLinkCustomInterface* Custo...
)

Call when moving agent finishes using custom nav link, returns control back to path following

Protected function Virtual

void

 

FollowPathSegment

(
    float DeltaTime
)

Follow current path segment

Protected function

void

 

ForceBlockDetectionUpdate()

Force creating new location sample for block detection

Public function Const

float

 

GetAcceptanceRadius()

Public function Const

UObject *...

 

GetCurrentCustomLinkOb()

Public function Const

FVector

 

GetCurrentDirection()

Public function Const

FVector

 

GetCurrentMoveInput()

Note that CurrentMoveInput is only valid if MovementComp->UseAccelerationForPathFollowing() == true

Public function Const

FNavLocation

 

GetCurrentNavLocation()

Returns current location on navigation data

Public function Virtual Const

int32

 

GetCurrentPathElement()

Returns index of the currently followed element of path.

Public function Const

uint32

 

GetCurrentPathIndex()

Public function Const

FAIRequestID

 

GetCurrentRequestId()

Public function Const

FVector

 

GetCurrentTargetLocation()

Public function Const

FBasedPositi...

 

GetCurrentTargetLocationBased()

Public function Virtual Const

FString

 

GetDebugString()

Public function Virtual Const

void

 

GetDebugStringTokens

(
    TArray< FString >& Tokens,
    TArray< EPathFollowingDebugTokens::...
)

Public function Const

float

 

GetDefaultAcceptanceRadius()

Protected function Const

float

 

GetFinalAcceptanceRadius

(
    const FNavigationPath& PathInstanc...,
    const FVector OriginalGoalLocation,
    const FVector* PathEndOverride
)

Based on Path's properties, original move goal location and requested AcceptanceRadius this function calculates actual acceptance radius to apply when testing if the agent has successfully reached requested goal's vicinity

Public function Virtual Const

FVector

 

GetMoveFocus

(
    bool bAllowStrafe
)

Get current focal point of movement

Public function Const

AActor *

 

GetMoveGoal()

Public function Const

FVector

 

GetMoveGoalLocationOffset()

Public function Const

uint32

 

GetNextPathIndex()

Protected function Static

uint32

 

GetNextRequestId()

Public function Const

const FNavPa...

 

GetPath()

Public function Const

EPathFollowi...

 

GetPathActionType()

Public function Const

FVector

 

GetPathDestination()

Public function Const

float

 

GetRemainingPathCost()

Public function Const

FString

 

GetResultDesc

(
    EPathFollowingResult::Type Result
)

Readable name of result enum

Public function Const

EPathFollowi...

 

GetStatus()

Public function Const

FString

 

GetStatusDesc()

Readable name of current status

Protected function Virtual

bool

 

HandlePathUpdateEvent()

Called after receiving update event from current path

Public function Const

bool

 

HasDirectPath()

Public function Const

bool

 

HasMovementAuthority()

Check if path following has authority over movement (e.g. not falling) and can update own state

Public function Const

bool

 

HasPartialPath()

Public function Const

bool

 

HasReached

(
    const FVector& TestPoint,
    EPathFollowingReachMode ReachMode,
    float AcceptanceRadius
)

Simple test for stationary agent (used as early finish condition), check if reached given point

Public function Const

bool

 

HasReached

(
    const FAIMoveRequest& MoveRequest
)

Simple test for stationary agent (used as early finish condition), check if reached target specified in move request

Public function Const

bool

 

HasReached

(
    const AActor& TestGoal,
    EPathFollowingReachMode ReachMode,
    float AcceptanceRadius,
    bool bUseNavAgentGoalLocation
)

Simple test for stationary agent (used as early finish condition), check if reached given goal

Protected function Virtual Const

bool

 

HasReachedCurrentTarget

(
    const FVector& CurrentLocation
)

Check if segment is completed

Protected function Const

bool

 

HasReachedDestination

(
    const FVector& CurrentLocation
)

Check if move is completed

Protected function Const

bool

 

HasReachedInternal

(
    const FVector& GoalLocation,
    float GoalRadius,
    float GoalHalfHeight,
    const FVector& AgentLocation,
    float RadiusThreshold,
    float AgentRadiusMultiplier
)

Check if moving agent has reached goal defined by cylinder

Public function Const

bool

 

HasStartedNavLinkMove()

Public function Const

bool

 

HasValidPath()

Public function Virtual

void

 

Initialize()

Initialize component to use

Public function Const

bool

 

IsBlockDetectionActive()

Protected function Const

bool

 

IsBlocked()

Check if movement is blocked

Public function Const

bool

 

IsCurrentSegmentNavigationLink()

Public function Const

bool

 

IsDecelerating()

Returns true if pathfollowing is doing deceleration at the end of the path.

Protected function Virtual Const

bool

 

IsOnPath()

Check if agent is on path

Public function Virtual Const

bool

 

IsPathFollowingAllowed()

Check if path following can be activated

Public function Const

bool

 

IsStopMovementOnFinishActive()

Public function Static

void

 

LogPathHelper

(
    const AActor* LogOwner,
    FNavPathSharedPtr InLogPath,
    const AActor* LogGoalActor
)

Helper function for sending a path for visual log

Public function Static

void

 

LogPathHelper

(
    const AActor* LogOwner,
    FNavigationPath* InLogPath,
    const AActor* LogGoalActor
)

Helper function for sending a path for visual log

Public function Virtual

void

 

OnActorBump

(
    AActor* SelfActor,
    AActor* OtherActor,
    FVector NormalImpulse,
    const FHitResult& Hit
)

Called when moving agent collides with another actor

Protected function

void

 

OnNavDataRegistered

(
    ANavigationData* NavData
)

Called when NavigationSystem registers new navigation data type while this component instance has empty MyNavData.

Protected function Virtual

void

 

OnNavigationInitDone()

Called when NavigationSystem finishes initial navigation data registration.

Protected function Virtual

void

 

OnNewPawn

(
    APawn* NewPawn
)

Called if owning Controller possesses new pawn or ends up pawn-less.

Public function

void

 

OnPathEvent

(
    FNavigationPath* InPath,
    ENavPathEvent::Type Event
)

Path observer

Public function Virtual

void

 

OnPathfindingQuery

(
    FPathFindingQuery& Query
)

Called when owner is preparing new pathfinding request

Public function Virtual

void

 

OnPathFinished

(
    const FPathFollowingResult& Result
)

Notify about finished movement

Public function

void

 

OnPathFinished

(
    EPathFollowingResult::Type ResultCo...,
    uint16 ExtraResultFlags
)

Public function Virtual

void

 

OnPathUpdated()

Notify about changing current path: new pointer or update from path event

Public function Virtual

void

 

OnSegmentFinished()

Notify about finishing move along current path segment

Protected function Virtual

void

 

OnWaitingPathTimeout()

Called from timer if component spends too much time in Waiting state

Public function Virtual

void

 

PauseMove

(
    FAIRequestID RequestID,
    EPathFollowingVelocityMode Velocity...
)

Pause path following

Public function Virtual

FAIRequestID

 

RequestMove

(
    const FAIMoveRequest& RequestData,
    FNavPathSharedPtr InPath
)

Start movement along path

Public function

FAIRequestID

 

RequestMoveWithImmediateFinish

(
    EPathFollowingResult::Type Result,
    EPathFollowingVelocityMode Velocity...
)

Create new request and finish it immediately (e.g. already at goal)

Protected function Virtual

void

 

Reset()

Reset path following data

Protected function

void

 

ResetBlockDetectionData()

Clears Block Detection stored data effectively resetting the mechanism

Public function Virtual

void

 

ResumeMove

(
    FAIRequestID RequestID
)

Resume path following

Public function

void

 

SetAcceptanceRadius

(
    const float InAcceptanceRadius
)

Public function

void

 

SetBlockDetection

(
    float DistanceThreshold,
    float Interval,
    int32 NumSamples
)

Set block detection params

Public function

void

 

SetBlockDetectionState

(
    bool bEnable
)

Update state of block detection

Public function

void

 

SetDestinationActor

(
    const AActor* InDestinationAct...
)

Public function

void

 

SetLastMoveAtGoal

(
    bool bFinishedAtGoal
)

Set status of last requested move, works only in Idle state

Public function Virtual

void

 

SetMovementComponent

(
    UNavMovementComponent* MoveCom...
)

Set associated movement component

Protected function Virtual

void

 

SetMoveSegment

(
    int32 SegmentStartIndex
)

Sets variables related to current move segment

Protected function

void

 

SetNextMoveSegment()

Switch to next segment on path

Public function

void

 

SetPreciseReachThreshold

(
    float AgentRadiusMultiplier,
    float AgentHalfHeightMultiplier
)

Set threshold for precise reach tests in intermediate goals (minimal test radius)

Public function

void

 

SetStopMovementOnFinish

(
    bool bEnable
)

Set whether movement is stopped on finish of move.

Protected function Virtual Const

bool

 

ShouldCheckPathOnResume()

Should verify if agent if still on path ater movement has been resumed?

Protected function Virtual

void

 

StartUsingCustomLink

(
    INavLinkCustomInterface* Custo...,
    const FVector& DestPoint
)

Next path segment if custom nav link, try passing control to it

Protected function

void

 

StoreRequestId()

Assign new request Id

Protected function Virtual

bool

 

UpdateBlockDetection()

Update blocked movement detection,

Public function Virtual

void

 

UpdateCachedComponents()

Updates cached pointers to relevant owner's components

Protected function Virtual

void

 

UpdateDecelerationData()

Updates braking distance and deceleration segment

Protected function

void

 

UpdateMoveFocus()

Set move focus in AI owner

Protected function Virtual

bool

 

UpdateMovementComponent

(
    bool bForce
)

Check if movement component is valid or tries to grab one from owner

Protected function Virtual

void

 

UpdatePathSegment()

Check state of path following, update move segment if needed

Overridden from UActorComponent

Name Description

Public function Virtual

void

 

OnRegister()

Called when a component is registered, after Scene is set, but before CreateRenderState_Concurrent or OnCreatePhysicsState are called.

Public function Virtual

void

 

TickComponent

(
    float DeltaTime,
    enum ELevelTick TickType,
    FActorComponentTickFunction* T...
)

Function called every frame on this ActorComponent.

Overridden from IAIResourceInterface

Name Description

Public function Virtual

void

 

ClearResourceLock

(
    EAIRequestPriority::Type LockSource
)

Clear resource lock of the given origin

Public function Virtual

void

 

ForceUnlockResource()

Force-clears all locks on resource

Public function Virtual Const

bool

 

IsResourceLocked()

Check whether resource is currently locked

Public function Virtual

void

 

LockResource

(
    EAIRequestPriority::Type LockSource
)

If resource is lockable lock it with indicated priority

Overridden from IPathFollowingAgentInterface

Name Description

Public function Virtual

void

 

OnLanded()

Called when falling movement ends.

Public function Virtual

void

 

OnStartedFalling()

Virtual void OnMoveBlockedBy(const FHitResult& BlockingImpact) {}

Public function Virtual

void

 

OnUnableToMove

(
    const UObject& Instigator
)

Called when pathfollowing agent is not able to move anymore

Typedefs

Constants

Name

Description

DefaultAcceptanceRadius

Special float constant to symbolize "use default value".

NextRequestId

Used for debugging purposes to be able to identify which logged information results from which request, if there was multiple ones during one frame

Deprecated Variables

Name Description

Public variable

FMoveCompletedS...

 

OnMoveFinished_DEPRECATED

This delegate is now deprecated, please use OnRequestFinished instead.

Deprecated Functions

Name Description

Public function Virtual

void

 

AbortMove

(
    const FString& Reason,
    FAIRequestID RequestID,
    bool bResetVelocity,
    bool bSilent,
    uint8 MessageFlags
)

This function is now deprecated, please use version with EPathFollowingResultDetails parameter instead.

Public function Const

bool

 

HasReached

(
    const FVector& TestPoint,
    float AcceptanceRadius,
    bool bExactSpot
)

This function is now deprecated, please use version with EPathFollowingReachMode parameter instead.

Public function Const

bool

 

HasReached

(
    const AActor& TestGoal,
    float AcceptanceRadius,
    bool bExactSpot,
    bool bUseNavAgentGoalLocation
)

This function is now deprecated, please use version with EPathFollowingReachMode parameter instead.

Public function Virtual

void

 

OnPathFinished

(
    EPathFollowingResult::Type Result
)

This function is now deprecated, please version with FPathFollowingResult parameter instead.

Public function

int32

 

OptimizeSegmentVisibility

(
    int32 StartIndex
)

This function is now deprecated and no longer supported.

Public function Virtual

void

 

PauseMove

(
    FAIRequestID RequestID,
    bool bResetVelocity
)

This function is now deprecated, please use version with EPathFollowingVelocityMode parameter instead.

Public function

FAIRequestID

 

RequestMove

(
    FNavPathSharedPtr InPath,
    const AActor* InDestinationAct...,
    float InAcceptanceRadius,
    bool InStopOnOverlap,
    FCustomMoveSharedPtr InGameData
)

This function is now deprecated, please use version with FAIMoveRequest parameter instead.

Public function Virtual

FAIRequestID

 

RequestMove

(
    FNavPathSharedPtr Path,
    FRequestCompletedSignature OnComple...,
    const AActor* DestinationActor,
    float AcceptanceRadius,
    bool bStopOnOverlap,
    FCustomMoveSharedPtr GameData
)

This function is now deprecated, please use version with FAIMoveRequest parameter instead. Any observers needs to register with OnRequestFinished mutlicast delegate now.

Public function Virtual

bool

 

UpdateMove

(
    FNavPathSharedPtr Path,
    FAIRequestID RequestID
)

This function is now deprecated and replaced with HandlePathUpdateEvent. Receiving new path pointer for the same move request is no longer supported, please either update data within current path and call FNavigationPath::DoneUpdating or start new move request.

Help shape the future of Unreal Engine documentation! Tell us how we're doing so we can serve you better.
Take our survey
Dismiss