Extreme Jitter While On Moving Vehicle (Multiplayer)

So I have a helicopter in my multiplayer game.
When it’s moving with some velocity > 0, and a client character is on top of the helicopter (not possessing it, just riding on it), the client experiences significant jitter on his screen.
Now, I expect this is normal since there is replication delay. But how do you go about fixing this?

My attempt was to detect when I am on top of the helicopter (through a OnHit collision), and then do an interpolation in the Tick function like shown below, but it doesn’t seem to be doing anything…Any thoughts?

if (IsLocallyControlled() && OnHelicopter)
{
	FVector InterpolatedLocation = FMath::Lerp(PreviousOnHelicopterLoc, OnHelicopter->GetActorLocation(), 0.1f);
	FRotator InterpolatedRotation = FMath::Lerp(PreviousOnHelicopterRot, OnHelicopter-  >GetActorRotation(), 0.1f);
	PreviousOnHelicopterLoc = OnHelicopter->GetActorLocation();
	PreviousOnHelicopterRot = OnHelicopter->GetActorRotation();
	
OnHelicopter->SetActorLocationAndRotation(InterpolatedLocation, InterpolatedRotation);
}

It might be a long shot, but I had exactly this recently, and it turns out that disabling the player collision ( on the player ) fixed it. ( I had a piece of code to just hold the player in place )

Thanks for the suggestion.
Just tried this, and it didn’t seem to work.
I didn’t attach the character on the helicopter though (because this would interfere with the gameplay).

1 Like

FYI, I tried to attach the character to the helicopter while it’s moving (using the AttachToActor function), and the jitter is significantly reduced. But again, I don’t want to do this because the player should be able to freely move.

1 Like

It might be a long shot, but I had exactly this recently, and it turns out that disabling the player collision ( on the player ) fixed it. ( I had a piece of code to just hold the player in place )

It looks like calling this in the Tick function of my character is going in the right direction:

FVector InterpedLoc = FMath::VInterpTo(GetActorLocation(), GetActorLocation() + (OnHelicopter->GetVelocity() - GetVelocity()) * DeltaTime, DeltaTime, 1.f);

SetActorLocation(InterpedLoc);

But it’s still giving a lot of jitter…

1 Like

Hello! I found a solution to properly replicate vehicle movement for the client, eliminating delays and stuttering. Simply change the Replication Angle Lerp value from 0.4 to 0, and it works perfectly!

:small_blue_diamond: Where to find this setting?

  1. Go to Edit → Project Settings
  2. In the left menu, navigate to Physics
  3. Scroll down to the Replication section
  4. Find Replication Angle Lerp and change its value from 0.4 to 0

This change disables automatic rotation smoothing, ensuring that the vehicle’s rotation is replicated instantly and without jitter between the client and server.

This happens because you’re probably attaching the player actor directly to the helicopter. To fix this, you need to attach the player’s mesh to the vehicle’s mesh.