How do I sync host and peer in a multiplayer turn based game?

0 favourites
  • 2 posts
From the Asset Store
Hand-animated Sprite Base for isometric game/animation development
  • Hi all,

    I released my game “Cornhole Duels” few days ago, that is a turn-based game, with the possibility to play only on local computer in different modes:

    - versus cpu

    - versus player

    - training

    The game is simple, when global variable Turn is “Player 1” then you can use arrows up and down to aim and then press spacebar to shoot. The same controls when turn variable becomes “Player 2”.

    Both players have same simple controls.

    Now I’m trying to implement online multiplayer and I was able (following tutorials) to arrive at the point where peer joins the host’s room.

    I can’t understand how then to make everything working with syncs.

    I created Host, Peer and Common group.

    Do I have to put my “game core functions” under Host group?

    Do have I to create single instance variables of objects in the game layout and then update these and send messages to peer with updated ones?

    Do I just need to sync objects?

    Have tried with messages but just achieved how to see same texts for host and peer.

    If anybody could help me I appreciate.

    Just let me know and I’ll share with you the capx of the multiplayer version, if needed to better help me out.

    Thanks and regards

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You should do read and follow the multiplayer tutorials.

    You can consider the host to be the "real" game. Syncing refers to updating synced objects' properties (position, angle) on peers to match the host's game state.

    Peers send their inputs to the host via input states or messages, and the host then applies those inputs to the game objects, which are then synced back to peers.

    In a real time game, to hide latency, peers can also apply their inputs to their local copies immediately when pressed by using local input prediction.

    Syncing objects and local input prediction are sometimes not necessary in a turn based game, given that results of inputs are deterministic. That is when the result of any particular input will always be the same on any device. Messages can work fine in this case for peers to communicate with the host either what was input, or the result of what happened after the input (or both). If not using synced objects, the host will then need to forward the same message to all the other peers. Naturally that doesn't apply if there are only 2 players involved.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)