Code Monkey home page Code Monkey logo

Comments (5)

DoubleDeez avatar DoubleDeez commented on August 15, 2024

I haven't fully read through this yet but I wanted to comment that I have a position synchronization class started for my own game that I'm planning to move to the framework. It supports prediction and interpolation based on the expected RPC rate but there's still a bunch of room for improvement.

References:
https://www.reddit.com/r/godot/comments/8ch20v/help_with_node_sync_over_a_network/
https://gafferongames.com/post/snapshot_interpolation/

from mdframework.

DoubleDeez avatar DoubleDeez commented on August 15, 2024

As for Join Synchronization, MDReplicator/MDGameSession should already handle that for you, it will update new players with the networked nodes and any MDReplicated properties.

from mdframework.

Beider avatar Beider commented on August 15, 2024

Aye they do synchronize on join, however currently as far as I know there is no way for the client to know when synchronization is complete. Nor for the server.

The synchronizer I proposed would allow for the client and server to know when synchronization is completed. Also the game ticks I think could be useful in a lot of situation, particlarly if you are making a network game based on ticks (such as a real time game like transport tycoon or factorio, both of which work on ticks I believe).

That being said, it might be that this is not useful for the framework itself. If that is the case I would just implement this seperately for my own game as I wish to have these features.

Also I would be very interested in your sychronization class once you completed it, I am just about to start on the same thing for my game so if it is added to the framework I would be happy to help test it.

from mdframework.

DoubleDeez avatar DoubleDeez commented on August 15, 2024

Ah yeah, the synchronization state is a bit of a special case. The framework sort of assumes that the game will continue during synchronization so there's no "complete" moment, it just sends everything continuously.

That's great, I'll try to get the PositionReplicator up in the next few days, it would be good to try out some other algorithms. The current one is okay but there's some noticeable jitter/rubber-banding.

from mdframework.

Beider avatar Beider commented on August 15, 2024

So I have completed the first stage of this now locally, the game now pauses when another client joins. Makes sure every client is synched, then resumes at the same time.

Here is a video

In this video I got a dumb actor that actually recieve no further network signals except for the initial synchronized state of position, speed and direction to move. Then it just bounces off the edge of the screen. All clients stay completely in synch.

All that is left is to add a default graphical interface to show the synch progress (currently only logged) and then a timer that shows the countdown to game unpausing.

Here is how the log looks on join,

[2020-06-10 00:29:24.249][548][SERVER] [LogBasicNetworkLobby::Info] Player joined UnkownPlayer with PeerID 1397867656
[2020-06-10 00:29:24.259][548][SERVER] [LogBasicNetworkLobby::Info] Player changed name to UnkownPlayer
[2020-06-10 00:29:24.525][565][SERVER] [LogGameSynchronizer::Info] Msec response number 1 from peer [1397867656] is 3866 local Msec is 62324
[2020-06-10 00:29:24.531][565][SERVER] [LogGameSynchronizer::Info] Peer [1397867656] recorded a ping of 275
[2020-06-10 00:29:24.540][565][SERVER] [LogGameSynchronizer::Info] Peer [1397867656] recorded a estimated msec of -58335
[2020-06-10 00:29:24.550][565][SERVER] [LogGameSynchronizer::Info] Estimated OS.GetTicksMsec offset for peer [1397867656] is -58335 based on 1 measurements
[2020-06-10 00:29:25.009][594][SERVER] [LogGameSynchronizer::Info] Peer [1018386675] completed synch
[2020-06-10 00:29:25.015][594][SERVER] [LogGameSynchronizer::Trace] All clients are not synched yet
[2020-06-10 00:29:25.025][594][SERVER] [LogGameSynchronizer::Info] Peer [1058880107] completed synch
[2020-06-10 00:29:25.031][594][SERVER] [LogGameSynchronizer::Trace] All clients are not synched yet
[2020-06-10 00:29:25.143][602][SERVER] [LogGameSynchronizer::Info] Peer [1397867656] has synched 0 out of 120 nodes
[2020-06-10 00:29:26.611][690][SERVER] [LogGameSynchronizer::Info] Msec response number 2 from peer [1397867656] is 5153 local Msec is 64409
[2020-06-10 00:29:26.619][690][SERVER] [LogGameSynchronizer::Info] Peer [1397867656] recorded a ping of 2063
[2020-06-10 00:29:26.631][690][SERVER] [LogGameSynchronizer::Info] Peer [1397867656] recorded a estimated msec of -58245
[2020-06-10 00:29:26.636][690][SERVER] [LogGameSynchronizer::Info] Estimated OS.GetTicksMsec offset for peer [1397867656] is -58290 based on 2 measurements
[2020-06-10 00:29:26.641][690][SERVER] [LogGameSynchronizer::Info] Peer [1397867656] completed synch
[2020-06-10 00:29:26.652][690][SERVER] [LogGameSynchronizer::Trace] All clients synched, sending unpause signal
[2020-06-10 00:29:26.658][690][SERVER] [LogGameSynchronizer::Trace] Unpausing game in 2

If we look in the client log for the clients you can see the unpause signal reach them at different times,

[2020-06-10 00:29:26.777][267][PEER 1058880107] [LogGameSynchronizer::Trace] Unpausing game in 1.881
[2020-06-10 00:29:26.777][376][PEER 1018386675] [LogGameSynchronizer::Trace] Unpausing game in 1.891
[2020-06-10 00:29:27.094][275][PEER 1397867656] [LogGameSynchronizer::Trace] Unpausing game in 1.616

[PEER 1058880107] unpaused at 00:29:28.658
[PEER 1018386675] unpaused at 00:29:28.668
[PEER 1397867656] unpaused at 00:29:28.710

So even though there was over 700 ms difference in signal arrival all peers unpaused within 52 ms of each other. The only reason the last client is so far off is because it just joined and I still didn't make the server wait for a higher confidence on it's TickMsec value (if you see in the server log we only had 2 values, it is pretty accurate around 20). Which I probably will do in which case I assume all clients will unpause within 10 ms of eachother regardless of ping.

from mdframework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.