UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
CrowdFollowingComponent.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"
8#include "EngineDefines.h"
9#include "AITypes.h"
13#include "CrowdFollowingComponent.generated.h"
14
17class UCrowdManager;
18
20{
21 enum Type
22 {
27 };
28}
29
31{
32 Enabled,
33 ObstacleOnly, // Disabled, avoided by others
34 Disabled, // Disabled, ignored by others
35};
36
37UCLASS(BlueprintType, MinimalAPI)
39{
41
42 AIMODULE_API virtual void BeginDestroy() override;
43
44 // ICrowdAgentInterface BEGIN
45 AIMODULE_API virtual FVector GetCrowdAgentLocation() const override;
46 AIMODULE_API virtual FVector GetCrowdAgentVelocity() const override;
47 AIMODULE_API virtual void GetCrowdAgentCollisions(float& CylinderRadius, float& CylinderHalfHeight) const override;
48 AIMODULE_API virtual float GetCrowdAgentMaxSpeed() const override;
49 AIMODULE_API virtual int32 GetCrowdAgentAvoidanceGroup() const override;
50 AIMODULE_API virtual int32 GetCrowdAgentGroupsToAvoid() const override;
51 AIMODULE_API virtual int32 GetCrowdAgentGroupsToIgnore() const override;
52 // ICrowdAgentInterface END
53
54 // PathFollowingComponent BEGIN
55 AIMODULE_API virtual void Initialize() override;
56 AIMODULE_API virtual void Cleanup() override;
59 AIMODULE_API virtual void ResumeMove(FAIRequestID RequestID = FAIRequestID::CurrentRequest) override;
60 AIMODULE_API virtual FVector GetMoveFocus(bool bAllowStrafe) const override;
61 AIMODULE_API virtual void OnLanded() override;
62 AIMODULE_API virtual void FinishUsingCustomLink(INavLinkCustomInterface* CustomNavLink) override;
63 AIMODULE_API virtual void OnPathFinished(const FPathFollowingResult& Result) override;
64 AIMODULE_API virtual void OnPathUpdated() override;
65 AIMODULE_API virtual void OnPathfindingQuery(FPathFindingQuery& Query) override;
66 virtual int32 GetCurrentPathElement() const override { return LastPathPolyIndex; }
67 AIMODULE_API virtual void OnNavigationInitDone() override;
68 // PathFollowingComponent END
69
71 AIMODULE_API void UpdateCrowdAgentParams() const;
72
74 AIMODULE_API virtual void ApplyCrowdAgentVelocity(const FVector& NewVelocity, const FVector& DestPathCorner, bool bTraversingLink, bool bIsNearEndOfPath);
75
77 AIMODULE_API virtual void ApplyCrowdAgentPosition(const FVector& NewPosition);
78
80 UFUNCTION(BlueprintCallable, Category = "Crowd")
81 AIMODULE_API virtual void SuspendCrowdSteering(bool bSuspend);
82
84 AIMODULE_API virtual void SetCrowdSimulationState(ECrowdSimulationState NewState);
85
88
89 AIMODULE_API void SetCrowdAnticipateTurns(bool bEnable, bool bUpdateAgent = true);
90 AIMODULE_API void SetCrowdObstacleAvoidance(bool bEnable, bool bUpdateAgent = true);
91 AIMODULE_API void SetCrowdSeparation(bool bEnable, bool bUpdateAgent = true);
92 AIMODULE_API void SetCrowdOptimizeVisibility(bool bEnable, bool bUpdateAgent = true);
93 AIMODULE_API void SetCrowdOptimizeTopology(bool bEnable, bool bUpdateAgent = true);
94 AIMODULE_API void SetCrowdPathOffset(bool bEnable, bool bUpdateAgent = true);
95 AIMODULE_API void SetCrowdSlowdownAtGoal(bool bEnable, bool bUpdateAgent = true);
96 AIMODULE_API void SetCrowdSeparationWeight(float Weight, bool bUpdateAgent = true);
97 AIMODULE_API void SetCrowdCollisionQueryRange(float Range, bool bUpdateAgent = true);
98 AIMODULE_API void SetCrowdPathOptimizationRange(float Range, bool bUpdateAgent = true);
99 AIMODULE_API void SetCrowdAvoidanceQuality(ECrowdAvoidanceQuality::Type Quality, bool bUpdateAgent = true);
100 AIMODULE_API void SetCrowdAvoidanceRangeMultiplier(float Multiplier, bool bUpdateAgent = true);
101 AIMODULE_API void SetCrowdAffectFallingVelocity(bool bEnable);
102 AIMODULE_API void SetCrowdRotateToVelocity(bool bEnable);
103 AIMODULE_API void SetAvoidanceGroup(int32 GroupFlags, bool bUpdateAgent = true);
104 AIMODULE_API void SetGroupsToAvoid(int32 GroupFlags, bool bUpdateAgent = true);
105 AIMODULE_API void SetGroupsToIgnore(int32 GroupFlags, bool bUpdateAgent = true);
106
107 inline bool IsCrowdSimulationEnabled() const { return SimulationState == ECrowdSimulationState::Enabled; }
108 inline bool IsCrowdSimulatioSuspended() const { return bSuspendCrowdSimulation; }
109 inline bool IsCrowdAnticipateTurnsEnabled() const { return bEnableAnticipateTurns; }
110 inline bool IsCrowdObstacleAvoidanceEnabled() const { return bEnableObstacleAvoidance; }
111 inline bool IsCrowdSeparationEnabled() const { return bEnableSeparation; }
112 inline bool IsCrowdOptimizeVisibilityEnabled() const { return bEnableOptimizeVisibility; }
113 inline bool IsCrowdOptimizeTopologyEnabled() const { return bEnableOptimizeTopology; }
114 inline bool IsCrowdPathOffsetEnabled() const { return bEnablePathOffset; }
115 inline bool IsCrowdSlowdownAtGoalEnabled() const { return bEnableSlowdownAtGoal; }
116 inline bool IsCrowdAffectFallingVelocityEnabled() const { return bAffectFallingVelocity; }
117 inline bool IsCrowdRotateToVelocityEnabled() const { return bRotateToVelocity; }
118
119 inline ECrowdSimulationState GetCrowdSimulationState() const { return SimulationState; }
120 inline bool IsCrowdSimulationActive() const { return IsCrowdSimulationEnabled() && !IsCrowdSimulatioSuspended(); }
122 inline bool IsCrowdAnticipateTurnsActive() const { return IsCrowdAnticipateTurnsEnabled() && !IsCrowdSimulatioSuspended(); }
124 inline bool IsCrowdObstacleAvoidanceActive() const { return IsCrowdObstacleAvoidanceEnabled() && !IsCrowdSimulatioSuspended(); }
126 inline bool IsCrowdSeparationActive() const { return IsCrowdSeparationEnabled() && !IsCrowdSimulatioSuspended(); }
128 inline bool IsCrowdOptimizeTopologyActive() const { return IsCrowdOptimizeTopologyEnabled() && !IsCrowdSimulatioSuspended(); }
129
130 inline float GetCrowdSeparationWeight() const { return SeparationWeight; }
131 inline float GetCrowdCollisionQueryRange() const { return CollisionQueryRange; }
132 inline float GetCrowdPathOptimizationRange() const { return PathOptimizationRange; }
133 inline ECrowdAvoidanceQuality::Type GetCrowdAvoidanceQuality() const { return AvoidanceQuality; }
134 inline float GetCrowdAvoidanceRangeMultiplier() const { return AvoidanceRangeMultiplier; }
135 AIMODULE_API int32 GetAvoidanceGroup() const;
136 AIMODULE_API int32 GetGroupsToAvoid() const;
137 AIMODULE_API int32 GetGroupsToIgnore() const;
138
139 AIMODULE_API virtual void GetDebugStringTokens(TArray<FString>& Tokens, TArray<EPathFollowingDebugTokens::Type>& Flags) const override;
140#if ENABLE_VISUAL_LOG
141 AIMODULE_API virtual void DescribeSelfToVisLog(struct FVisualLogEntry* Snapshot) const override;
142#endif // ENABLE_VISUAL_LOG
143
144 UE_DEPRECATED_FORGAME(4.16, "Use ApplyCrowdAgentVelocity function with bIsNearEndOfPath param instead.")
145 virtual void ApplyCrowdAgentVelocity(const FVector& NewVelocity, const FVector& DestPathCorner, bool bTraversingLink) {}
146
147 AIMODULE_API void UpdateDestinationForMovingGoal(const FVector& NewDestination);
148
149protected:
150
152
153public:
154 UPROPERTY()
155 FVector CrowdAgentMoveDirection;
156
158#if WITH_EDITORONLY_DATA
160 UPROPERTY()
162
164 UPROPERTY()
166
168 UPROPERTY()
170#endif
171
174
177
180
183
186
194
197
200
203
206
208
211
215
218
221
224
225 // PathFollowingComponent BEGIN
226 AIMODULE_API virtual int32 DetermineStartingPathPoint(const FNavigationPath* ConsideredPath) const override;
227 AIMODULE_API virtual void SetMoveSegment(int32 SegmentStartIndex) override;
228 AIMODULE_API virtual void UpdatePathSegment() override;
229 AIMODULE_API virtual void FollowPathSegment(float DeltaTime) override;
230 AIMODULE_API virtual bool ShouldCheckPathOnResume() const override;
231 AIMODULE_API virtual bool IsOnPath() const override;
232 AIMODULE_API virtual bool UpdateMovementComponent(bool bForce) override;
233 AIMODULE_API virtual void Reset() override;
234 // PathFollowingComponent END
235
236 AIMODULE_API void SwitchToNextPathPart();
237 AIMODULE_API bool ShouldSwitchPathPart(int32 CorridorSize) const;
238 AIMODULE_API bool HasMovedDuringPause() const;
239 AIMODULE_API void UpdateCachedDirections(const FVector& NewVelocity, const FVector& NextPathCorner, bool bTraversingLink);
240
241 AIMODULE_API virtual bool ShouldTrackMovingGoal(FVector& OutGoalLocation) const;
242
243 AIMODULE_API void RegisterCrowdAgent();
244
246};
#define UE_DEPRECATED_FORGAME
Definition CoreMiscDefines.h:377
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
ECrowdSimulationState
Definition CrowdFollowingComponent.h:31
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
EPathFollowingVelocityMode
Definition PathFollowingComponent.h:195
@ Multiplier
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition CrowdAgentInterface.h:18
Definition NavLinkCustomInterface.h:40
Definition RVOAvoidanceInterface.h:23
Definition Array.h:670
Definition EnumAsByte.h:22
Definition CrowdFollowingComponent.h:39
uint8 bCanCheckMovingTooFar
Definition CrowdFollowingComponent.h:199
float CollisionQueryRange
Definition CrowdFollowingComponent.h:213
uint8 bEnableOptimizeVisibility
Definition CrowdFollowingComponent.h:190
friend UCrowdManager
Definition CrowdFollowingComponent.h:245
TEnumAsByte< ECrowdAvoidanceQuality::Type > AvoidanceQuality
Definition CrowdFollowingComponent.h:209
TWeakInterfacePtr< IRVOAvoidanceInterface > AvoidanceInterface
Definition CrowdFollowingComponent.h:151
int32 PathStartIndex
Definition CrowdFollowingComponent.h:220
uint8 bEnableSeparation
Definition CrowdFollowingComponent.h:189
float SeparationWeight
Definition CrowdFollowingComponent.h:212
uint8 bEnableSimulationReplanOnResume
Definition CrowdFollowingComponent.h:207
uint8 bFinalPathPart
Definition CrowdFollowingComponent.h:196
float PathOptimizationRange
Definition CrowdFollowingComponent.h:214
uint8 bEnableObstacleAvoidance
Definition CrowdFollowingComponent.h:188
uint8 bEnableOptimizeTopology
Definition CrowdFollowingComponent.h:191
uint8 bCanUpdatePathPartInTick
Definition CrowdFollowingComponent.h:202
uint8 bCheckMovementAngle
Definition CrowdFollowingComponent.h:205
ECrowdSimulationState SimulationState
Definition CrowdFollowingComponent.h:210
uint8 bRegisteredWithCrowdSimulation
Definition CrowdFollowingComponent.h:182
uint8 bSuspendCrowdSimulation
Definition CrowdFollowingComponent.h:185
uint8 bEnableSlowdownAtGoal
Definition CrowdFollowingComponent.h:193
uint8 bEnableAnticipateTurns
Definition CrowdFollowingComponent.h:187
int32 LastPathPolyIndex
Definition CrowdFollowingComponent.h:223
uint8 bEnablePathOffset
Definition CrowdFollowingComponent.h:192
float AvoidanceRangeMultiplier
Definition CrowdFollowingComponent.h:217
uint8 bAffectFallingVelocity
Definition CrowdFollowingComponent.h:173
uint8 bRotateToVelocity
Definition CrowdFollowingComponent.h:176
uint8 bUpdateDirectMoveVelocity
Definition CrowdFollowingComponent.h:179
Definition CrowdManager.h:174
Definition Object.h:95
Definition PathFollowingComponent.h:217
Definition CrowdFollowingComponent.h:20
Type
Definition CrowdFollowingComponent.h:22
@ Good
Definition CrowdFollowingComponent.h:25
@ Low
Definition CrowdFollowingComponent.h:23
@ High
Definition CrowdFollowingComponent.h:26
@ Medium
Definition CrowdFollowingComponent.h:24
uint16 Type
Definition PathFollowingComponent.h:79
Definition AITypes.h:403
static AIMODULE_API const FAIRequestID CurrentRequest
Definition AITypes.h:452
Definition NavigationAvoidanceTypes.h:13
Definition NavigationData.h:87
Definition NavigationSystemTypes.h:62
Definition PathFollowingComponent.h:122
Definition VisualLoggerTypes.h:205
Definition WeakInterfacePtr.h:18