UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AnimStateMachineTypes.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"
6#include "Stats/Stats.h"
8#include "UObject/Object.h"
9#include "AlphaBlend.h"
10#include "BlendProfile.h"
11#include "AnimStateMachineTypes.generated.h"
12
13class UCurveFloat;
15
16UENUM(BlueprintType)
18{
19 Shared UMETA(ToolTip = "Only one transition can handle this request"),
20 Unique UMETA(ToolTip = "Allows multiple transitions to handle the same request"),
21};
22
23UENUM(BlueprintType)
25{
26 Append UMETA(ToolTip = "This request is added whether or not another with the same name is already queued"),
27 Ignore UMETA(ToolTip = "This request is ignored if another request with the same name is already queued"),
28 Overwrite UMETA(ToolTip = "This request overwrites another request with the same name if one exists")
29};
30
31//@TODO: Document
32UENUM()
34{
35 enum Type : int
36 {
37 TBM_Linear UMETA(DisplayName="Linear"),
38 TBM_Cubic UMETA(DisplayName="Cubic")
39 };
40}
41
42//@TODO: Document
43UENUM()
45{
46 enum Type : int
47 {
48 TLT_StandardBlend UMETA(DisplayName="Standard Blend", ToolTip="Blend smoothly from source state to destination state.\nBoth states update during the transition.\nFalls back to Inertialization on re-entry to an already active state when Fall Back to Inertialization is true."),
49 TLT_Inertialization UMETA(DisplayName = "Inertialization", ToolTip="Use inertialization to extrapolate when blending between states.\nOnly one state is active at a time.\nRequires an Inertialization or Dead Blending node rootwards of this node in the graph."),
50 TLT_Custom UMETA(DisplayName="Custom", ToolTip="Use a custom graph to define exactly how the blend works.")
51 };
52}
53
55{
58 double TimeToLive;
62
71
72 bool IsValidRequest() const
73 {
74 return TimeToLive > 0.0;
75 }
76
77 double GetRemainingTime() const
78 {
80 }
81
82 bool HasExpired() const
83 {
84 return GetRemainingTime() <= 0.0;
85 }
86
87 bool ToBeConsumed() const
88 {
89 if (QueueMode == ETransitionRequestQueueMode::Shared && ConsumedTransitions.Num() > 0)
90 {
91 return true;
92 }
93 return false;
94 }
95
96 bool HasBeenHandled() const
97 {
98 return ConsumedTransitions.Num() > 0;
99 }
100
101 FString ToDebugString() const
102 {
103 FString HandledByString = *FString::JoinBy(ConsumedTransitions, TEXT(", "), [](const int32& TransitionIndex) { return FString::Printf(TEXT("%d"), TransitionIndex); });
104 return FString::Printf(TEXT("%s (%.2fs) [Handled by: %s]"), *EventName.ToString(), GetRemainingTime(), *HandledByString);
105 }
106};
107
108// This structure represents a baked transition rule inside a state
109USTRUCT()
111{
113
114 UPROPERTY()
115 FName RuleToExecute;
116
118 UPROPERTY()
119 bool TransitionReturnVal;
120
121 UPROPERTY()
122 int32 TransitionIndex;
123
125 : TransitionReturnVal(true)
126 , TransitionIndex(INDEX_NONE)
127 {}
128
133};
134
135// This is the base class that both baked states and transitions use
136USTRUCT()
138{
140
141 // The name of this state
142 UPROPERTY()
143 FName StateName;
144
147};
148
149//
150USTRUCT()
152{
154
155 // Set of legal transitions out of this state; already in priority order
156 UPROPERTY()
158
159 // The root node index (into the AnimNodeProperties array of the UAnimBlueprintGeneratedClass)
160 UPROPERTY()
161 int32 StateRootNodeIndex;
162
163 // The index of the notify to fire when this state is first entered (weight within the machine becomes non-zero)
164 UPROPERTY()
165 int32 StartNotify;
166
167 // The index of the notify to fire when this state is finished exiting (weight within the machine becomes zero)
168 UPROPERTY()
169 int32 EndNotify;
170
171 // The index of the notify to fire when this state is fully entered (weight within the machine becomes one)
172 UPROPERTY()
173 int32 FullyBlendedNotify;
174
177 , StateRootNodeIndex(INDEX_NONE)
178 , StartNotify(INDEX_NONE)
179 , EndNotify(INDEX_NONE)
180 , FullyBlendedNotify(INDEX_NONE)
181 {}
182};
183
184// This represents a baked transition
185USTRUCT()
187{
189
190 UPROPERTY()
192
193 UPROPERTY()
195
196 // Transition-only: State being transitioned from
197 UPROPERTY()
198 int32 PreviousState;
199
200 // Transition-only: State being transitioned to
201 UPROPERTY()
202 int32 NextState;
203
204 UPROPERTY()
205 float CrossfadeDuration;
206
207 UPROPERTY()
208 float MinTimeBeforeReentry;
209
210 UPROPERTY()
211 int32 StartNotify;
212
213 UPROPERTY()
214 int32 EndNotify;
215
216 UPROPERTY()
217 int32 InterruptNotify;
218
219 UPROPERTY()
221
222 UPROPERTY()
224
225 UPROPERTY()
226 uint8 bAllowInertializationForSelfTransitions : 1;
227
228#if WITH_EDITORONLY_DATA
229 // This is only needed for the baking process, to denote which baked transitions need to reverse their prev/next state in the final step
231#endif
232
235 , CustomCurve(nullptr)
236 , BlendProfile(nullptr)
237 , PreviousState(INDEX_NONE)
238 , NextState(INDEX_NONE)
239 , CrossfadeDuration(-1.0f)
240 , MinTimeBeforeReentry(-1.0f)
241 , StartNotify(INDEX_NONE)
242 , EndNotify(INDEX_NONE)
243 , InterruptNotify(INDEX_NONE)
244 , BlendMode(EAlphaBlendOption::CubicInOut)
246 , bAllowInertializationForSelfTransitions(false)
249#endif
250 {}
251};
252
253
254USTRUCT()
256{
258
259 // The node property index for this rule
260 UPROPERTY()
261 int32 CanTakeDelegateIndex;
262
263 // The blend graph result node index
264 UPROPERTY()
265 int32 CustomResultNodeIndex;
266
267 // The index into the machine table of transitions
268 UPROPERTY()
269 int32 TransitionIndex;
270
271 // What the transition rule node needs to return to take this transition (for bidirectional transitions)
272 UPROPERTY()
273 bool bDesiredTransitionReturnValue;
274
275 // Automatic Transition Rule based on animation remaining time.
276 UPROPERTY()
277 bool bAutomaticRemainingTimeRule;
278
279 // Automatic Transition Rule triggering time:
280 // < 0 means trigger the transition 'Crossfade Duration' seconds before the end of the asset player, so a standard blend would finish just as the asset player ends
281 // >= 0 means trigger the transition 'Automatic Rule Trigger Time' seconds before the end of the asset player
282 UPROPERTY()
283 float AutomaticRuleTriggerTime;
284
285 // Additional rule around SyncGroup requiring Valid Markers
286 UPROPERTY()
287 FName SyncGroupNameToRequireValidMarkersRule;
288
289 UPROPERTY()
290 TArray<int32> PoseEvaluatorLinks;
291
293 : CanTakeDelegateIndex(INDEX_NONE)
294 , CustomResultNodeIndex(INDEX_NONE)
295 , TransitionIndex(INDEX_NONE)
296 , bDesiredTransitionReturnValue(true)
297 , bAutomaticRemainingTimeRule(false)
298 , AutomaticRuleTriggerTime(-1.f)
299 , SyncGroupNameToRequireValidMarkersRule(NAME_None)
300 {
301 }
302};
303
304
305//
306USTRUCT()
308{
310
311 // Indices into the property array for player nodes in the state
312 UPROPERTY()
313 TArray<int32> PlayerNodeIndices;
314
315 // Indices into the property array for layer nodes in the state
316 UPROPERTY()
317 TArray<int32> LayerNodeIndices;
318
319 // Set of legal transitions out of this state; already in priority order
320 UPROPERTY()
322
323 // The name of this state
324 UPROPERTY()
325 FName StateName;
326
327 // The root node index (into the AnimNodeProperties array of the UAnimBlueprintGeneratedClass)
328 UPROPERTY()
329 int32 StateRootNodeIndex;
330
331 UPROPERTY()
332 int32 StartNotify;
333
334 UPROPERTY()
335 int32 EndNotify;
336
337 UPROPERTY()
338 int32 FullyBlendedNotify;
339
340 UPROPERTY()
341 int32 EntryRuleNodeIndex;
342
343 // Whether or not this state will ALWAYS reset it's state on reentry, regardless of remaining weight
344 UPROPERTY()
345 bool bAlwaysResetOnEntry;
346
347 UPROPERTY()
348 bool bIsAConduit;
349
350public:
352 : StateRootNodeIndex(INDEX_NONE)
353 , StartNotify(INDEX_NONE)
354 , EndNotify(INDEX_NONE)
355 , FullyBlendedNotify(INDEX_NONE)
356 , EntryRuleNodeIndex(INDEX_NONE)
357 , bAlwaysResetOnEntry(false)
358 , bIsAConduit(false)
359 {}
360};
361
362USTRUCT()
364{
366
367 // Name of this machine (primarily for debugging purposes)
368 UPROPERTY()
369 FName MachineName;
370
371 // Index of the initial state that the machine will start in
372 UPROPERTY()
373 int32 InitialState;
374
375 // List of all states this machine can be in
376 UPROPERTY()
378
379 // List of all transitions between states
380 UPROPERTY()
382
383 // Cached StatID for this state machine
384 STAT(mutable TStatId StatID;)
385
386public:
388 : InitialState(INDEX_NONE)
389 {}
390
391 // Finds a state by name or INDEX_NONE if no such state exists
392 ENGINE_API int32 FindStateIndex(const FName& StateName) const;
393
394 // Find the index of a transition from StateNameFrom to StateNameTo
395 ENGINE_API int32 FindTransitionIndex(const FName& InStateNameFrom, const FName& InStateNameTo) const;
396 ENGINE_API int32 FindTransitionIndex(const int32 InStateIdxFrom, const int32 InStateIdxTo) const;
397
398#if STATS
400 inline TStatId GetStatID() const
401 {
402 if (!StatID.IsValidStat())
403 {
404 StatID = FDynamicStats::CreateStatId<FStatGroup_STATGROUP_Anim>(MachineName);
405 }
406 return StatID;
407 }
408#endif // STATS
409};
410
411UCLASS()
416
EAlphaBlendOption
Definition AlphaBlend.h:13
ETransitionRequestQueueMode
Definition AnimStateMachineTypes.h:18
ETransitionRequestOverwriteMode
Definition AnimStateMachineTypes.h:25
#define WITH_EDITOR
Definition Build.h:67
@ INDEX_NONE
Definition CoreMiscDefines.h:150
#define TEXT(x)
Definition Platform.h:1272
FPlatformTypes::int32 int32
A 32-bit signed integer.
Definition Platform.h:1125
#define STAT(x)
Definition Stats.h:44
UE_FORCEINLINE_HINT TSharedRef< CastToType, Mode > StaticCastSharedRef(TSharedRef< CastFromType, Mode > const &InSharedRef)
Definition SharedPointer.h:127
return true
Definition ExternalRpcRegistry.cpp:601
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_UCLASS_BODY(...)
Definition ObjectMacros.h:768
#define UCLASS(...)
Definition ObjectMacros.h:776
#define UENUM(...)
Definition ObjectMacros.h:749
#define USTRUCT(...)
Definition ObjectMacros.h:746
#define GENERATED_USTRUCT_BODY(...)
Definition ObjectMacros.h:767
if(Failed) console_printf("Failed.\n")
uint8_t uint8
Definition binka_ue_file_header.h:8
Definition NameTypes.h:617
CORE_API FString ToString() const
Definition UnrealNames.cpp:3537
Definition Array.h:670
Definition EnumAsByte.h:22
Definition AnimStateMachineTypes.h:413
Definition BlendProfile.h:132
Definition CurveFloat.h:31
Definition Object.h:95
Definition AnimStateMachineTypes.h:34
Type
Definition AnimStateMachineTypes.h:36
Definition AnimStateMachineTypes.h:45
Type
Definition AnimStateMachineTypes.h:47
@ false
Definition radaudio_common.h:23
static double Seconds()
Definition AndroidPlatformTime.h:20
Definition AnimStateMachineTypes.h:138
Definition AnimStateMachineTypes.h:152
Definition AnimStateMachineTypes.h:187
FAnimationTransitionBetweenStates()
Definition AnimStateMachineTypes.h:233
Definition AnimStateMachineTypes.h:111
FAnimationTransitionRule(int32 InTransitionState)
Definition AnimStateMachineTypes.h:129
Definition AnimStateMachineTypes.h:364
Definition AnimStateMachineTypes.h:308
Definition AnimStateMachineTypes.h:256
Definition AnimStateMachineTypes.h:55
double CreationTime
Definition AnimStateMachineTypes.h:57
double GetRemainingTime() const
Definition AnimStateMachineTypes.h:77
bool ToBeConsumed() const
Definition AnimStateMachineTypes.h:87
FName EventName
Definition AnimStateMachineTypes.h:59
FString ToDebugString() const
Definition AnimStateMachineTypes.h:101
FTransitionEvent(const FName &InEventName, const double InTimeToLive, const ETransitionRequestQueueMode &InQueueMode, const ETransitionRequestOverwriteMode &InOverwriteMode)
Definition AnimStateMachineTypes.h:63
ETransitionRequestQueueMode QueueMode
Definition AnimStateMachineTypes.h:60
bool IsValidRequest() const
Definition AnimStateMachineTypes.h:72
TArray< int32, TInlineAllocator< 8 > > ConsumedTransitions
Definition AnimStateMachineTypes.h:56
bool HasBeenHandled() const
Definition AnimStateMachineTypes.h:96
ETransitionRequestOverwriteMode OverwriteMode
Definition AnimStateMachineTypes.h:61
bool HasExpired() const
Definition AnimStateMachineTypes.h:82
double TimeToLive
Definition AnimStateMachineTypes.h:58
Definition ObjectPtr.h:488
Definition LightweightStats.h:416