Building-escape tutorial. around 102
void UOpenTheDoor::BeginPlay()
{
Super::BeginPlay();
InitialYaw = GetOwner()->GetActorRotation().Yaw;
TargetYaw = InitialYaw + 90.0f;
UE_LOG(LogTemp, Warning, TEXT("This %f"), InitialYaw);
}
// Called every frame=1
void UOpenTheDoor::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction* ThisTickFunction)
{
Super::TickComponent(DeltaTime, TickType, ThisTickFunction);
CurrentYaw = GetOwner()->GetActorRotation().Yaw;
if (CurrentYaw < TargetYaw - 1.0f)
{
UE_LOG(LogTemp, Warning, TEXT("Yaw is: %f"), GetOwner()->GetActorRotation().Yaw);
FRotator OpenDoor(0.0f, TargetYaw, 0.0f);
OpenDoor.Yaw = FMath::FInterpTo(CurrentYaw, TargetYaw, DeltaTime, 2);
GetOwner()->SetActorRotation(OpenDoor);
}
}
The door comes almost to a stop, then speeds up again doing a carousel type thing. This occurs if the initial yaw was greater than 90 degrees. Seems when the yaw hits 180, it then becomes -180.
LogTemp: Warning: Yaw is: 178.742538
LogTemp: Warning: Yaw is: 179.066345
LogTemp: Warning: Yaw is: 179.368576
LogTemp: Warning: Yaw is: 179.650665
LogTemp: Warning: Yaw is: 179.913940
LogTemp: Warning: Yaw is: -179.840347
LogTemp: Warning: Yaw is: -155.610916
LogTemp: Warning: Yaw is: -132.996613
LogTemp: Warning: Yaw is: -111.889908
LogTemp: Warning: Yaw is: -92.190491
LogTemp: Warning: Yaw is: -73.804329
LogTemp: Warning: Yaw is: -56.643780
LogTemp: Warning: Yaw is: -40.627468
LogTemp: Warning: Yaw is: -25.678783
Et cetera.
If the inital yaw was less than 90 degrees, everything works as expected.
This is not the first time i have had issues with the way UE4 calculates/maps circles. Any solutions or suggestions would be appreciated.
Thank you