Jump to content

What is the best way to lerp in a multiplayer game where the update rates are inconsistent?


thedupdup
 Share

Recommended Posts

11 hours ago, Antriel said:

I explained exactly why this happens in your other topic, with a solution and a link to my blog post where I go deeper into details regarding that issue. If something wasn't clear, maybe ask a question rather than make a new topic.

 

Hi, whilst reading through your blog, I have found this http://buildnewgames.com/real-time-multiplayer/#entity-interpolation-other-clients, which seems like a solid way to do this. But I am having troubles understanding what current_time is, maybe you can help me understand? 

Link to comment
Share on other sites

`current_time` is simply the time that is now. If server sends you `{x: 100, time: 0}` and then `{x: 200, time: 100}`, and your current time is 50, you interpolate x to be 150.

Of course it's a bit more complex as you need to keep that time relative to what server is sending out. And interpolate a bit in the past to cover delayed messages. So server sends you e.g. 4 positions, you start showing the first, second... meanwhile you get 5th, 6th... etc.

Link to comment
Share on other sites

No, in a way it's `Date.now()`. Or some number that's relative to that and the server's time.

E.g. I simply start counting time when first message arrives and I know what rate to expect, so I know what timestamp the other messages have. Imagine starting a stopwatch when first message comes and timing your whole game based on that.

Link to comment
Share on other sites

19 minutes ago, Antriel said:

Essentially yes. It's all nicely explained in my blog too.

So I re-looked at your examples, so in this example: http://buildnewgames.com/real-time-multiplayer/#entity-interpolation-other-clients I don't see current_time ever altered, wouldn't this mean the current_time would always be ahead ahead of the server? Since in your example you subtract 0.2 from the current time. 

Link to comment
Share on other sites

17 minutes ago, Antriel said:

There isn't `current_time` ever used there, it's just used to describe the principle. If you look at it properly you see it also subtracts time from the current time.

Okay so in that code they subtract net_offset from current_time? Is net_offset just the time it takes the packet from the server to reach the client? 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...