Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

AnswerHub Maintenance

Background maintenance is scheduled to occur between 9 - 11am EDT on Tuesday, May 21. Site operation may be slower than normal during this time and a brief interruption in operation may be observed

[Multiplayer] Predict player movements


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"    
     PrimaryActorTick.bStartWithTickEnabled = false;
     PreviousLocation = GetActorLocation();
     NextLocation = PreviousLocation;
     TimeSinceLastUpdate = 0.0f;
 // Called when the game starts or when spawned
 void AOtherPlayerCharacter::BeginPlay()
 // Called every frame.
 void AOtherPlayerCharacter::Tick(float DeltaTime)
     TimeSinceLastUpdate += DeltaTime * 1000;
 void AOtherPlayerCharacter::Interpolation(){
     // Remove the FMath::Min() to do movement prediction.
     float Alpha = FMath::Min(TimeSinceLastUpdate / 50, 1.0f);
         FMath::Lerp(PreviousLocation, NextLocation, Alpha),
 // Function called each ~50ms by the server events.
 void AOtherPlayerCharacter::SetNextLocationRotation(FVector NewLocation, FRotator NewRotation){
     PreviousLocation = GetActorLocation();
     NextLocation = NewLocation;
     TimeSinceLastUpdate = 0.0f;
Product Version: UE 4.19
more ▼

asked Oct 07 '18 at 04:43 PM in C++ Programming

avatar image

1 2 3

(comments are locked)
10|2000 characters needed characters left

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question