Jump to content

  • Log In with Google      Sign In   
  • Create Account

We need your help!

We need 7 developers from Canada and 18 more from Australia to help us complete a research survey.

Support our site by taking a quick sponsored survey and win a chance at a $50 Amazon gift card. Click here to get started!


Interpolation And Latency's effect on it


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 bobrules   Members   -  Reputation: 102

Like
0Likes
Like

Posted 31 January 2011 - 03:03 AM

Hi guys. My computer is currently broken so I'm using a friend laptop at the moment, but once it's fixed I want to continue my simple network game.
I was reading the article on http://developer.valvesoftware.com/wiki/Source_Multiplayer_Networking and wish to do something similar as my pure extrapolation model has a very bad jerk when the user stops moving.

If I'm not mistaken it works like this - assuming packets sent every 50 ms -
- Client 1 presses Right at time 0 ms.
- Client 1 delays moving itself for 2 times of packet travel - 100 ms.
- Server receives information and send to all other clients.
- Client 2 waits until there's at least 2 ( 3 ? ) packets arrive initially and interpolate client 1's position from last received packet - 2 to last received packet - 1

Is this the correct implementation ?

Also say client 1's latency is huge - say 500 ms, would this affect how client 2 sees client 1? Would it still be smooth, just that client 2 will see client 1 as it was 500 ms later?

Thank you all!

Sponsor:

#2 Hodgman   Moderators   -  Reputation: 42343

Like
0Likes
Like

Posted 31 January 2011 - 05:21 AM

Is this the correct implementation ?

Pretty much, you've missed out client-side prediction though;

With a round-trip ping of 100ms:
at time 0 ms
- Client 1 presses Right - sending a move command to the server.
- Client 1 moves it's own camera to the right - by executing the same move command that it sent.
at time 50 ms
- Server receives information and uses it in the next update loop
- Server sends new game world information to all clients
at time 100 ms
- Client 1 compares it's predicted position to the server's new position. If there is a large difference, then the camera smoothly snaps back to the server's position.
- Client 2 waits until there's at least 2 packets worth of data about client 1's position (assuming for this example there isn't 2 packets yet)
at time 150 ms
- Client 2 interpolates client 1's position from the 2nd last received packet to the last received packet

Also say client 1's latency is huge - say 500 ms, would this affect how client 2 sees client 1? Would it still be smooth, just that client 2 will see client 1 as it was 500 ms later?

Assuming a client-server design, then the server is simulating client 1's character, and can send updates to client 2 as fast as usual. The server is always the authority on all rules - clients don't move themselves, they just send "I'm holding the move key" messages to the server, and also predict the outcome of these messages locally (and the local predictions can/will be overwritten by the server's version of events).

#3 hplus0603   Moderators   -  Reputation: 7854

Like
1Likes
Like

Posted 31 January 2011 - 09:23 AM

Because of transmission latency, you have to choose one of these main options:

1) Guess about the future. Use forward extrapolation. Remote viewers will see entities out of place, and starting/stopping will be late/over-shooting.
2) Display in the past. Delay the display enough to cover any transmission latency/jitter. Remote viewers will see things in the right place, but later.

These are the two options, because information can't magically teleport faster than light between computers :-) The rest has to be handled with game design.
enum Bool { True, False, FileNotFound };

#4 bobrules   Members   -  Reputation: 102

Like
0Likes
Like

Posted 31 January 2011 - 12:46 PM

Ahh Thanks everyone for your help! Hopefully my computer will up and running so I can test this for sure. :)




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS