• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.
Sign in to follow this  
Followers 0
Ollhax

Player prediction across clients, minimizing latency

10 posts in this topic

Hi there! I'm working on my network code and I've run into a minor snag that someone perhaps can help me with. I went with the [url="http://nclabs.org/articles/5"]Quake 3[/url] network model and I've used [url="http://www.gabrielgambetta.com/?p=22"]Gabriel Gambetta's[/url] excellent blog posts as a reference when implementing the finer points such as server reconciliation.

However, there's a situation that occur when there's more than one client in the picture. Lengthy example ahead:

Say that [i]Client A[/i] runs three frames, then decides to send an update to the server. I.e, three input structures are sent to the server.

The server receives the update after a few moments, say [i]SendTime(Client A)[/i] or ST(A) time units later. The three inputs are queued for Client A for three server update ticks in the future, meaning that the server will be fully up to date with the client after ST(A) + 3 ticks. This is all fine and dandy, since Client A's prediction and server reconciliation will hide all this latency for Client A.

What bothers me is when [i]Client B[/i] enters the picture. One could argue that he should be able to know Client A's newest position after ST(A) + ST(B) time units, but if the system is implemented exactly as described above, the input may not show until ST(A) + ST(B) + 3 ticks. This is because the server would have to update the state in order for the input's effect to show. Exactly how much delay Client B would experience also depends on how often the server sends updates.

My question is, do I have a fault in this design or is this how it usually is? One improvement I can see now would be for the server to send over A's remaining inputs to B when doing an update, letting B predict some of A's "future" inputs also. Another thing to try out would be to let Client B just extrapolate A's previous input until the server sends fresher updates. Any more takes on this?
0

Share this post


Link to post
Share on other sites
You have to be careful about your "frames." There may be render frames, physics frames, and network tick frames. The latency in question will be a combination of network tick frames.
For example, if you have three physics frames per network frame, then the batching of commands will add three physics frames' worth of latency.
Also, if the data for a player arrives "early" on the server, then the server has the choice to immediately forward it to the other clients, or to only forward it after it's been simulated and verified. How much latency there is from player A to player B depends on this choice as well.
1

Share this post


Link to post
Share on other sites
[quote name='hplus0603' timestamp='1334352984' post='4931062']
You have to be careful about your "frames." There may be render frames, physics frames, and network tick frames. The latency in question will be a combination of network tick frames.
For example, if you have three physics frames per network frame, then the batching of commands will add three physics frames' worth of latency.
Also, if the data for a player arrives "early" on the server, then the server has the choice to immediately forward it to the other clients, or to only forward it after it's been simulated and verified. How much latency there is from player A to player B depends on this choice as well.
[/quote]

Yes, one of the problem is that network ticks run slower than physic frames, which is why I have to queue up the inputs.

Good idea about forwarding inputs immediately, but I'm a bit worried over the overhead in a situation where lots of player inputs arrive spread out over different frames, this would trigger a lot of data sending. I guess I could also let clients send this kind of info directly to all other clients in the game, but that would complicate things a bit I think.

Anyhow, am I being paranoid about this thing or is it something you generally need to deal with?
0

Share this post


Link to post
Share on other sites
[quote]
[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]Anyhow, am I being paranoid about this thing or is it something you generally need to deal with? [/background][/left][/size][/font][/color]

[/quote]

[color=#282828][font=helvetica, arial, verdana, tahoma, sans-serif][size=3][left][background=rgb(250, 251, 252)]Lag, and how to provide a fun and fair game experience in the presence of it, is what network game development is ALL ABOUT. There is no perfect solution, only various trade-offs in game design and presentation.[/background][/left][/size][/font][/color]
0

Share this post


Link to post
Share on other sites
[quote]What is the point of having more physics ticks than network ticks? [/quote]

Much better feeling gameplay. You get higher latency from the bunching, but you still get to play a 60 Hz (or 100 Hz, or whatever) game. The feel for action-based games is significantly different between at 60 Hz input-and-physics game that sends three frames per packet, and a 20 Hz input-and-physics game that sends one frame per packet.

1

Share this post


Link to post
Share on other sites
Do you actually send three game states per packet bunched together? Sending three game states per packet vs one game state per packet three times as often seems like a minimal difference bandwidth-wise. What would the client do with the first two of the three game states?

If a server was running 60Hz physics and sends out game states at 20Hz, does the server still read usercmds at every physics tick, rather than every third physics tick? It seems like higher-resolution physics makes no difference unless it comes with a corresponding increase in responsiveness, though I could see how physics could provide "smoother" trajectories and such with more ticks per second even without an increase in responsiveness, depending on how exactly you implement the physics.
0

Share this post


Link to post
Share on other sites
[quote]Do you actually send three game states per packet bunched together?[/quote]

No, you probably send three sets of simulation inputs, and perhaps one game state.

You don't generally want to just dump full network states across the wire at full frame rate, because of the bandwidth usage. However, by sending the inputs, you can get a very good replica of what the entity is doing, without using much bandwidth. Typically, you can get away with sending a baseline/checkpoint for an entity only once every few seconds, and do inputs for all the simulation steps in between.

To avoid burstiness, you could send the inputs for all entities for the three steps, and a state dump of one entity, per packet. Keep a queue of entities, and rotate through which one gets state-dumped per packet.
1

Share this post


Link to post
Share on other sites
[quote name='hplus0603' timestamp='1334704303' post='4932309']
[quote]Do you actually send three game states per packet bunched together?[/quote]

No, you probably send three sets of simulation inputs, and perhaps one game state.

You don't generally want to just dump full network states across the wire at full frame rate, because of the bandwidth usage. However, by sending the inputs, you can get a very good replica of what the entity is doing, without using much bandwidth. Typically, you can get away with sending a baseline/checkpoint for an entity only once every few seconds, and do inputs for all the simulation steps in between.

To avoid burstiness, you could send the inputs for all entities for the three steps, and a state dump of one entity, per packet. Keep a queue of entities, and rotate through which one gets state-dumped per packet.
[/quote]

From the server, I send only the latest game state and all queued (and not yet used) inputs. I decided to fix this and yes, it did improve the responsiveness of the game.
0

Share this post


Link to post
Share on other sites
Article along those lines.

[url="http://gafferongames.com/game-physics/networked-physics/"]http://gafferongames.com/game-physics/networked-physics/[/url]

Maybe contains some extra stuff that would be useful to you.
0

Share this post


Link to post
Share on other sites
[quote name='papalazaru' timestamp='1334835016' post='4932766']
Article along those lines.

[url="http://gafferongames.com/game-physics/networked-physics/"]http://gafferongames...worked-physics/[/url]

Maybe contains some extra stuff that would be useful to you.
[/quote]

Yup, read them all. It's a good link though!
0

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
Sign in to follow this  
Followers 0