Currently I'm participating in a multiplayer game project as a network developer. Unfortunately, however, I'm facing an interpolation problem which makes game objects look like they are 'jumping/teleporting' sometimes. Images don't look smooth compared to the server even if the client runs at 60 frames per second.

Things about the architecture:

  • Based on client/server model. server sends regular transform updates at every 33 milliseconds (30fps).
  • Client receives and stores position updates in a queue. then, plays them from 1 second behind using interpolation between each update.
  • Before processing the next packet, client calculates the sent time between current and next packet to find out how many milliseconds this interpolation should take. at every frame, it deducts the delta time from the interpolation time. so, if interpolation time reaches a number equal or less than zero, it iterates to the next packet (if the value is less than zero, it means that there is a time fragment. so the client also considers that time fragment for interpolation of the jumped packet at the same frame.)
  • Client doesn't deal with rigidbody; only position and rotation.

I'm using Unity3D's LERP method from the Vector3 class. Using SLERP didn't solve the problem.

Any ideas? Everything looks great on paper.


It seems the problem caused by Unity's double typed timestamp which is included in the NetworkInfo packet. Since most of the Unity classes utilize from float instead of double, I was applying typecasting on the timestamp which was leading to loss of data.

After realizing that, I've inserted my own timestamp using Time.time (a float value) to each packet. Now, everything looks fine.

  • \$\begingroup\$ You should mark this as selected answer, to help future visitors. \$\endgroup\$ – o0'. Nov 19 '13 at 10:06
  • 1
    \$\begingroup\$ Why are you using a floating point timestamp? You would better use an int for this kind of thing. \$\endgroup\$ – o0'. Nov 19 '13 at 10:06
  • \$\begingroup\$ Because that's how Unity represents time. Time.time is a float value of seconds (using fractions to represent ms) \$\endgroup\$ – Vasisualiy Dec 30 '14 at 12:31

Linear interpolation should be fine. The trick is to figure out which two states to interpolate between, not the interpolation itself. Maybe this will help? http://gabrielgambetta.com/fpm3.html

I disagree with the other reply, you definitely need interpolation even if you don't lose packets (except if you get exactly one packet per frame with zero lag and zero loss, which is unrealistic)


If game objects can get the correct position updatings each frame there's NO need to use interpolation, you just update the position the same in single-player mode.

But packet loss always happens in WLAN, you may need to predict the game object transform in client.

  • 4
    \$\begingroup\$ Not quite. In practice you always need some kind of local interpolation/extrapolation to keep the display smooth, even on a well behaved network variances in ping will make everything look very twitchy. \$\endgroup\$ – Patrick Hughes Nov 18 '13 at 4:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.