UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
AnimNode_BlendSpacePlayer.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"
9#include "AnimNode_BlendSpacePlayer.generated.h"
10
11class UBlendSpace;
12
13//@TODO: Comment
14USTRUCT(BlueprintInternalUseOnly)
16{
18
19protected:
20 // Filter used to dampen coordinate changes
22
23 // Cache of samples used to determine blend weights
25
27 int32 CachedTriangulationIndex = -1;
28
30 TObjectPtr<UBlendSpace> PreviousBlendSpace = nullptr;
31
32public:
33
34 // FAnimNode_AssetPlayerBase interface
35 ANIMGRAPHRUNTIME_API virtual float GetCurrentAssetTime() const override;
36 ANIMGRAPHRUNTIME_API virtual float GetCurrentAssetTimePlayRateAdjusted() const override;
37 ANIMGRAPHRUNTIME_API virtual float GetCurrentAssetLength() const override;
39 // End of FAnimNode_AssetPlayerBase interface
40
41 // FAnimNode_Base interface
46 ANIMGRAPHRUNTIME_API virtual void GatherDebugData(FNodeDebugData& DebugData) override;
47 // End of FAnimNode_Base interface
48
49 // Get the amount of time from the end
50 ANIMGRAPHRUNTIME_API float GetTimeFromEnd(float CurrentTime) const;
51
52 // @return the current sample coordinates after going through the filtering
53 FVector GetFilteredPosition() const { return BlendFilter.GetFilterLastOutput(); }
54
55 // Forces the Position to the specified value
56 ANIMGRAPHRUNTIME_API void SnapToPosition(const FVector& NewPosition);
57
58public:
59
60 // Get the blendspace asset to play
61 virtual UBlendSpace* GetBlendSpace() const PURE_VIRTUAL(FAnimNode_BlendSpacePlayerBase::GetBlendSpace, return nullptr;);
62
63 // Get the coordinates that are currently being sampled by the blendspace
64 virtual FVector GetPosition() const PURE_VIRTUAL(FAnimNode_BlendSpacePlayerBase::GetPosition, return FVector::Zero(););
65
66 // The start position in [0, 1] to use when initializing. When looping, play will still jump back to the beginning when reaching the end.
67 virtual float GetStartPosition() const PURE_VIRTUAL(FAnimNode_BlendSpacePlayerBase::GetStartPosition, return 0.0f;);
68
69 // Get the play rate multiplier. Can be negative, which will cause the animation to play in reverse.
70 virtual float GetPlayRate() const PURE_VIRTUAL(FAnimNode_BlendSpacePlayerBase::GetPlayRate, return 1.0f;);
71
72 // Should the animation loop back to the start when it reaches the end?
73 UE_DEPRECATED(5.3, "Please use IsLooping instead.")
74 virtual bool GetLoop() const final { return IsLooping(); }
75
76 // Get whether we should reset the current play time when the blend space changes
77 virtual bool ShouldResetPlayTimeWhenBlendSpaceChanges() const PURE_VIRTUAL(FAnimNode_BlendSpacePlayerBase::ShouldResetPlayTimeWhenBlendSpaceChanges, return true;);
78
79 // Set whether we should reset the current play time when the blend space changes
80 virtual bool SetResetPlayTimeWhenBlendSpaceChanges(bool bReset) PURE_VIRTUAL(FAnimNode_BlendSpacePlayerBase::SetResetPlayTimeWhenBlendSpaceChanges, return false;);
81
82 // An evaluator will be setting the play rate to zero and setting the time explicitly. ShouldTeleportToTime indicates whether we should jump to that time, or move to it playing out root motion and events etc.
83 virtual bool ShouldTeleportToTime() const { return false; }
84
85 // Indicates if we are an evaluator - i.e. will be setting the time explicitly rather than letting it play out
86 virtual bool IsEvaluator() const { return false; }
87
88 // Set the blendspace asset to play
90
91 // Set the coordinates that are currently being sampled by the blendspace
93
94 // Set the play rate multiplier. Can be negative, which will cause the animation to play in reverse.
96
97 // Set if the animation should loop back to the start when it reaches the end?
99
100protected:
101 ANIMGRAPHRUNTIME_API void UpdateInternal(const FAnimationUpdateContext& Context);
102
103private:
104 ANIMGRAPHRUNTIME_API void Reinitialize(bool bResetTime = true);
105
106 ANIMGRAPHRUNTIME_API const FBlendSampleData* GetHighestWeightedSample() const;
107};
108
109template<>
111{
112 enum
113 {
115 };
116};
117
118
119//@TODO: Comment
120USTRUCT(BlueprintInternalUseOnly)
122{
124
125 friend class UAnimGraphNode_BlendSpaceBase;
126 friend class UAnimGraphNode_BlendSpacePlayer;
127 friend class UAnimGraphNode_BlendSpaceEvaluator;
128 friend class UAnimGraphNode_RotationOffsetBlendSpace;
129 friend class UAnimGraphNode_AimOffsetLookAt;
130
131private:
132
133#if WITH_EDITORONLY_DATA
134 // The group name that we synchronize with (NAME_None if it is not part of any group). Note that
135 // this is the name of the group used to sync the output of this node - it will not force
136 // syncing of animations contained by it.
137 UPROPERTY(EditAnywhere, Category = Sync, meta = (FoldProperty))
138 FName GroupName = NAME_None;
139
140 // The role this node can assume within the group (ignored if GroupName is not set). Note
141 // that this is the role of the output of this node, not of animations contained by it.
142 UPROPERTY(EditAnywhere, Category = Sync, meta = (FoldProperty))
143 TEnumAsByte<EAnimGroupRole::Type> GroupRole = EAnimGroupRole::CanBeLeader;
144
145 // When enabled, acting as the leader, and using marker-based sync, this asset player will not sync to the previous leader's sync position when joining a sync group and before becoming the leader but instead force everyone else to match its position.
146 UPROPERTY(EditAnywhere, Category = Sync, meta = (FoldProperty, EditCondition = "GroupRole != EAnimGroupRole::TransitionFollower && GroupRole != EAnimGroupRole::AlwaysFollower", EditConditionHides))
147 bool bOverridePositionWhenJoiningSyncGroupAsLeader = false;
148
149 // How this node will synchronize with other animations. Note that this determines how the output
150 // of this node is used for synchronization, not of animations contained by it.
151 UPROPERTY(EditAnywhere, Category = Sync, meta = (FoldProperty))
153
154 // If true, "Relevant anim" nodes that look for the highest weighted animation in a state will ignore this node
155 UPROPERTY(EditAnywhere, Category = Relevancy, meta = (FoldProperty, PinHiddenByDefault))
156 bool bIgnoreForRelevancyTest = false;
157
158 // The X coordinate to sample in the blendspace
159 UPROPERTY(EditAnywhere, Category = Coordinates, meta = (PinShownByDefault, FoldProperty))
160 float X = 0.0f;
161
162 // The Y coordinate to sample in the blendspace
163 UPROPERTY(EditAnywhere, Category = Coordinates, meta = (PinShownByDefault, FoldProperty))
164 float Y = 0.0f;
165
166 // The play rate multiplier. Can be negative, which will cause the animation to play in reverse.
167 UPROPERTY(EditAnywhere, Category = Settings, meta = (DefaultValue = "1.0", PinHiddenByDefault, FoldProperty))
168 float PlayRate = 1.0f;
169
170 // Should the animation loop back to the start when it reaches the end?
171 UPROPERTY(EditAnywhere, Category = Settings, meta = (DefaultValue = "true", PinHiddenByDefault, FoldProperty))
172 bool bLoop = true;
173
174 // Whether we should reset the current play time when the blend space changes
175 UPROPERTY(EditAnywhere, Category = Settings, meta = (PinHiddenByDefault, FoldProperty))
176 bool bResetPlayTimeWhenBlendSpaceChanges = true;
177
178 // The start position in [0, 1] to use when initializing. When looping, play will still jump back to the beginning when reaching the end.
179 UPROPERTY(EditAnywhere, Category = Settings, meta = (DefaultValue = "0.f", PinHiddenByDefault, FoldProperty))
180 float StartPosition = 0.0f;
181#endif
182
183 // The blendspace asset to play
184 UPROPERTY(EditAnywhere, Category = Settings, meta = (PinHiddenByDefault))
185 TObjectPtr<UBlendSpace> BlendSpace = nullptr;
186
187public:
188
189 // FAnimNode_AssetPlayerBase interface
190 ANIMGRAPHRUNTIME_API virtual FName GetGroupName() const override;
191 ANIMGRAPHRUNTIME_API virtual EAnimGroupRole::Type GetGroupRole() const override;
192 ANIMGRAPHRUNTIME_API virtual bool GetOverridePositionWhenJoiningSyncGroupAsLeader() const override;
193 ANIMGRAPHRUNTIME_API virtual EAnimSyncMethod GetGroupMethod() const override;
194 ANIMGRAPHRUNTIME_API virtual bool GetIgnoreForRelevancyTest() const override;
195 ANIMGRAPHRUNTIME_API virtual bool IsLooping() const override;
196 ANIMGRAPHRUNTIME_API virtual bool SetGroupName(FName InGroupName) override;
197 ANIMGRAPHRUNTIME_API virtual bool SetGroupRole(EAnimGroupRole::Type InRole) override;
198 ANIMGRAPHRUNTIME_API virtual bool SetOverridePositionWhenJoiningSyncGroupAsLeader(bool InOverridePositionWhenJoiningSyncGroupAsLeader) override;;
199 ANIMGRAPHRUNTIME_API virtual bool SetGroupMethod(EAnimSyncMethod InMethod) override;
200 ANIMGRAPHRUNTIME_API virtual bool SetIgnoreForRelevancyTest(bool bInIgnoreForRelevancyTest) override;
201 // End of FAnimNode_AssetPlayerBase interface
202
203 // FAnimNode_BlendSpacePlayerBase interface
204 ANIMGRAPHRUNTIME_API virtual UBlendSpace* GetBlendSpace() const override;
205 ANIMGRAPHRUNTIME_API virtual FVector GetPosition() const override;
206 ANIMGRAPHRUNTIME_API virtual float GetStartPosition() const override;
207 ANIMGRAPHRUNTIME_API virtual float GetPlayRate() const override;
208 ANIMGRAPHRUNTIME_API virtual bool ShouldResetPlayTimeWhenBlendSpaceChanges() const override;
209 ANIMGRAPHRUNTIME_API virtual bool SetResetPlayTimeWhenBlendSpaceChanges(bool bReset) override;
210 ANIMGRAPHRUNTIME_API virtual bool SetBlendSpace(UBlendSpace* InBlendSpace) override;
211 ANIMGRAPHRUNTIME_API virtual bool SetPosition(FVector InPosition) override;
212 ANIMGRAPHRUNTIME_API virtual bool SetPlayRate(float InPlayRate) override;
213 ANIMGRAPHRUNTIME_API virtual bool SetLoop(bool bInLoop) override;
214 // End of FAnimNode_BlendSpacePlayerBase interface
215};
216
217//@TODO: Comment
218USTRUCT(BlueprintInternalUseOnly)
220{
222
223private:
224
225 // The group name that we synchronize with (NAME_None if it is not part of any group). Note that
226 // this is the name of the group used to sync the output of this node - it will not force
227 // syncing of animations contained by it. Animations inside this Blend Space have their own
228 // options for syncing.
229 UPROPERTY(EditAnywhere, Category = Sync)
230 FName GroupName = NAME_None;
231
232 // The role this Blend Space can assume within the group (ignored if GroupName is not set). Note
233 // that this is the role of the output of this node, not of animations contained by it.
234 UPROPERTY(EditAnywhere, Category = Sync)
235 TEnumAsByte<EAnimGroupRole::Type> GroupRole = EAnimGroupRole::CanBeLeader;
236
237 // When enabled, acting as the leader, and using marker-based sync, this asset player will not sync to the previous leader's sync position when joining a sync group and before becoming the leader but instead force everyone else to match its position.
238 UPROPERTY(EditAnywhere, Category = Sync, meta = (EditCondition = "GroupRole != EAnimGroupRole::TransitionFollower && GroupRole != EAnimGroupRole::AlwaysFollower", EditConditionHides))
239 bool bOverridePositionWhenJoiningSyncGroupAsLeader = false;
240
241 // How this asset will synchronize with other assets. Note that this determines how the output
242 // of this node is used for synchronization, not of animations contained by it.
243 UPROPERTY(EditAnywhere, Category = Sync)
245
246 // If true, "Relevant anim" nodes that look for the highest weighted animation in a state will ignore this node
247 UPROPERTY(EditAnywhere, Category = Relevancy, meta = (PinHiddenByDefault))
248 bool bIgnoreForRelevancyTest = false;
249
250 // The X coordinate to sample in the blendspace
251 UPROPERTY(EditAnywhere, Category = Coordinates, meta = (PinShownByDefault))
252 float X = 0.0f;
253
254 // The Y coordinate to sample in the blendspace
255 UPROPERTY(EditAnywhere, Category = Coordinates, meta = (PinShownByDefault))
256 float Y = 0.0f;
257
258 // The play rate multiplier. Can be negative, which will cause the animation to play in reverse.
259 UPROPERTY(EditAnywhere, Category = Settings, meta = (DefaultValue = "1.0", PinHiddenByDefault))
260 float PlayRate = 1.0f;
261
262 // Should the animation loop back to the start when it reaches the end?
263 UPROPERTY(EditAnywhere, Category = Settings, meta = (DefaultValue = "true", PinHiddenByDefault))
264 bool bLoop = true;
265
266 // Whether we should reset the current play time when the blend space changes
267 UPROPERTY(EditAnywhere, Category = Settings, meta = (PinHiddenByDefault))
268 bool bResetPlayTimeWhenBlendSpaceChanges = true;
269
270 // The start position in [0, 1] to use when initializing. When looping, play will still jump back to the beginning when reaching the end.
271 UPROPERTY(EditAnywhere, Category = Settings, meta = (DefaultValue = "0.f", PinHiddenByDefault))
272 float StartPosition = 0.0f;
273
274 // The blendspace asset to play
275 UPROPERTY(EditAnywhere, Category = Settings, meta = (PinHiddenByDefault))
276 TObjectPtr<UBlendSpace> BlendSpace = nullptr;
277
278public:
279
280 // FAnimNode_AssetPlayerBase interface
281 virtual FName GetGroupName() const override { return GroupName; }
282 virtual EAnimGroupRole::Type GetGroupRole() const override { return GroupRole; }
283 virtual EAnimSyncMethod GetGroupMethod() const override { return Method; }
284 virtual bool GetOverridePositionWhenJoiningSyncGroupAsLeader() const override { return bOverridePositionWhenJoiningSyncGroupAsLeader; };
285 virtual bool GetIgnoreForRelevancyTest() const override { return bIgnoreForRelevancyTest; }
286 virtual bool IsLooping() const override { return bLoop; }
287 virtual bool SetGroupName(FName InGroupName) override { GroupName = InGroupName; return true; }
288 virtual bool SetGroupRole(EAnimGroupRole::Type InRole) override { GroupRole = InRole; return true; }
289 virtual bool SetGroupMethod(EAnimSyncMethod InMethod) override { Method = InMethod; return true; }
290 virtual bool SetOverridePositionWhenJoiningSyncGroupAsLeader(bool InOverridePositionWhenJoiningSyncGroupAsLeader) override { bOverridePositionWhenJoiningSyncGroupAsLeader = InOverridePositionWhenJoiningSyncGroupAsLeader; return true; };
291 virtual bool SetIgnoreForRelevancyTest(bool bInIgnoreForRelevancyTest) override { bIgnoreForRelevancyTest = bInIgnoreForRelevancyTest; return true; }
292 // End of FAnimNode_AssetPlayerBase interface
293
294 // FAnimNode_BlendSpacePlayerBase interface
295 virtual UBlendSpace* GetBlendSpace() const override { return BlendSpace; }
296 virtual FVector GetPosition() const override { return FVector(X, Y, 0.0); }
297 virtual float GetStartPosition() const override { return StartPosition; }
298 virtual float GetPlayRate() const override { return PlayRate; }
299 virtual bool ShouldResetPlayTimeWhenBlendSpaceChanges() const override { return bResetPlayTimeWhenBlendSpaceChanges; }
300 virtual bool SetResetPlayTimeWhenBlendSpaceChanges(bool bReset) override { bResetPlayTimeWhenBlendSpaceChanges = bReset; return true; }
301 virtual bool SetBlendSpace(UBlendSpace* InBlendSpace) override { BlendSpace = InBlendSpace; return true; }
302 virtual bool SetPosition(FVector InPosition) override { X = static_cast<float>(InPosition[0]); Y = static_cast<float>(InPosition[1]); return true; }
303 virtual bool SetPlayRate(float InPlayRate) override { PlayRate = InPlayRate; return true; }
304 virtual bool SetLoop(bool bInLoop) override { bLoop = bInLoop; return true; }
305 // End of FAnimNode_BlendSpacePlayerBase interface
306};
EAnimSyncMethod
Definition AnimationAsset.h:629
#define PURE_VIRTUAL(func,...)
Definition CoreMiscDefines.h:103
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
return true
Definition ExternalRpcRegistry.cpp:601
#define X(Name, Desc)
Definition FormatStringSan.h:47
#define FVector
Definition IOSSystemIncludes.h:8
#define UPROPERTY(...)
UObject definition macros.
Definition ObjectMacros.h:744
#define GENERATED_BODY(...)
Definition ObjectMacros.h:765
#define USTRUCT(...)
Definition ObjectMacros.h:746
Definition NameTypes.h:617
Definition UnrealType.h:3087
Definition Array.h:670
Definition EnumAsByte.h:22
Definition AnimationAsset.h:1020
Definition BlendSpace.h:467
@ false
Definition radaudio_common.h:23
Definition AnimNode_AssetPlayerBase.h:15
Definition AnimNode_BlendSpacePlayer.h:16
FBlendFilter BlendFilter
Definition AnimNode_BlendSpacePlayer.h:21
virtual bool IsEvaluator() const
Definition AnimNode_BlendSpacePlayer.h:86
virtual bool SetPlayRate(float InPlayRate) PURE_VIRTUAL(FAnimNode_BlendSpacePlayerBase
Definition AnimNode_BlendSpacePlayer.h:95
virtual bool SetPosition(FVector InPosition) PURE_VIRTUAL(FAnimNode_BlendSpacePlayerBase
Definition AnimNode_BlendSpacePlayer.h:92
virtual bool SetBlendSpace(UBlendSpace *InBlendSpace) PURE_VIRTUAL(FAnimNode_BlendSpacePlayerBase
Definition AnimNode_BlendSpacePlayer.h:89
TArray< FBlendSampleData > BlendSampleDataCache
Definition AnimNode_BlendSpacePlayer.h:24
virtual bool SetLoop(bool bInLoop) PURE_VIRTUAL(FAnimNode_BlendSpacePlayerBase
Definition AnimNode_BlendSpacePlayer.h:98
virtual bool ShouldResetPlayTimeWhenBlendSpaceChanges() const PURE_VIRTUAL(FAnimNode_BlendSpacePlayerBase
Definition AnimNode_BlendSpacePlayer.h:77
virtual UBlendSpace * GetBlendSpace() const PURE_VIRTUAL(FAnimNode_BlendSpacePlayerBase
Definition AnimNode_BlendSpacePlayer.h:61
Definition AnimNode_BlendSpacePlayer.h:220
virtual bool IsLooping() const override
Definition AnimNode_BlendSpacePlayer.h:286
virtual UBlendSpace * GetBlendSpace() const override
Definition AnimNode_BlendSpacePlayer.h:295
virtual bool SetPosition(FVector InPosition) override
Definition AnimNode_BlendSpacePlayer.h:302
virtual bool SetGroupName(FName InGroupName) override
Definition AnimNode_BlendSpacePlayer.h:287
virtual bool SetGroupMethod(EAnimSyncMethod InMethod) override
Definition AnimNode_BlendSpacePlayer.h:289
virtual bool SetResetPlayTimeWhenBlendSpaceChanges(bool bReset) override
Definition AnimNode_BlendSpacePlayer.h:300
virtual bool ShouldResetPlayTimeWhenBlendSpaceChanges() const override
Definition AnimNode_BlendSpacePlayer.h:299
virtual FName GetGroupName() const override
Definition AnimNode_BlendSpacePlayer.h:281
virtual bool GetIgnoreForRelevancyTest() const override
Definition AnimNode_BlendSpacePlayer.h:285
virtual bool SetOverridePositionWhenJoiningSyncGroupAsLeader(bool InOverridePositionWhenJoiningSyncGroupAsLeader) override
Definition AnimNode_BlendSpacePlayer.h:290
virtual EAnimGroupRole::Type GetGroupRole() const override
Definition AnimNode_BlendSpacePlayer.h:282
virtual float GetPlayRate() const override
Definition AnimNode_BlendSpacePlayer.h:298
virtual bool GetOverridePositionWhenJoiningSyncGroupAsLeader() const override
Definition AnimNode_BlendSpacePlayer.h:284
virtual bool SetLoop(bool bInLoop) override
Definition AnimNode_BlendSpacePlayer.h:304
virtual float GetStartPosition() const override
Definition AnimNode_BlendSpacePlayer.h:297
virtual FVector GetPosition() const override
Definition AnimNode_BlendSpacePlayer.h:296
virtual bool SetGroupRole(EAnimGroupRole::Type InRole) override
Definition AnimNode_BlendSpacePlayer.h:288
virtual bool SetPlayRate(float InPlayRate) override
Definition AnimNode_BlendSpacePlayer.h:303
virtual EAnimSyncMethod GetGroupMethod() const override
Definition AnimNode_BlendSpacePlayer.h:283
virtual bool SetIgnoreForRelevancyTest(bool bInIgnoreForRelevancyTest) override
Definition AnimNode_BlendSpacePlayer.h:291
virtual bool SetBlendSpace(UBlendSpace *InBlendSpace) override
Definition AnimNode_BlendSpacePlayer.h:301
Definition AnimNode_BlendSpacePlayer.h:122
Definition AnimNodeBase.h:337
Definition AnimNodeBase.h:324
Definition AnimNodeBase.h:354
Definition AnimationAsset.h:209
FVector GetFilterLastOutput() const
Definition AnimationAsset.h:218
Definition AnimationAsset.h:122
Definition AnimNodeBase.h:642
Definition AnimNodeBase.h:479
Definition ObjectPtr.h:488
Definition StructOpsTypeTraits.h:11
@ WithPureVirtual
Definition StructOpsTypeTraits.h:33
Definition StructOpsTypeTraits.h:46