-
Notifications
You must be signed in to change notification settings - Fork 62
Open
Description
Hey!
Motivation:
Almost every multiplayer online game has a synced clock aka remoteTime, remoteTicks, roomTime etc.
Its helps to understand when exactly actions be happened and how to handle it on the local side.
Suggestion:
When we create a lobby, we set on the server side:
_createdAt = Date.now();
lobbyTime(){
return Date.now() - _createdAt;
}
Then, we send it to the every peer.
On the client side, we have:
network.ts
private onLobbyTimeReceived(lobbyTime: number) {
// TODO we need to compensate for the RTT/ping
const compensation = 10;
this._createdAt = Date.now() - lobbyTime + compensation;
}
get lobbyTime() {
return Date.time() - this._createdAt;
}
ErikSom
Metadata
Metadata
Assignees
Labels
No labels