UDocumentation UE5.7 10.02.2026 (Source)
API documentation for Unreal Engine 5.7
InterpolateComponentToAction.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 "LatentActions.h"
10
13{
14public:
16 float TotalTime;
21
28
31
38
45
47 bool bEaseIn;
50
53
73
75 {
76 // Update elapsed time
77 TimeElapsed += Response.ElapsedTime();
78
79 bool bComplete = (TimeElapsed >= TotalTime);
80
81 // If we have a component to modify..
83 {
84 // Work out 'Blend Percentage'
85 const float BlendExp = 2.f;
87 float BlendPct;
88 if(bEaseIn)
89 {
90 if(bEaseOut)
91 {
92 // EASE IN/OUT
93 BlendPct = FMath::InterpEaseInOut(0.f, 1.f, DurationPct, BlendExp);
94 }
95 else
96 {
97 // EASE IN
98 BlendPct = FMath::Lerp(0.f, 1.f, FMath::Pow(DurationPct, BlendExp));
99 }
100 }
101 else
102 {
103 if(bEaseOut)
104 {
105 // EASE OUT
106 BlendPct = FMath::Lerp(0.f, 1.f, FMath::Pow(DurationPct, 1.f / BlendExp));
107 }
108 else
109 {
110 // LINEAR
111 BlendPct = FMath::Lerp(0.f, 1.f, DurationPct);
112 }
113 }
114
115 // Update location
117 {
119 TargetComponent->SetRelativeLocation(NewLocation, false);
120 }
121
123 {
124 FRotator NewRotation;
125 // If we are done just set the final rotation
126 if (bComplete)
127 {
128 NewRotation = TargetRotation;
129 }
131 {
132 // We want the shortest path
135
137 Result.Normalize();
138 NewRotation = Result.Rotator();
139 }
140 else
141 {
142 // dont care about it being the shortest path - just lerp
144 }
145 TargetComponent->SetRelativeRotation(NewRotation, false);
146 }
147 }
148
149 Response.FinishAndTriggerIf(bComplete || !bInterpolating, ExecutionFunction, OutputLink, CallbackTarget);
150 }
151
152#if WITH_EDITOR
153 // Returns a human readable description of the latent operation's current state
154 virtual FString GetDescription() const override
155 {
159 return FText::Format(NSLOCTEXT("FInterpolateComponentToAction", "ActionTimeFmt", "Move ({0} seconds left)"), FText::AsNumber(TotalTime-TimeElapsed, &DelayTimeFormatOptions)).ToString();
160 }
161#endif
162};
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
auto Response
Definition ExternalRpcRegistry.cpp:598
#define NSLOCTEXT(InNamespace, InKey, InTextLiteral)
Definition Internationalization.h:300
Definition InterpolateComponentToAction.h:13
int32 OutputLink
Definition InterpolateComponentToAction.h:25
float TotalTime
Definition InterpolateComponentToAction.h:16
FName ExecutionFunction
Definition InterpolateComponentToAction.h:23
virtual void UpdateOperation(FLatentResponse &Response) override
Definition InterpolateComponentToAction.h:74
bool bEaseIn
Definition InterpolateComponentToAction.h:47
float TimeElapsed
Definition InterpolateComponentToAction.h:18
bool bInterpLocation
Definition InterpolateComponentToAction.h:40
TWeakObjectPtr< USceneComponent > TargetComponent
Definition InterpolateComponentToAction.h:30
FWeakObjectPtr CallbackTarget
Definition InterpolateComponentToAction.h:27
FRotator InitialRotation
Definition InterpolateComponentToAction.h:35
FInterpolateComponentToAction(float Duration, const FLatentActionInfo &LatentInfo, USceneComponent *Component, bool bInEaseOut, bool bInEaseIn, bool bInForceShortestRotationPath)
Definition InterpolateComponentToAction.h:54
bool bForceShortestRotationPath
Definition InterpolateComponentToAction.h:52
FVector InitialLocation
Definition InterpolateComponentToAction.h:42
bool bInterpRotation
Definition InterpolateComponentToAction.h:33
bool bEaseOut
Definition InterpolateComponentToAction.h:49
FVector TargetLocation
Definition InterpolateComponentToAction.h:44
bool bInterpolating
Definition InterpolateComponentToAction.h:20
FRotator TargetRotation
Definition InterpolateComponentToAction.h:37
Definition NameTypes.h:617
Definition LatentActions.h:73
static CORE_API FText AsNumber(float Val, const FNumberFormattingOptions *const Options=NULL, const FCulturePtr &TargetCulture=NULL)
static CORE_API FText Format(FTextFormat Fmt, const FFormatNamedArguments &InArguments)
Definition Text.cpp:469
CORE_API const FString & ToString() const
Definition Text.cpp:1263
Definition LatentActionManager.h:19
Definition LatentActions.h:10
static T InterpEaseInOut(const T &A, const T &B, float Alpha, float Exp)
Definition UnrealMathUtility.h:1288
static constexpr UE_FORCEINLINE_HINT T Lerp(const T &A, const T &B, const U &Alpha)
Definition UnrealMathUtility.h:1116
Definition Text.h:199
FNumberFormattingOptions & SetMaximumFractionalDigits(int32 InValue)
Definition Text.h:224
FNumberFormattingOptions & SetMinimumFractionalDigits(int32 InValue)
Definition Text.h:221
Definition WeakObjectPtr.h:49
Definition WeakObjectPtrTemplates.h:25
FORCEINLINE bool IsValid(bool bEvenIfPendingKill, bool bThreadsafeTest=false) const
Definition WeakObjectPtrTemplates.h:232
static UE_FORCEINLINE_HINT TQuat< double > Slerp(const TQuat< double > &Quat1, const TQuat< double > &Quat2, double Slerp)
Definition Quat.h:660