void AKoreChar::SERVER_ChangeFacing_Implementation(FVector inVec)
{
Capsule->SetRelativeRotation(FRotationMatrix::MakeFromZX(Capsule->GetComponentLocation(), inVec).ToQuat());
Controller->SetControlRotation(Capsule->GetComponentRotation());
pawnCR = Controller->GetControlRotation();
pawnFacing = Capsule->RelativeRotation;
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Magenta, FString::Printf(TEXT("%s"), *pawnFacing.ToString()));
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Magenta, FString::Printf(TEXT("%s"), *pawnCR.ToString()));
CLIENT_displayROTATIONS(pawnFacing, pawnCR);
}
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Replication List
void AKoreChar::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
{
Super::GetLifetimeReplicatedProps(OutLifetimeProps);
//Gravity Scale, Adjustments in In-Game Editor
DOREPLIFETIME_CONDITION(AKoreChar, pawnFacing, COND_OwnerOnly);
DOREPLIFETIME_CONDITION(AKoreChar, pawnCR, COND_OwnerOnly);
}
void AKoreChar::CLIENT_displayROTATIONS_Implementation(FRotator inCap, FRotator inCR)
{
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Cyan, FString::Printf(TEXT("%s"), *inCap.ToString()));
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Cyan, FString::Printf(TEXT("%s"), *inCR.ToString()));
}
The image shows the capsule rotation and control rotation printed to screen from the server and the client. The SERVER_ChangeFacing_Implementation sets the two replicated FRotators and displays them on screen in Magenta, then immediately calls the client function to display the same FRotators on screen in Cyan. You can see they are different. How is this possible? Why is the client version changing the rotation range from -180 to 180 to -360 to 360?