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