UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AvoidanceManager.h
Go to the documentation of this file.
1// Copyright Epic Games, Inc. All Rights Reserved.
2
3#pragma once
4
5#if UE_ENABLE_INCLUDE_ORDER_DEPRECATED_IN_5_4
6#include "CoreMinimal.h"
7#endif
8#include "Stats/Stats.h"
10#include "UObject/Object.h"
11#include "Engine/EngineTypes.h"
12#include "Misc/CoreMisc.h"
14#include "AvoidanceManager.generated.h"
15
21
23
25
26USTRUCT()
28{
30
31
33
36
38 float RemainingTimeToLive;
39
41 float Radius;
42
44 float HalfHeight;
45
47 float Weight;
48
50 double OverrideWeightTime;
51
53 int32 GroupMask;
54
56 int32 GroupsToAvoid;
57
59 int32 GroupsToIgnore;
60
62 float TestRadius2D;
63
66
69 const FVector& InVelocity, float InWeight = 0.5f,
71 float InTestRadius2D = 500.0f);
72
73 inline bool ShouldBeIgnored() const
74 {
75 return (RemainingTimeToLive <= 0.0f);
76 }
77
79 {
80 return ((GroupsToAvoid& OtherGroupMask) == 0) || ((GroupsToIgnore & OtherGroupMask) != 0);
81 }
82};
83
85{
86 FPlane ConePlane[2]; //Left and right cone planes - these should point in toward each other. Technically, this is a convex hull, it's just unbounded.
87};
88
89UCLASS(config=Engine, Blueprintable, MinimalAPI)
91{
93
94
95 UPROPERTY(EditAnywhere, Category="Avoidance", config, meta=(ClampMin = "0.0"))
96 float DefaultTimeToLive;
97
99 UPROPERTY(EditAnywhere, Category="Avoidance", config, meta=(ClampMin = "0.0"))
100 float LockTimeAfterAvoid;
101
103 UPROPERTY(EditAnywhere, Category="Avoidance", config, meta=(ClampMin = "0.0"))
104 float LockTimeAfterClean;
105
107 UPROPERTY(EditAnywhere, Category="Avoidance", config, meta=(ClampMin = "0.0"))
108 float DeltaTimeToPredict;
109
111 UPROPERTY(EditAnywhere, Category="Avoidance", config, meta=(ClampMin = "0.0"))
112 float ArtificialRadiusExpansion;
113
115 UPROPERTY()
116 float TestHeightDifference_DEPRECATED;
117
119 UPROPERTY(EditAnywhere, Category="Avoidance", config, meta=(ClampMin = "0.0"))
120 float HeightCheckMargin;
121
123 UFUNCTION(BlueprintCallable, Category="AI")
124 ENGINE_API int32 GetObjectCount();
125
127 UFUNCTION(BlueprintCallable, Category="AI")
128 ENGINE_API int32 GetNewAvoidanceUID();
129
133 UFUNCTION(BlueprintCallable, Category="AI")
134 ENGINE_API bool RegisterMovementComponent(class UMovementComponent* MovementComp, float AvoidanceWeight = 0.5f);
135
136 ENGINE_API bool RegisterMovementComponent(UCharacterMovementComponent* MovementComp, float AvoidanceWeight = 0.5f);
137
139 FNavAvoidanceData* GetAvoidanceObjectForUID(int32 AvoidanceUID) { return AvoidanceObjects.Find(AvoidanceUID); }
140 const FNavAvoidanceData* GetAvoidanceObjectForUID(int32 AvoidanceUID) const { return AvoidanceObjects.Find(AvoidanceUID); }
141
143 UFUNCTION(BlueprintCallable, Category="AI")
144 ENGINE_API FVector GetAvoidanceVelocityForComponent(UMovementComponent* MovementComp);
145
148 ENGINE_API FVector GetAvoidanceVelocityForComponent(UCharacterMovementComponent* MovementComp);
149
151 ENGINE_API FVector GetAvoidanceVelocityIgnoringUID(const FNavAvoidanceData& AvoidanceData, float DeltaTime, int32 IgnoreThisUID);
152
154 ENGINE_API FVector GetAvoidanceVelocity(const FNavAvoidanceData& AvoidanceData, float DeltaTime);
155
157 ENGINE_API void UpdateRVO(UMovementComponent* MovementComp);
158
160 ENGINE_API void UpdateRVO(UCharacterMovementComponent* MovementComp);
161
163 ENGINE_API void OverrideToMaxWeight(int32 AvoidanceUID, float Duration);
164
165#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
166 ENGINE_API bool IsDebugOnForUID(int32 AvoidanceUID);
167 ENGINE_API bool IsDebugOnForAll();
168 ENGINE_API bool IsDebugEnabled(int32 AvoidanceUID);
169 ENGINE_API void AvoidanceDebugForUID(int32 AvoidanceUID, bool TurnOn);
170 ENGINE_API void AvoidanceDebugForAll(bool TurnOn);
171 static ENGINE_API void AvoidanceSystemToggle(bool TurnOn);
172
174 ENGINE_API void HandleToggleDebugAll( const TCHAR* Cmd, FOutputDevice& Ar );
175 ENGINE_API void HandleToggleAvoidance( const TCHAR* Cmd, FOutputDevice& Ar );
176#endif
177
178 ENGINE_API void SetNavEdgeProvider(INavEdgeProviderInterface* InEdgeProvider);
179
181 ENGINE_API void RemoveAvoidanceObject(const int32 AvoidanceUID);
182
184 bool IsAutoPurgeEnabled() const { return bAutoPurgeOutdatedObjects; }
185
186protected:
187 //~ Begin FExec Interface
188 ENGINE_API virtual bool Exec_Dev(UWorld* Inworld,const TCHAR* Cmd,FOutputDevice& Ar) override;
189 //~ End FExec Interface
190
193
195 ENGINE_API void RemoveOutdatedObjects();
196
198 ENGINE_API void RequestUpdateTimer();
199
201 ENGINE_API void UpdateRVO_Internal(int32 AvoidanceUID, const FNavAvoidanceData& AvoidanceData);
202
204 ENGINE_API FVector GetAvoidanceVelocity_Internal(const FNavAvoidanceData& AvoidanceData, float DeltaTime, int32 *IgnoreThisUID = NULL);
205
208
211
214
218
221
226
227 UE_DEPRECATED(5.3, "Please use bAutoPurgeOutdatedObjects instead.")
228 uint32 bAutoPurceOutdatedObjects : 1;
229
230#if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
234
237#endif
238};
#define NULL
Definition oodle2base.h:134
#define UE_DEPRECATED(Version, Message)
Definition CoreMiscDefines.h:302
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::TCHAR TCHAR
Either ANSICHAR or WIDECHAR, depending on whether the platform supports wide characters or the requir...
Definition Platform.h:1135
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define DECLARE_CYCLE_STAT_EXTERN(CounterName, StatId, GroupId, API)
Definition Stats.h:679
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
void Init()
Definition LockFreeList.h:4
#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 USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
uint32_t uint32
Definition binka_ue_file_header.h:6
Definition Engine.Build.cs:7
Definition OutputDevice.h:133
Definition CoreMisc.h:28
Definition NavEdgeProviderInterface.h:24
Definition RVOAvoidanceInterface.h:23
Definition Array.h:670
Definition UnrealString.h.inl:34
Definition AvoidanceManager.h:91
TArray< int32 > DebugUIDs
Definition AvoidanceManager.h:232
uint32 bAutoPurgeOutdatedObjects
Definition AvoidanceManager.h:225
TArray< FVelocityAvoidanceCone > AllCones
Definition AvoidanceManager.h:213
INavEdgeProviderInterface * EdgeProviderInterface
Definition AvoidanceManager.h:217
bool bDebugAll
Definition AvoidanceManager.h:233
TMap< int32, FNavAvoidanceData > AvoidanceObjects
Definition AvoidanceManager.h:207
TWeakObjectPtr< UObject > EdgeProviderOb
Definition AvoidanceManager.h:216
TArray< int32 > NewKeyPool
Definition AvoidanceManager.h:210
FTimerHandle TimerHandle_RemoveOutdatedObjects
Definition AvoidanceManager.h:192
uint32 bRequestedUpdateTimer
Definition AvoidanceManager.h:220
static ENGINE_API bool bSystemActive
Definition AvoidanceManager.h:236
Definition CharacterMovementComponent.h:136
Definition MovementComponent.h:71
Definition Object.h:95
Definition World.h:918
Definition AvoidanceManager.h:28
bool ShouldBeIgnored() const
Definition AvoidanceManager.h:73
bool ShouldIgnoreGroup(int32 OtherGroupMask) const
Definition AvoidanceManager.h:78
Definition TimerHandle.h:12
Definition AvoidanceManager.h:85
FPlane ConePlane[2]
Definition AvoidanceManager.h:86
Definition WeakObjectPtrTemplates.h:25