Like HowStuffWorks on Facebook!

Halo Networking: An Interview with Chris Butcher


Everything in its Right Place
"Then the client can use that information to predict for maybe the next 300 milliseconds what that's going to look like before the guy actually gets there. "
"Then the client can use that information to predict for maybe the next 300 milliseconds what that's going to look like before the guy actually gets there. "
Photo courtesy of Bungie.net

Chris Butcher continues:

"The last piece of the puzzle is as the client you're trying to present a consistent view of the world to the player. What the server is sending you is maybe it's sending you four updates a second for this player that is running and shooting near you. So basically four times a second you're getting, "This is where that player is, this is where he's looking and this is what he's doing in the world." So if you were to just present that the way it is sent, the client would see a lot of jerky, stuttering behavior because it's not necessarily a smooth packet that's coming from the server.

So we have code that manages the objects in the predicted client world. Basically it tries to smooth out the appearance of what's happening to the players in the world. For example, rather than just sending the player 'He's here, he's here, he's here.' the server sends, 'He's here and this is what he's doing and this is the direction he's heading.' Then the client can use that information to predict for maybe the next 300 milliseconds what that's going to look like before the guy actually gets there. So rather than seeing a guy go jerk, jerk, jerk, jerk, I see him here and he's running here and he's running here.

Once you've predicted the behavior of the guy you basically apply smoothing to smooth out those differences in the transmission of data so that you see the guy running. Maybe the range of his motion isn't completely consistent but we don't jerk him from place to place. We speed him up or slow him down based on where we think he needs to be at that point in time. And of course you do the same for the vehicles, the physical objects in the world and everything like that.

So the problem essentially... is that the servers have got to generate this stream of information from clients. And how do they do that? Well the way we do that is there are two different types of things that the server can send: There is the persistence state of objects and the events that take place.

So imagine the persistence state of this jersey on the table -- that it's in this position [Chris moves the jersey] or it's in that position, right? So for every object in the world, the server is tracking information about what has changed about this object and which machine is this information being sent from.

For example, if I throw a grenade here, and there are a whole lot of objects on the ground in that location and they go flying, they will eventually settle down in new places. Those objects will be marked. Their new position needs to be sent to everybody in the world because their position has been changed.

But people who are a long way away don't care about those objects very much because maybe they're in a battle somewhere. But when they come over to that location they will eventually want those objects to be in the right location. So what that means is that those objects are low priority because they're a long way away. But they are marked because they do need to be transmitted eventually. So over time, the priority of those objects will rise and rise until eventually they pass the threshold to be sent."