Client: override actor rotation with smoothed yaw to eliminate body mesh jitter

Previous fix only smoothed cascade inputs (head/eyes) via SmoothedBodyYaw
but the body mesh still followed the raw replicated actor rotation which
jumped at ~30Hz network rate. Now the client calls SetActorRotation with
the smoothed yaw so the mesh visually interpolates. Replication overwrites
on next network update; SmoothedBodyYaw absorbs the correction smoothly.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
j.foucher 2026-03-03 11:37:59 +01:00
parent 28964f0a40
commit 8886e7a7a2

View File

@ -347,6 +347,8 @@ void UPS_AI_ConvAgent_PostureComponent::TickComponent(
// ── Smoothed body yaw for cascade computations ──────────────────
// Server: direct copy (no lag). Client: interpolate toward replicated
// rotation to avoid step artifacts from discrete ~30Hz network updates.
// The client also overrides the actor's rotation with the smoothed value
// so the body mesh doesn't visually jump at network tick rate.
if (Owner->HasAuthority())
{
SmoothedBodyYaw = Owner->GetActorRotation().Yaw;
@ -356,6 +358,14 @@ void UPS_AI_ConvAgent_PostureComponent::TickComponent(
const float ReplicatedYaw = Owner->GetActorRotation().Yaw;
const float ClientDelta = FMath::FindDeltaAngleDegrees(SmoothedBodyYaw, ReplicatedYaw);
SmoothedBodyYaw += FMath::FInterpTo(0.0f, ClientDelta, SafeDeltaTime, BodyInterpSpeed * 3.0f);
// Override actor rotation with smoothed value so the body mesh
// shows the interpolated rotation instead of the raw replicated steps.
// This is local-only — replication will overwrite on next network update,
// and SmoothedBodyYaw will absorb the correction smoothly.
FRotator SmoothedRot = Owner->GetActorRotation();
SmoothedRot.Yaw = SmoothedBodyYaw;
Owner->SetActorRotation(SmoothedRot);
}
// ── 3. Compute DeltaYaw after body interp ──────────────────────────