// Called when the game starts
void UOpenDoor::BeginPlay()
{
Super::BeginPlay();
InitialYaw = GetOwner()->GetActorRotation().Yaw;
TargetYaw = 90.f;
}
// Called every frame
void UOpenDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
CurrentYaw = GetOwner()->GetActorRotation().Yaw;
FRotator OpenDoor;
OpenDoor.Yaw = FMath::Lerp(CurrentYaw, InitialYaw + TargetYaw , 0.02f);
GetOwner()->SetActorRotation(OpenDoor);
}
I found the example method in the video a little difficult to follow, but this is what I came up with when I tried it myself before watching. By initializing InitialYaw and TargetYaw in BeginPlay, and then constantly updating CurrentYaw, you are able to lerp between CurrentYaw and (InitialYaw + Target Yaw). This functions perfectly, just wondering if it’s as performant or if there is anything wrong with the solution I’m not seeing. Thank you!