[Unreal Engine] FMath::FInterpConstantTo
(Ultimo aggiornamento: 25 Ottobre 2020)
Il FMath::FInterpConstantTo interpola il float dalla Posizione attuale al Target desiderato con un andamento costante.
Module | Core |
Header | /Engine/Source/Runtime/Core/Public/Math/UnrealMathUtility.h |
Include | #include “Math/UnrealMathUtility.h” |
Source | /Engine/Source/Runtime/Core/Private/Math/UnrealMath.cpp |
Sintassi:
static float FInterpConstantTo ( float Current, float Target, float DeltaTime, float InterpSpeed )
Esempio sulla rotazione
Nella classe corrente di MioScript.h:
private: float TargetYaw = 90.f; float InitialYaw = 0.f; float CurrentYaw;
MioScript.cpp:
// Called every frame void UMioScript::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction) { Super::TickComponent(DeltaTime, TickType, ThisTickFunction); // HERE BEGIN CODE CurrentYaw = GetOwner()->GetActorRotation().Yaw; FRotator OpenDoor(0.f, TargetYaw, 0.f); /* Change Yaw of OpenDoor StartingYaw TargetYaw: CurrentYaw 0-1 */ OpenDoor.Yaw = FMath::FInterpConstantTo(CurrentYaw, TargetYaw, DeltaTime, 45); GetOwner()->SetActorRotation(OpenDoor); }