Replicating Player Movement explained how to properly sync player movement between the player's machine and the server. All of this happens between owner and authority of the object. This chapter on the other hand explains how to use the movement replicator to sync objects that don't have a player.
The ZCom_Replicate_Movement class can also be used to replicate movement of non-player objects. In contrast to replicating position variables directly, the movement replicator will only send updates when the movement of the object in question changed in a unpredictable way. In more detail, the movement replicator will feed position, velocity and acceleration to proxies (clients) which in turn extrapolate with this data until a new update arrives. New updates are only sent out if the authority thinks, that the proxies can't extrapolate correctly anymore with the data available to them. (Note that all this happens also when replicating player movement)
Extrapolation is another word for making educated guesses. But when an object or a player suddenly change direction, the extrapolation is instantly wrong, as it works on outdated data. When a proxy receives an update with a new movement direction, it might have extrapolated to a wrong position already resulting in a visual snap of the object to the new, updated position. To counter this and smooth out the snap, the movement replicator does interpolate the object position to the updated version using Catmull-Rom splines. The time it takes to finally reach the real object position is adjustable through ZCom_RSetupMovement::setInterpolationTime(). After the position has been reached through interpolation, the replicator will automatically switch to extrapolation again, guessing the object position until a new update arrives again.
Using the movement replicator for non-player objects is really easy. All you need to do is setting up the replicator exactly like in example 7. The only difference is, that you do not assign an owner for the node. Without an owner, the move replicator has only proxies, so the whole input handling complexity is not in use. On the server, you call ZCom_Replicate_Movement::updateState() regularly. The replicator will sort out when updates are necessary. The clients just need to regularly call
to get the currently interpolated/extrapolated values.
This leaves you with regular calls to updateState() on the server and the get* family of functions on the client to get a bandwidth efficient and smooth movement replication.
This file is part of the documentation for Zoidcom. Documentation copyright © 2004-2008 by Jörg Rüppel. Generated on Sat Aug 16 15:26:51 2008 for Zoidcom by 1.4.6-NO