UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
PathFollowingComponent.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#include "CoreMinimal.h"
10#include "EngineDefines.h"
12#include "NavigationData.h"
13#include "AITypes.h"
14#include "AIResourceInterface.h"
17#include "PathFollowingComponent.generated.h"
18
19class Error;
22class UCanvas;
23class ANavigationData;
24
26
27class UCanvas;
28class AActor;
32
33UENUM(BlueprintType)
35{
36 enum Type : int
37 {
40
43
46
49 };
50}
51
52UENUM(BlueprintType)
54{
75}
76
78{
79 typedef uint16 Type;
80
81 inline const Type None = 0;
82
84 inline const Type Success = (1 << 0);
85
87 inline const Type Blocked = (1 << 1);
88
90 inline const Type OffPath = (1 << 2);
91
93 inline const Type UserAbort = (1 << 3);
94
96 inline const Type OwnerFinished = (1 << 4);
97
99 inline const Type InvalidPath = (1 << 5);
100
102 inline const Type MovementStop = (1 << 6);
103
105 inline const Type NewRequest = (1 << 7);
106
108 inline const Type ForcedScript = (1 << 8);
109
111 inline const Type AlreadyAtGoal = (1 << 9);
112
114 inline const Type FirstGameplayFlagShift = 10;
115
117
118 FString ToString(uint16 Value);
119}
120
138
139// DEPRECATED, will be removed with GetPathActionType function
140UENUM(BlueprintType)
152
153UENUM(BlueprintType)
155{
162}
163
172
183
184// DEPRECATED, please use EPathFollowingResultDetails instead, will be removed with deprecated override of AbortMove function
186{
187 enum Type : int
188 {
191 };
192}
193
195{
196 Reset,
197 Keep,
198};
199
201{
204
207
210
213};
214
215UCLASS(config=Engine, MinimalAPI)
217{
219
224
226 FPostProcessMoveSignature PostProcessMove;
227
229 FMoveComplete OnRequestFinished;
230
231 //~ Begin UActorComponent Interface
232 AIMODULE_API virtual void OnRegister() override;
233 AIMODULE_API virtual void TickComponent(float DeltaTime, enum ELevelTick TickType, FActorComponentTickFunction *ThisTickFunction) override;
234 //~ End UActorComponent Interface
235
237 AIMODULE_API virtual void Initialize();
238
240 AIMODULE_API virtual void Cleanup();
241
243 AIMODULE_API virtual void UpdateCachedComponents();
244
248 AIMODULE_API virtual FAIRequestID RequestMove(const FAIMoveRequest& RequestData, FNavPathSharedPtr InPath);
249
252
257
261
264 AIMODULE_API virtual void ResumeMove(FAIRequestID RequestID = FAIRequestID::CurrentRequest);
265
267 AIMODULE_API virtual void OnPathFinished(const FPathFollowingResult& Result);
268
270
272 AIMODULE_API virtual void OnSegmentFinished();
273
275 AIMODULE_API virtual void OnPathUpdated();
276
282 UE_DEPRECATED(5.5, "SetMovementComponent(UNavMovementComponent* MoveComp) is deprecated, please use SetNavMoveInterface(INavMoveInterface* NavMoveInterface) instead.")
284
286 AIMODULE_API virtual void SetNavMovementInterface(INavMovementInterface* NavMoveInterface);
287
289 AIMODULE_API virtual FVector GetMoveFocus(bool bAllowStrafe) const;
290
297
304 AIMODULE_API bool HasReached(const AActor& TestGoal, EPathFollowingReachMode ReachMode, float AcceptanceRadius = UPathFollowingComponent::DefaultAcceptanceRadius, bool bUseNavAgentGoalLocation = true) const;
305
307 AIMODULE_API bool HasReached(const FAIMoveRequest& MoveRequest) const;
308
310 AIMODULE_API void SetBlockDetectionState(bool bEnable);
311
313 bool IsBlockDetectionActive() const { return bUseBlockDetection; }
314
316 AIMODULE_API void SetBlockDetection(float DistanceThreshold, float Interval, int32 NumSamples);
317
319 bool IsDecelerating() const { return bIsDecelerating; };
320
322 inline bool IsStopMovementOnFinishActive() const { return bStopMovementOnFinish; }
323
325 inline void SetStopMovementOnFinish(bool bEnable) { bStopMovementOnFinish = bEnable; }
326
328 AIMODULE_API void SetPreciseReachThreshold(float AgentRadiusMultiplier, float AgentHalfHeightMultiplier);
329
331 AIMODULE_API void SetLastMoveAtGoal(bool bFinishedAtGoal);
332
335 AIMODULE_API FVector::FReal GetRemainingPathCost() const;
336
338 AIMODULE_API FNavLocation GetCurrentNavLocation() const;
339
340 inline EPathFollowingStatus::Type GetStatus() const
341 {
343 return Status;
345 }
346 inline float GetAcceptanceRadius() const { return AcceptanceRadius; }
347 inline float GetDefaultAcceptanceRadius() const { return MyDefaultAcceptanceRadius; }
348 AIMODULE_API void SetAcceptanceRadius(const float InAcceptanceRadius);
349 inline AActor* GetMoveGoal() const { return DestinationActor.Get(); }
350 inline bool HasPartialPath() const { return Path.IsValid() && Path->IsPartial(); }
351 inline bool DidMoveReachGoal() const
352 {
354 return bLastMoveReachedGoal && (Status == EPathFollowingStatus::Idle);
356 }
357
358 inline FAIRequestID GetCurrentRequestId() const { return CurrentRequestId; }
359 inline uint32 GetCurrentPathIndex() const { return MoveSegmentStartIndex; }
360 inline uint32 GetNextPathIndex() const { return MoveSegmentEndIndex; }
361 inline UObject* GetCurrentCustomLinkOb() const { return CurrentCustomLinkOb.Get(); }
362 inline FVector GetCurrentTargetLocation() const { return *CurrentDestination; }
363 inline FBasedPosition GetCurrentTargetLocationBased() const { return CurrentDestination; }
364 inline FVector GetMoveGoalLocationOffset() const { return MoveOffset; }
365 bool HasStartedNavLinkMove() const { return bWalkingNavLinkStart; }
366 AIMODULE_API bool IsCurrentSegmentNavigationLink() const;
367 AIMODULE_API FVector GetCurrentDirection() const;
369 FVector GetCurrentMoveInput() const { return CurrentMoveInput; }
370
372 inline bool HasMovementAuthority() const { return (NavMovementInterface == nullptr) || NavMovementInterface->CanStopPathFollowing(); }
373
374 inline const FNavPathSharedPtr GetPath() const { return Path; }
375 inline bool HasValidPath() const { return Path.IsValid() && Path->IsValid(); }
376 AIMODULE_API bool HasDirectPath() const;
377
379 AIMODULE_API FString GetStatusDesc() const;
381 AIMODULE_API FString GetResultDesc(EPathFollowingResult::Type Result) const;
382
383 AIMODULE_API void SetDestinationActor(const AActor* InDestinationActor);
384
387 virtual int32 GetCurrentPathElement() const { return MoveSegmentEndIndex; }
388
389 AIMODULE_API virtual void GetDebugStringTokens(TArray<FString>& Tokens, TArray<EPathFollowingDebugTokens::Type>& Flags) const;
390 AIMODULE_API virtual FString GetDebugString() const;
391
392 AIMODULE_API virtual void DisplayDebug(UCanvas* Canvas, const FDebugDisplayInfo& DebugDisplay, float& YL, float& YPos) const;
393#if ENABLE_VISUAL_LOG
394 AIMODULE_API virtual void DescribeSelfToVisLog(struct FVisualLogEntry* Snapshot) const;
395#endif // ENABLE_VISUAL_LOG
396
398 UFUNCTION()
399 AIMODULE_API virtual void OnActorBump(AActor* SelfActor, AActor* OtherActor, FVector NormalImpulse, const FHitResult& Hit);
400
401 //~ IPathFollowingAgentInterface begin
402 AIMODULE_API virtual void OnUnableToMove(const UObject& Instigator) override;
403 AIMODULE_API virtual void OnStartedFalling() override;
404 virtual void OnLanded() override {}
405 AIMODULE_API virtual bool IsFollowingNavLink() const override;
406 //~ IPathFollowingAgentInterface end
407
409 AIMODULE_API virtual bool IsPathFollowingAllowed() const;
410
412 AIMODULE_API virtual void FinishUsingCustomLink(INavLinkCustomInterface* CustomNavLink);
413
415 virtual void OnPathfindingQuery(FPathFindingQuery& Query) {}
416
417 //~ IAIResourceInterface begin
418 AIMODULE_API virtual void LockResource(EAIRequestPriority::Type LockSource) override;
419 AIMODULE_API virtual void ClearResourceLock(EAIRequestPriority::Type LockSource) override;
420 AIMODULE_API virtual void ForceUnlockResource() override;
421 AIMODULE_API virtual bool IsResourceLocked() const override;
422 //~ IAIResourceInterface end
423
425 AIMODULE_API void OnPathEvent(FNavigationPath* InPath, ENavPathEvent::Type Event);
426
428 static AIMODULE_API void LogPathHelper(const AActor* LogOwner, FNavPathSharedPtr InLogPath, const AActor* LogGoalActor);
429 static AIMODULE_API void LogPathHelper(const AActor* LogOwner, FNavigationPath* InLogPath, const AActor* LogGoalActor);
430
431 UFUNCTION(BlueprintCallable, Category="AI|Components|PathFollowing", meta = (DeprecatedFunction, DeprecationMessage = "This function is now deprecated, please use AIController.GetMoveStatus instead"))
432 AIMODULE_API EPathFollowingAction::Type GetPathActionType() const;
433
434 UFUNCTION(BlueprintCallable, Category="AI|Components|PathFollowing", meta = (DeprecatedFunction, DeprecationMessage = "This function is now deprecated, please use AIController.GetImmediateMoveDestination instead"))
435 AIMODULE_API FVector GetPathDestination() const;
436
437#if WITH_EDITORONLY_DATA
438 // This delegate is now deprecated, please use OnRequestFinished instead
440#endif
441
442protected:
445
447 UE_DEPRECATED(5.5, "MovementComp is deprecated, please use NavMovementComp and the INavMoveInterface instead.")
448 UPROPERTY(transient, meta = (DeprecatedProperty, DeprecationMessage = "MovementComp is deprecated, please use NavMovementInterface and the INavMoveInterface instead."))
450
453
455 FWeakObjectPtr CurrentCustomLinkOb;
456
458 FWeakObjectPtr MoveSegmentCustomLinkOb;
459
463
466
469
471 float MyDefaultAcceptanceRadius;
472
478 float AcceptanceRadius;
479
481 float CurrentAcceptanceRadius;
482
484 float MinAgentRadiusPct;
485
487 float MinAgentHalfHeightPct;
488
490 float WaitingTimeout;
491
494
496 TWeakObjectPtr<AActor> DestinationActor;
497
499 const INavAgentInterface* DestinationAgent;
500
502 FBasedPosition CurrentDestination;
503
505 FVector CurrentMoveInput;
506
508 FVector MoveOffset;
509
511 FVector LocationWhenPaused;
512
517 FVector OriginalMoveRequestGoalLocation;
518
520 double PathTimeWhenPaused;
521
525 int32 PreciseAcceptanceRadiusCheckStartNodeIndex;
526
527 UE_DEPRECATED_FORGAME(5.6, "This member should no longer be accessed directly, please use GetStatus/SetStatus instead.")
530
532 uint8 bReachTestIncludesAgentRadius : 1;
533
535 uint8 bReachTestIncludesGoalRadius : 1;
536
538 uint8 bMoveToGoalOnLastSegment : 1;
539
543 uint8 bMoveToGoalClampedToNavigation : 1;
544
546 uint8 bUseBlockDetection : 1;
547
549 uint8 bCollidedWithGoal : 1;
550
552 uint8 bLastMoveReachedGoal : 1;
553
555 uint8 bStopMovementOnFinish : 1;
556
558 uint8 bIsUsingMetaPath : 1;
559
561 uint8 bWalkingNavLinkStart : 1;
562
564 uint8 bIsDecelerating : 1;
565
567 uint8 bMoveSegmentIsUsingCustomLinkReachCondition : 1;
568
573 uint8 bTickComponentOnlyWhenMoving : 1;
574
576 float BlockDetectionDistance;
577
579 float BlockDetectionInterval;
580
582 int32 BlockDetectionSampleCount;
583
585 double LastSampleTime;
586
588 int32 NextSampleIdx;
589
591 TArray<FBasedPosition> LocationSamples;
592
594 int32 MoveSegmentStartIndex;
595
597 int32 MoveSegmentEndIndex;
598
600 NavNodeRef MoveSegmentStartRef;
601
603 NavNodeRef MoveSegmentEndRef;
604
606 FVector MoveSegmentDirection;
607
609 float CachedBrakingDistance;
610
612 float CachedBrakingMaxSpeed;
613
615 int32 DecelerationSegmentIndex;
616
618 AIMODULE_API FSharedConstNavQueryFilter ExtractNavigationFilter(const FAIMoveRequest& RequestData, FNavPathSharedPtr InPath) const;
619
622
625 AIMODULE_API virtual void OnNewPawn(APawn* NewPawn);
626
628 AIMODULE_API virtual bool ShouldCheckPathOnResume() const;
629
631 AIMODULE_API virtual void SetMoveSegment(int32 SegmentStartIndex);
632
634 AIMODULE_API virtual void FollowPathSegment(float DeltaTime);
635
637 AIMODULE_API virtual void UpdatePathSegment();
638
641
643 AIMODULE_API virtual bool UpdateBlockDetection();
644
646 AIMODULE_API virtual void UpdateDecelerationData();
647
649 AIMODULE_API virtual bool HasReachedDestination(const FVector& CurrentLocation) const;
650
652 AIMODULE_API virtual bool HasReachedCurrentTarget(const FVector& CurrentLocation) const;
653
655 AIMODULE_API bool HasReachedInternal(const FVector& GoalLocation, float GoalRadius, float GoalHalfHeight, const FVector& AgentLocation, float RadiusThreshold, float AgentRadiusMultiplier) const;
656
658 AIMODULE_API void ResetMoveSegmentCustomLinkCache();
659
661 AIMODULE_API virtual bool IsOnPath() const;
662
664 AIMODULE_API bool IsBlocked() const;
665
667 inline void SetNextMoveSegment() { SetMoveSegment(GetNextPathIndex()); }
668
670 inline void StoreRequestId() { CurrentRequestId = UPathFollowingComponent::GetNextRequestId(); }
671
672 inline static uint32 GetNextRequestId() { return NextRequestId++; }
673
678 AIMODULE_API virtual int32 DetermineStartingPathPoint(const FNavigationPath* ConsideredPath) const;
679
681 AIMODULE_API virtual int32 DetermineCurrentTargetPathPoint(int32 StartIndex);
682
685 AIMODULE_API virtual bool UpdateMovementComponent(bool bForce = false);
686
689 AIMODULE_API virtual bool HandlePathUpdateEvent();
690
692 AIMODULE_API virtual void OnWaitingPathTimeout();
693
695 AIMODULE_API void ResetBlockDetectionData();
696
698 AIMODULE_API void ForceBlockDetectionUpdate();
699
701 AIMODULE_API virtual void UpdateMoveFocus();
702
704 AIMODULE_API virtual bool ShouldStopMovementOnPathFinished() const;
705
709 AIMODULE_API int32 FindPreciseAcceptanceRadiusTestsStartNodeIndex(const FNavigationPath& PathInstance, const FVector& GoalLocation) const;
710
714 AIMODULE_API float GetFinalAcceptanceRadius(const FNavigationPath& PathInstance, const FVector OriginalGoalLocation, const FVector* PathEndOverride = nullptr) const;
715
717 AIMODULE_API void DebugReachTest(float& CurrentDot, float& CurrentDistance, float& CurrentHeight, uint8& bDotFailed, uint8& bDistanceFailed, uint8& bHeightFailed) const;
718
721 AIMODULE_API virtual void OnNavigationInitDone();
722
726 UFUNCTION()
727 AIMODULE_API void OnNavDataRegistered(ANavigationData* NavData);
728
729
731 FAIResourceLock ResourceLock;
732
734 FTimerHandle WaitingForPathTimer;
735
736private:
737
740 static AIMODULE_API uint32 NextRequestId;
741 FAIRequestID CurrentRequestId;
742
746 mutable FNavLocation CurrentNavLocation;
747
748public:
752 static AIMODULE_API const float DefaultAcceptanceRadius;
753
754#if !UE_BUILD_SHIPPING
756#endif // !UE_BUILD_SHIPPING
757};
#define UE_DEPRECATED_FORGAME
Definition CoreMiscDefines.h:377
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define DECLARE_MULTICAST_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
Definition DelegateCombinations.h:58
#define DECLARE_DELEGATE_TwoParams(DelegateName, Param1Type, Param2Type)
Definition DelegateCombinations.h:57
#define DECLARE_DELEGATE_OneParam(DelegateName, Param1Type)
Definition DelegateCombinations.h:48
ELevelTick
Definition EngineBaseTypes.h:70
#define PRAGMA_ENABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:12
#define PRAGMA_DISABLE_DEPRECATION_WARNINGS
Definition GenericPlatformCompilerPreSetup.h:8
#define DECLARE_LOG_CATEGORY_EXTERN(CategoryName, DefaultVerbosity, CompileTimeVerbosity)
Definition LogMacros.h:361
uint64 NavNodeRef
Definition NavigationTypes.h:34
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define UFUNCTION(...)
Definition ObjectMacros.h:745
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
EPathFollowingVelocityMode
Definition PathFollowingComponent.h:195
EPathFollowingReachMode
Definition PathFollowingComponent.h:201
bool Failed
Definition binka_ue_decode_test.cpp:18
uint8_t uint8
Definition binka_ue_file_header.h:8
uint16_t uint16
Definition binka_ue_file_header.h:7
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Actor.h:257
Definition NavigationData.h:547
Definition Engine.Build.cs:7
Definition DisplayDebugHelpers.h:9
Definition UnrealType.h:3087
Definition AIResourceInterface.h:18
Definition NavAgentInterface.h:20
Definition NavLinkCustomInterface.h:40
Definition NavMovementInterface.h:26
Definition PathFollowingAgentInterface.h:21
Definition Array.h:670
Definition EnumAsByte.h:22
Definition ActorComponent.h:152
Definition Canvas.h:159
Definition NavMovementComponent.h:27
Definition Object.h:95
Definition PathFollowingComponent.h:217
void StoreRequestId()
Definition PathFollowingComponent.h:670
static AIMODULE_API const float DefaultAcceptanceRadius
Definition PathFollowingComponent.h:752
uint8 DEBUG_bMovingDirectlyToGoal
Definition PathFollowingComponent.h:755
static uint32 GetNextRequestId()
Definition PathFollowingComponent.h:672
Type
Definition AITypes.h:126
Definition PathFollowingComponent.h:142
Type
Definition PathFollowingComponent.h:144
@ PathToGoal
Definition PathFollowingComponent.h:149
@ NoMove
Definition PathFollowingComponent.h:146
@ PartialPath
Definition PathFollowingComponent.h:148
@ DirectMove
Definition PathFollowingComponent.h:147
Definition PathFollowingComponent.h:174
Type
Definition PathFollowingComponent.h:176
@ Description
Definition PathFollowingComponent.h:177
@ PassedValue
Definition PathFollowingComponent.h:180
@ FailedValue
Definition PathFollowingComponent.h:179
@ ParamName
Definition PathFollowingComponent.h:178
Definition PathFollowingComponent.h:186
Type
Definition PathFollowingComponent.h:188
@ NoPath
Definition PathFollowingComponent.h:189
@ OtherRequest
Definition PathFollowingComponent.h:190
Definition AIController.h:34
Type
Definition PathFollowingComponent.h:157
@ RequestSuccessful
Definition PathFollowingComponent.h:160
@ AlreadyAtGoal
Definition PathFollowingComponent.h:159
@ Failed
Definition PathFollowingComponent.h:158
Definition AIController.h:35
Type
Definition PathFollowingComponent.h:56
@ Success
Definition PathFollowingComponent.h:58
@ OffPath
Definition PathFollowingComponent.h:64
@ UMETA
Definition PathFollowingComponent.h:70
@ Blocked
Definition PathFollowingComponent.h:61
@ Aborted
Definition PathFollowingComponent.h:67
@ Invalid
Definition PathFollowingComponent.h:73
Definition AIController.h:36
Type
Definition PathFollowingComponent.h:37
@ Idle
Definition PathFollowingComponent.h:39
@ Waiting
Definition PathFollowingComponent.h:42
@ Paused
Definition PathFollowingComponent.h:45
@ Moving
Definition PathFollowingComponent.h:48
Definition PathFollowingComponent.h:78
const Type OwnerFinished
Definition PathFollowingComponent.h:96
const Type Success
Definition PathFollowingComponent.h:84
const Type None
Definition PathFollowingComponent.h:81
uint16 Type
Definition PathFollowingComponent.h:79
const Type InvalidPath
Definition PathFollowingComponent.h:99
const Type OffPath
Definition PathFollowingComponent.h:90
const Type FirstGameplayFlagShift
Definition PathFollowingComponent.h:114
const Type AlreadyAtGoal
Definition PathFollowingComponent.h:111
const Type Blocked
Definition PathFollowingComponent.h:87
FString ToString(uint16 Value)
Definition PathFollowingComponent.cpp:82
const Type ForcedScript
Definition PathFollowingComponent.h:108
const Type UserAbortFlagMask
Definition PathFollowingComponent.h:116
const Type MovementStop
Definition PathFollowingComponent.h:102
const Type NewRequest
Definition PathFollowingComponent.h:105
const Type UserAbort
Definition PathFollowingComponent.h:93
Definition AITypes.h:462
Definition AITypes.h:403
static AIMODULE_API const FAIRequestID CurrentRequest
Definition AITypes.h:452
Definition AITypes.h:329
Definition EngineBaseTypes.h:571
Definition EngineTypes.h:1918
Definition HitResult.h:21
Definition NavigationTypes.h:252
Definition NavigationData.h:87
Definition NavigationSystemTypes.h:62
Definition PathFollowingComponent.h:165
TEnumAsByte< EPathFollowingRequestResult::Type > Code
Definition PathFollowingComponent.h:167
FPathFollowingRequestResult()
Definition PathFollowingComponent.h:169
FAIRequestID MoveId
Definition PathFollowingComponent.h:166
Definition PathFollowingComponent.h:122
bool IsInterrupted() const
Definition PathFollowingComponent.h:134
AIMODULE_API FString ToString() const
Definition PathFollowingComponent.cpp:76
bool IsSuccess() const
Definition PathFollowingComponent.h:132
FPathFollowingResult()
Definition PathFollowingComponent.h:126
bool HasFlag(FPathFollowingResultFlags::Type Flag) const
Definition PathFollowingComponent.h:130
FPathFollowingResultFlags::Type Flags
Definition PathFollowingComponent.h:123
bool IsFailure() const
Definition PathFollowingComponent.h:133
TEnumAsByte< EPathFollowingResult::Type > Code
Definition PathFollowingComponent.h:124
Definition ResourceArray.h:31
Definition TimerHandle.h:12
Definition VisualLoggerTypes.h:205
Definition WeakObjectPtr.h:49
Definition ObjectPtr.h:488
Definition WeakInterfacePtr.h:18
Definition WeakObjectPtrTemplates.h:25
double FReal
Definition Vector.h:55