Game Development Reference
In-Depth Information
The following illustration shows the lag for the updates coming over the network.
Observe that the lag is not a constant, even though the originating client is sending
the updates at a uniform time interval. The receiving client does not get it at the same
interval. The illustration also shows the interpolation of the remote ship position
between the update intervals.
Pulse SDK eases the issue by keeping track of the lag for each client and is recomputed
quite often based on the server load. To find the lag between a client and the server, we
simply get the value from the corresponding GameAvatarClient instance.
The lag value we want to take into account is the average lag originating from client
to server and the average lag from the server to our client.
The following lists the method on SpaceShip that processes the incoming update:
public function onUpdateRemote(posX:Number,
posY:Number,
speed:Number,
remoteLag:int):void {
m_rc = posX;
m_ry = posY;
m_speed = speed;
// As this came over the network, we
// will predict the ship's position at this
// moment. For this we assume that there was
// no change in speed!
var myLag:int;
myLag = m_av.getAveLag();
var totalLag:int;
totalLag = myLag + remoteLag;
trace("Total Packet Lag: " + totalLag);
 
Search WWH ::




Custom Search