By gameplay reasons i have to control players rotation on server.
But when i rotate my character i get this lags
:
Movement replicated:
Maybe on gif this looks not terrible, but it is
Same thing but Replicate Movement
disabled:
Everything smooth.
I’m not sure what to do with it. Seems like when Replicate Movement
is enabled, server trying to correct my rotation and this leads to lags.
I tried many many things, but still can’t make this work properly
Any help will be much appreciated
This is how i rotate my character (func called in tick):
0.666 on server was found randomly and gives most correct client/server rotation speed. Also changing or removing this value not helps with this problem.
if(IsLocallyControlled() || GetNetMode() == NM_DedicatedServer)
{
const FRotator CurrentRotator = FRotator(0, GetActorRotation().Yaw, 0);
const FRotator TargetRotator = FRotator(0, GetControlRotation().Yaw, 0);
float InterpolationSpeed = 5.0f;
if(GetNetMode() == NM_DedicatedServer)
{
const FRotator DesiredRotation = FMath::RInterpTo(CurrentRotator, TargetRotator, 0.01, InterpolationSpeed * 0.666);
SetActorRotation(DesiredRotation);
}
else
{
const FRotator DesiredRotation = FMath::RInterpTo(CurrentRotator, TargetRotator, 0.01, InterpolationSpeed);
SetActorRotation(DesiredRotation);
}
}