O'Reilly logo

Unity Multiplayer Games by Alan Stagner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Improving interpolation

Here's how our new interpolation will work, inspired by the methods employed in the Source game engine:

  • As we receive network states, we buffer them up
  • Each network state is timestamped with network time
  • We subtract a value from time to find a time in the past (in source, this value is 0.1 by default—so entities are always shown one tenth of a second in the past)
  • We find the two states on either side of this time value, and interpolate between them
  • Let's get started

First, we need some kind of struct to store a snapshot of the network state:

// a snapshot of values received over the network private struct networkState { public Vector3 Position; public double Timestamp; public networkState( Vector3 pos, double time ) { this.Position ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required