Game Development Reference
In-Depth Information
How it works...
By using this principle, each client will only receive updates on other relevant players. We
can't, however, just stop sending updates about certain players without also letting the cli-
ent know why, or they would just freeze in their last known position. That's why the last
message the server sends about a player is with visible set to false . However, to do
so, the server must keep track of when a player has disappeared, and not just when it's not
visible. That's why each ServerPlayerControl class needs to keep track of which
players it saw the last update in its visibleList .
This recipe focused on the networking aspects of visibility and how and when to send up-
dates. A proper game (at least an FPS) will need to keep track of obscured players as well,
not only how far away they are.
Optimization can be done in different ways, and it all comes down to the application. An
MMO may for example not be as dependent on frequent updates. In a game like that, net-
work updates can be done with less frequency, if a player is further away, and instead rely
on good interpolation to avoid jerkiness.
If we're using interpolation, and not absolute updates, we should also turn off interpolation
when visible switches from false to true, to avoid players possibly gliding to the new posi-
tion. We can also turn off updates when visible is false.
Search WWH ::




Custom Search