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 ...
Get Unity Multiplayer Games now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.