Download

Raknet and Unreal Engine 4 Movement Component

Hello, how to compensate for the delay between the client-server-client?
As a server I use RakNet; If you send data about the coordinates of the player and his speed every 5 ms lag is not noticeable. But this creates a very large load on the client / server and internet channel.

I tried to increase the delay between the exchange of coordinates player to 100/200 ms, and compensate for the delay increase player movement speed;



//OnSyncLocation
		auto curTime = RakNet::GetTimeMS();
		auto Delta =(curTime - timestamp) / 10;
		
		_Player->SetActorRotation(rotation);
		const FVector Direction = FRotationMatrix(rotation).GetScaledAxis(EAxis::X) * 1.0f;
		_Player->SetActorLocation(position + Direction);


		_Player->GetMovementComponent()->Velocity = velocity * Delta;
		_Player->GetMovementComponent()->UpdateComponentVelocity();



Movement is more or less smoothly, but the animation does not play