Hi, i just moved my pitch & yaw calculations from my animation blueprint to my c++ character class.
The server can see the client’s yaw and pitch updating, but the client cannot see the server’s yaw and pitch updating.
Here’s the pitch & yaw calculation into my character’s tick function:
FRotator rPitchYaw = UKismetMathLibrary::RInterpTo(FRotator(Pitch, Yaw, 0.0f), UKismetMathLibrary::NormalizedDeltaRotator(GetControlRotation(), GetActorRotation()), DeltaTime, 15.0f);
if(UKismetMathLibrary::ClampAngle(rPitchYaw.Pitch, -90.0f, 90.0f) != Pitch)
{
SetPitch(UKismetMathLibrary::ClampAngle(rPitchYaw.Pitch, -90.0f, 90.0f));
}
if (UKismetMathLibrary::ClampAngle(rPitchYaw.Yaw, -90.0f, 90.0f) != Yaw)
{
SetYaw(UKismetMathLibrary::ClampAngle(rPitchYaw.Yaw, -90.0f, 90.0f));
}
And there are the declarations inside the character’s header file
UPROPERTY(Transient, Replicated)
float Pitch;
UPROPERTY(Transient, Replicated)
float Yaw;
void SetPitch(float value);
UFUNCTION(Reliable, Server, WithValidation)
void ServerSetPitch(float value);
void ServerSetPitch_Implementation(float value);
bool ServerSetPitch_Validate(float value);
void SetYaw(float value);
UFUNCTION(Reliable, Server, WithValidation)
void ServerSetYaw(float value);
void ServerSetYaw_Implementation(float value);
bool ServerSetYaw_Validate(float value);
and then the functions:
oid AULCharacter::SetPitch(float value)
{
Pitch = value;
if (Role < ROLE_Authority)
{
ServerSetPitch(value);
}
}
void AULCharacter::ServerSetPitch_Implementation(float value)
{
SetPitch(value);
}
bool AULCharacter::ServerSetPitch_Validate(float value)
{
return true;
}
void AULCharacter::SetYaw(float value)
{
Yaw = value;
if (Role < ROLE_Authority)
{
ServerSetYaw(value);
}
}
void AULCharacter::ServerSetYaw_Implementation(float value)
{
SetYaw(value);
}
bool AULCharacter::ServerSetYaw_Validate(float value)
{
return true;
}
Then i simply get the pitch & yaw in the animation blueprint’s event blueprint update animation.
I replicate my others variable the same ways and they work well, i don’t get why this happens.
thank you in advance for your help.