FRotator LastBodyRot;
FRotator LastControlRot;
FRotator BodyRot = OwnerCharacter->GetActorRotation();
FRotator ControlRot = OwnerCharacter->GetBaseAimRotation();
LookRotOffset = UKismetMathLibrary::NormalizedDeltaRotator(ControlRot, BodyRot);
if (LastBodyRot != BodyRot || LastControlRot != ControlRot)
{
UE_LOG(LogTemp, Log, TEXT("BodyRot: %s"), *BodyRot.ToString());
UE_LOG(LogTemp, Log, TEXT("ControlRot: %s"), *ControlRot.ToString());
UE_LOG(LogTemp, Log, TEXT("LookRotOffset: %s"), *LookRotOffset.ToString());
float YawDifference = FMath::FindDeltaAngleDegrees(BodyRot.Yaw, ControlRot.Yaw);
UE_LOG(LogTemp, Log, TEXT("Yaw Difference: %.2f"), YawDifference);
LastBodyRot = BodyRot;
LastControlRot = ControlRot;
}
Sometimes BodyRot.Yaw and ControlRot.Yaw will suddenly become the same, but this only occurs when using multiple clients. The situation is quite perplexing, how to modify the code to solve this issue?