Simpler Solution

Hi, I found it a little bit confusing to introduce more private variables in this lecture. What I have done is to not initialize the TargetYaw in the header file but instead I initialized it in the BeginPlay() method. I simply set the target yaw by taking the initial yaw and adding 90 degrees.

TargetYaw = GetOwner()->GetActorRotation().Yaw + 90.f;

My TickComponent() method has not changed:

FRotator DoorRotation = GetOwner()->GetActorRotation();
DoorRotation.Yaw = FMath::FInterpTo(DoorRotation.Yaw, TargetYaw, DeltaTime, 2);
GetOwner()->SetActorRotation(DoorRotation);
3 Likes

How has the choice worked out for you? The best part of programming is making choices like you did and testing it out.

I took a similar approach to you @handyplayer, found it much more intuitive. Especially as the InitialYaw variable doesn’t even really feature in the update function. In fact that caused me no end of confusion, wondering why my door wouldn’t open because I was interpolating between two values that never changed.

Privacy & Terms