Door doesn't work (new building escape - relative vs absolute)

// Called when the game starts
void UDoorRotate::BeginPlay()
{
    Super::BeginPlay();

    float InitialYaw = GetOwner()->GetActorRotation().Yaw;
    float CurrentTargetYaw = InitialYaw;
    float FinalTargetYaw = InitialYaw + 90.f;
    
}


// Called every frame
void UDoorRotate::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
    Super::TickComponent(DeltaTime, TickType, ThisTickFunction);

    UE_LOG(LogTemp, Warning, TEXT("%s"), *GetOwner()->GetActorRotation().ToCompactString());
    
    CurrentTargetYaw = FMath::Lerp(CurrentTargetYaw, FinalTargetYaw, 0.05f);
    FRotator CurrentRotator = GetOwner()->GetActorRotation();
    CurrentRotator.Yaw = CurrentTargetYaw;
    GetOwner()->SetActorRotation(CurrentRotator);

}

This is my DoorRotate.cpp as of part 99 of the new BuildingEscape. I was making my own method, and it didn’t work, so I decided to copy the video’s method. It still doesn’t work. Here’s the log when I only have one door:

LogTemp: Warning: R(0)
LogTemp: Warning: R(Y=-90.00)
LogTemp: Warning: R(Y=-180.00)
LogTemp: Warning: R(0)
LogTemp: Warning: R(0)
LogTemp: Warning: R(0)
...
LogTemp: Warning: R(0)

how is it changing by -90 degrees per frame, and then stopping at 0?

Thank you for helping me!

float InitialYaw = GetOwner()->GetActorRotation().Yaw;
float CurrentTargetYaw = InitialYaw;
float FinalTargetYaw = InitialYaw + 90.f;

Here you are creating new local variables and not using the member variables declared as part of the class.

Thank you!

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms