UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
NavMovementComponent.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
7#pragma once
8
9#include "CoreMinimal.h"
12#include "Engine/EngineTypes.h"
13#include "GameFramework/Actor.h"
18#include "NavMovementComponent.generated.h"
19
21
25UCLASS(abstract, config=Engine, MinimalAPI)
27{
29
30protected:
32 UE_DEPRECATED(5.5, "FixedPathBrakingDistance is deprecated, please use NavMovementProperties.FixedPathBrakingDistance instead.")
33 UPROPERTY(meta = (DeprecatedProperty, DeprecationMessage = "FixedPathBrakingDistance is deprecated, please use NavMovementProperties.FixedPathBrakingDistance instead."))
34 float FixedPathBrakingDistance_DEPRECATED;
35
37 UE_DEPRECATED(5.5, "bUpdateNavAgentWithOwnersCollision is deprecated, please use NavMovementProperties.bUpdateNavAgentWithOwnersCollision instead.")
38 UPROPERTY(meta = (DeprecatedProperty, DeprecationMessage = "bUpdateNavAgentWithOwnersCollision is deprecated, please use NavMovementProperties.bUpdateNavAgentWithOwnersCollision instead."))
39 uint8 bUpdateNavAgentWithOwnersCollision_DEPRECATED:1;
40
42 UE_DEPRECATED(5.5, "bUseAccelerationForPaths is deprecated, please use NavMovementProperties.bUseAccelerationForPaths instead.")
43 UPROPERTY(GlobalConfig, meta = (DeprecatedProperty, DeprecationMessage = "bUseAccelerationForPaths is deprecated, please use NavMovementProperties.bUseAccelerationForPaths instead."))
44 uint8 bUseAccelerationForPaths_DEPRECATED : 1;
45
47 UE_DEPRECATED(5.5, "bUseFixedBrakingDistanceForPaths is deprecated, please use NavMovementProperties.bUseFixedBrakingDistanceForPaths instead.")
48 UPROPERTY(meta = (DeprecatedProperty, DeprecationMessage = "bUseFixedBrakingDistanceForPaths is deprecated, please use NavMovementProperties.bUseFixedBrakingDistanceForPaths instead."))
49 uint8 bUseFixedBrakingDistanceForPaths_DEPRECATED : 1;
50
52 UE_DEPRECATED(5.5, "bStopMovementAbortPaths is deprecated, please use NavMovementProperties.bStopMovementAbortPaths instead.")
53 uint8 bStopMovementAbortPaths_DEPRECATED:1;
54
55 UPROPERTY(EditAnywhere, Category = NavMovement)
56 FNavMovementProperties NavMovementProperties;
57
58public:
60 UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = NavMovement, meta = (DisplayName = "Movement Capabilities", Keywords = "Nav Agent"))
61 FNavAgentProperties NavAgentProps;
62
64 UPROPERTY()
65 FMovementProperties MovementState;
66
70 UPROPERTY()
71 TObjectPtr<UObject> PathFollowingComp;
72
73public:
75 virtual UObject* GetOwnerAsObject() const override { return GetOwner(); }
76
78 virtual TObjectPtr<UObject> GetUpdatedObject() const override { return UpdatedComponent; }
79
81 ENGINE_API virtual void GetSimpleCollisionCylinder(float& CollisionRadius, float& CollisionHalfHeight) const override;
82
84 ENGINE_API virtual FVector GetSimpleCollisionCylinderExtent() const override;
85
87 ENGINE_API virtual FVector GetForwardVector() const override;
88
90 UFUNCTION(BlueprintCallable, Category="AI|Components|NavMovement")
91 virtual FVector GetVelocityForNavMovement() const override { return Velocity; }
92
93 virtual float GetMaxSpeedForNavMovement() const override { return GetMaxSpeed(); }
94
95 // Overridden to also call StopActiveMovement().
96 virtual void StopMovementImmediately() override;
97
98 ENGINE_API void SetUpdateNavAgentWithOwnersCollisions(bool bUpdateWithOwner);
99 inline bool ShouldUpdateNavAgentWithOwnersCollision() const { return NavMovementProperties.bUpdateNavAgentWithOwnersCollision != 0; }
100
102 inline FVector GetActorLocation() const { return UpdatedComponent ? UpdatedComponent->GetComponentLocation() : FVector(FLT_MAX); }
104 virtual FVector GetActorFeetLocation() const { return UpdatedComponent ? (UpdatedComponent->GetComponentLocation() - FVector(0,0,UpdatedComponent->Bounds.BoxExtent.Z)) : FNavigationSystem::InvalidLocation; }
110 inline FTransform GetActorTransform() const { return UpdatedComponent ? UpdatedComponent->GetComponentTransform() : FTransform(); }
111
113 inline virtual FVector GetLocation() const override { return GetActorLocation(); }
115 virtual FVector GetFeetLocation() const override { return GetActorFeetLocation(); }
117 virtual FBasedPosition GetFeetLocationBased() const override { return GetActorFeetLocationBased(); };
118
119 ENGINE_API virtual void Serialize(FArchive& Ar) override;
120
121#if WITH_EDITOR
122 ENGINE_API virtual void PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent) override;
123#endif // WITH_EDITOR
124
126 ENGINE_API virtual void UpdateNavAgent(const UObject& ObjectToUpdateFrom) override;
127
129 ENGINE_API virtual void RequestDirectMove(const FVector& MoveVelocity, bool bForceMaxSpeed) override;
130
132 ENGINE_API virtual void RequestPathMove(const FVector& MoveInput) override;
133
136 ENGINE_API virtual bool CanStopPathFollowing() const override;
137
139 virtual FNavMovementProperties* GetNavMovementProperties() override { return &NavMovementProperties; }
141 virtual const FNavMovementProperties& GetNavMovementProperties() const override{ return NavMovementProperties; }
142
144 ENGINE_API void ClearFixedBrakingDistance();
145
148 virtual const IPathFollowingAgentInterface* GetPathFollowingAgent() const override { return Cast<const IPathFollowingAgentInterface>(PathFollowingComp); }
149
151 inline const FNavAgentProperties& GetNavAgentPropertiesRef() const override { return NavAgentProps; }
153 inline FNavAgentProperties& GetNavAgentPropertiesRef() override { return NavAgentProps; }
154
156 virtual void ResetMoveState() override { MovementState = NavAgentProps; }
157
159 virtual bool CanStartPathFollowing() const override { return true; }
160
162 inline bool IsJumpAllowed() const { return CanEverJump() && MovementState.bCanJump; }
163
165 inline void SetJumpAllowed(bool bAllowed) { MovementState.bCanJump = bAllowed; }
166
168 UFUNCTION(BlueprintCallable, Category="AI|Components|NavMovement")
169 virtual bool IsCrouching() const override;
170
172 UFUNCTION(BlueprintCallable, Category="AI|Components|NavMovement")
173 virtual bool IsFalling() const override;
174
176 UFUNCTION(BlueprintCallable, Category="AI|Components|NavMovement")
177 virtual bool IsMovingOnGround() const override;
178
180 UFUNCTION(BlueprintCallable, Category="AI|Components|NavMovement")
181 virtual bool IsSwimming() const override;
182
184 UFUNCTION(BlueprintCallable, Category="AI|Components|NavMovement")
185 virtual bool IsFlying() const override;
186};
187
188
189inline bool UNavMovementComponent::IsCrouching() const
190{
191 return false;
192}
193
195{
196 return false;
197}
198
200{
201 return false;
202}
203
205{
206 return false;
207}
208
210{
211 return false;
212}
213
215{
216 Super::StopMovementImmediately();
218}
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
#define FVector
Definition IOSSystemIncludes.h:8
UE::Math::TTransform< double > FTransform
Definition MathFwd.h:53
#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
USkinnedMeshComponent float
Definition SkinnedMeshComponent.h:60
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition Engine.Build.cs:7
Definition Archive.h:1208
Definition UnrealType.h:3087
Definition NavAgentInterface.h:20
Definition NavMovementInterface.h:26
virtual UE_API void StopActiveMovement()
Definition NavMovementInterface.cpp:9
Definition PathFollowingAgentInterface.h:21
Definition MovementComponent.h:71
Definition NavMovementComponent.h:27
virtual FVector GetActorFeetLocation() const
Definition NavMovementComponent.h:104
bool ShouldUpdateNavAgentWithOwnersCollision() const
Definition NavMovementComponent.h:99
virtual void StopMovementImmediately() override
Definition NavMovementComponent.h:214
FVector GetActorLocation() const
Definition NavMovementComponent.h:102
virtual ENGINE_API void Serialize(FArchive &Ar) override
FTransform GetActorTransform() const
Definition NavMovementComponent.h:110
const FNavAgentProperties & GetNavAgentPropertiesRef() const override
Definition NavMovementComponent.h:151
virtual bool IsFlying() const override
Definition NavMovementComponent.h:209
virtual FNavMovementProperties * GetNavMovementProperties() override
Definition NavMovementComponent.h:139
virtual FVector GetLocation() const override
Definition NavMovementComponent.h:113
virtual bool CanStartPathFollowing() const override
Definition NavMovementComponent.h:159
FVector GetActorNavLocation() const
Definition NavMovementComponent.h:108
virtual bool IsFalling() const override
Definition NavMovementComponent.h:194
virtual const IPathFollowingAgentInterface * GetPathFollowingAgent() const override
Definition NavMovementComponent.h:148
virtual ENGINE_API FBasedPosition GetActorFeetLocationBased() const
virtual FVector GetFeetLocation() const override
Definition NavMovementComponent.h:115
bool IsJumpAllowed() const
Definition NavMovementComponent.h:162
virtual FBasedPosition GetFeetLocationBased() const override
Definition NavMovementComponent.h:117
void SetJumpAllowed(bool bAllowed)
Definition NavMovementComponent.h:165
virtual bool IsMovingOnGround() const override
Definition NavMovementComponent.h:199
virtual TObjectPtr< UObject > GetUpdatedObject() const override
Definition NavMovementComponent.h:78
virtual void SetPathFollowingAgent(IPathFollowingAgentInterface *InPathFollowingAgent) override
Definition NavMovementComponent.h:146
virtual bool IsSwimming() const override
Definition NavMovementComponent.h:204
virtual float GetMaxSpeedForNavMovement() const override
Definition NavMovementComponent.h:93
virtual IPathFollowingAgentInterface * GetPathFollowingAgent() override
Definition NavMovementComponent.h:147
virtual void ResetMoveState() override
Definition NavMovementComponent.h:156
FNavAgentProperties & GetNavAgentPropertiesRef() override
Definition NavMovementComponent.h:153
virtual const FNavMovementProperties & GetNavMovementProperties() const override
Definition NavMovementComponent.h:141
Definition Object.h:95
constexpr FVector InvalidLocation
Definition NavigationTypes.h:47
Definition EngineTypes.h:1918
Definition NavigationTypes.h:388
Definition NavigationTypes.h:453
Definition NavigationTypes.h:426
Definition UnrealType.h:6865
Definition ObjectPtr.h:488