Dealing with latency extrapolation and overshooting
Blair Holloway <[email protected]>
| Newsgroups | gmane.games.devel.sweng |
|---|---|
| Message-ID | <[email protected]> |
I just dropped in a first iteration of interpolation to synchronise player
positions in our networked game, but I'm having an issue where, when a
player stops movement, remotely the player will stop ahead of where he
should have, and then slide back into place. This seems to be a side effect
of extrapolating the player's position ahead in order to compensate for lag.
The problem is compounded by the fact that players don't have a lot of
momentum, and therefore can stop dead within mere frames of applying input.
What methods might I use to avoid the stop-then-slide-back effect I'm
seeing? The only one I've been able to think of thus far is to "not
extrapolate", which solves the problem 90% of the time, but isn't desired,
as remote player movements will always lag behind their actual positions.
Some more detail: player movement is all locomotive in a two-dimensional
plane, driven by an animation system; animation playback itself is
synchronised by a separate system, but one that does not (and can not)
easily account for the drift caused by latency between machines.
The current code essentially, does this:
* Receive (position, velocity, orientation) for remote player.
* Determine time since send, and extrapolate current remote position to
hide latency.
* Store current time, local pos, vel, ori for remote player, and
extrapolated pos, vel, ori for remote player.
* Then, every frame:
* Extrapolate stored local position and remote position based on current
time.
* Interpolate between these two positions based on current time (aiming
to converge in ~300ms).
* Apply interpolated position to player model.
There is also some extra smoothing based on previous interpolation states
going on, but I've omitted this for clarity. Positional updates are
currently sent ten times per second.
Any help would be appreciated. :)
Cheers,
- Blair
_______________________________________________
Sweng-Gamedev mailing list
[email protected]
http://lists.midnightryder.com/listinfo.cgi/sweng-gamedev-midnightryder.com