How do I Sync Both ways: Multiplayer?

0 favourites
  • 5 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Hi, so I am making an online multiplayer game and both players can summon objects.

    So, I use Multiplayer Sync (and it's implied that there's a host and a peer).

    The problem is that the sync only works from the host to peer only.

    But, I want the peer's changes to be transferred to the host as well so that the "sync" is both ways rather than one.

    Is there a way I could do that?

    Thanks for helping!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • But, I want the peer's changes to be transferred to the host as well so that the "sync" is both ways rather than one.

    The plugin doesn't work that way, the host should always be authoritative over changes. In your case when you want the peer to summon an object, what you can do is to have the peer to [action: send message] to the host, then at host, on peer message, you spawn the object on peer behalf. That way the object will be automatically sync over all peers.

  • > But, I want the peer's changes to be transferred to the host as well so that the "sync" is both ways rather than one.

    >

    The plugin doesn't work that way, the host should always be authoritative over changes. In your case when you want the peer to summon an object, what you can do is to have the peer to [action: send message] to the host, then at host, on peer message, you spawn the object on peer behalf. That way the object will be automatically sync over all peers.

    Thanks for your Reply. After thinking about what you've said, Here's my new logic:

    1. Peer creates object.

    2. The object's created coordinates are stored in two global variables, objectX, and object Y.

    3. Then send two messages to the host each containing the global variables, objectX and objectY

    4. Then I want to sync the sent messages to the same global variables, except on the Host's side.

    5. Then from the host side, I can do action, create object at the locations of the global variables.

    I want to do the above, but I'm having trouble at step 4, figuring out how to set my Host's global variables to the sent messages of the Peer's equivalent global variables, objectX and objectY.

  • It should be:

    1. On start layout sync object (position or None depends on cases), if object moves every tick, use position, if static, use none. Your case should be None.

    2. Peer send message object.X&"_"&object.Y

    3. Host create object at x=tokenat(MP.message,0,"_") y=tokenat(MP.message,1,"_")

    Should be just that. Your no 4 is unclear, you need to be more specific on what the global variable is for.

  • O wow it worked!!!

    Thanks so much!

    I had no clue what Tokenat meant until now. Thanks!

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