[Multiplayer] Predict player movements

Hello,

I try to create my own multiplayer game. I have a server in NodeJS and a client that use Unreal Engine.
My server sends sockets with all the player positions to the clients every 50ms.

To get smooth movements, the client interpolates the current position of each player with the new received position.

My problem is, with the lag, the events can be received by the client after 50ms, and in this case, the movement of the players stops until the next event is received.

To resolve this, I tried to continue the interpolation and predict the next position, but it also seems bumpy.

Do you have any idea how other games are resolving this ?

The problem is the same for the AI.

This is my code :

#include "OtherPlayerCharacter.h"    

AOtherPlayerCharacter::AOtherPlayerCharacter()
{
	PrimaryActorTick.bStartWithTickEnabled = false;

	PreviousLocation = GetActorLocation();
	NextLocation = PreviousLocation;

	TimeSinceLastUpdate = 0.0f;
	GetCharacterMovement()->DestroyComponent();
}

// Called when the game starts or when spawned
void AOtherPlayerCharacter::BeginPlay()
{
	Super::BeginPlay();
}

// Called every frame.
void AOtherPlayerCharacter::Tick(float DeltaTime)
{
	TimeSinceLastUpdate += DeltaTime * 1000;

	Interpolation();
}

void AOtherPlayerCharacter::Interpolation(){
	// Remove the FMath::Min() to do movement prediction.
	float Alpha = FMath::Min(TimeSinceLastUpdate / 50, 1.0f);

	SetActorLocation(
		FMath::Lerp(PreviousLocation, NextLocation, Alpha),
		false,
		nullptr,
		ETeleportType::None
	);
}

// Function called each ~50ms by the server events.
void AOtherPlayerCharacter::SetNextLocationRotation(FVector NewLocation, FRotator NewRotation){

	PreviousLocation = GetActorLocation();
	NextLocation = NewLocation;

	TimeSinceLastUpdate = 0.0f;

	PrimaryActorTick.SetTickFunctionEnable(true);
}