Skip to main content
gamedev.net
🔒 Locked

Interpolation?

Started by FlorianapoliS 0 replies 650+ views
Original Post
FlorianapoliS
FlorianapoliS
I'm a bit stuck on how to implement good interpolation. What I'm doing at the moment is store the last pack received for each player on each client and then interpolate between that and the new packet just received for that player. The interpolation is based on the timestamps of each packet and the distance between the player positions. The catch I've found though is that if the players position isn't at expected position by the previous packet when the new one comes in, it starts interpolating from the objects current position to the next packet which slowy results in a bigger distance each time thus a greater velocity until it goes flying off the screen. So I made it lock the players position to the expected position of the last packet, this fixes the object flying off the screen, buy obviously makes it do little jumps when the position is locked to the last packet. Was wondering if this is this just a crap way of going about it, or am I doing something wrong? Cheers. Mark
hplus0603
hplus0603
There are a number of different interpolation strategies, with different kinds of smoothing, look-forward, look-back, higher order interpolation, etc.

Some questions to answer include what to do when the next packet you expect doesn't show up; what to do when the next packet shows up too early; and what to do if the next packet shows up with an "impossible" position that's totally counter to what the previous packet said.

There's no perfect solution to interpolation or extrapolation, but there are lots of reasonable solutions. One common technique is to interpolate between forward-extrapolated positions. The OpenTNL whitepaper describes this technique in reasonable detail; I'd suggest you start there, and do something else only if it doesn't work.
enum Bool { True, False, FileNotFound };

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.