Syncronising time and actions.

Started by
0 comments, last by hplus0603 14 years, 6 months ago
Hello, I'm pretty new to network programming and I started writing some network code based on what I read on Glenn Fiedler's website, but I feel that my lack of experience is finally catching up with me. So I got an authority managed system right now. It's a strictly 2-player coop game, so cheating is not an issue. A player just sends serialized rigid body data of entities over which it has authority to the other player. That data is then smoothly blended with the receivers data. Now I'm trying to add "actions", like melee weapon attacks etc. In a single-player environment I'd just add a start time and calculate the results of the attack based on the difference between the current time and the start time. (Is this a good idea at all?) But for this multiplayer environment I'm not sure how that will work since there's no global concept of time. A client will just use the latest data it gets no matter when it was send. Also I probably have to synchronize the global time at some time, but how do I do that with lag and is it really needed? And how do I keep it synchronized? Is transmitting the start time of an action a good idea at all? Thanks in advance!
Advertisement
Generally, in a networked game, you will actually establish a global concept of time. Search for "time management" or "clock management" to find references -- I think there are some pointers in the Forum FAQ for example.

In general, you use one of three models: Either you show entities on the other machine delayed from the first machine, which causes time skew, or you show entities on the other machine forward extrapolated, which causes position skew, or you delay all entities (local and remote), which causes input lag. Pick one!
enum Bool { True, False, FileNotFound };

This topic is closed to new replies.

Advertisement