How do I properly use sync and multiplayer ?

0 favourites
  • 5 posts
From the Asset Store
The official Scirra Multiplayer Signalling Server for helping peers find and connect to each other
  • Greetings.

    First off, I do know there is a tutorial on the subject, but it seems a little too much complicated for me. I haven't made much with Construct 2 for now, so I am a beginner and I have trouble messing around with the multiplayer object and especially with the sync action.

    I understood how the action was meant to work. The host's version of the position of an object must be the original one, meaning the host must send the position of their game to all other peers. I also understood that peers were meant to send their inputs to the host so the host could make in their game what actions the peer intented to do - move, attack, etc. But there is the thing - I just don't get it how this is meant to work. Even after looking at the example project again and again and trying to figure out how it works. My aim is the following :

    • In the game I created, there is a title screen which only goes to the actual layout if both the host and the unique peer (it is meant to have only two players for now) have checked a... check box indeed. For this part, it works. Basically, the way it works is that when the peer checks their check box, it sends a message with a specific tag to the host (the value is unused). If they uncheck it it sends another message, which when it will be received by the host will change back the value of a global variable to 0 (it changes to 1 when receiving the message that is evidence the peer checked their "Ready" check box).
    • If the host has their check box checked while the global variable which indicates if the peer has their check box checked or unchecked is equal to 1, both of them go to the layout. I made it simply : Host sends a message which, upon receiving, will cause the peer to go themselves to the layout, while the host will go to the layout directly after sending to the peer their message. Basically, they get on the layout at nearly the same time.

    For now this method works, at least for two players. Now we are about to reach the part that annoys me. Let me explain what this is meant to do, and what this actually does.

    • When the peer starts the layout, they will send the host a message containing their peer ID. Once receiving the message, the host will create an instance of the object I named "Peer", which is basically a character. The host will then store the ID of the peer in a proper instance variable on the character, using the value of the last message that was sent to the host - which normally, contains the ID of the peer that sent it.
    • It then associates the "Peer" object that was created with the ID that was contained in the message, using the same method again to pick the value. The object "Peer" should now be properly linked to its actual player and has their ID stored in an instance variable.
    • It then changes the instance variable "color" to 1. This does not matter here. It is just made so the "Peer" object has a different color than the host's. Here I haven't made one yet for the host but it doesn't matter for now because I already met problems...
    • And then it finally syncs the "Peer" linked with the player over the network. So this is what I'd like to see :
    • The "Peer" object being visible on both the host's and peer's games.

    What I actually get to see :

    • The "Peer" object is indeed created on the host game, but I have no clue if it is indeed linked to its peer. Furthermore it does not appear to exist at all on the peer's game, even though I synced it over the network ! Why ?

    So this is the problem I encounter. I will leave the .capx in case anyone would be kind enough to help me understand what's wrong.

    Thanks a lot.

    Hoping for an answer.

    dropbox.com/s/wxty6lf02n6b4y4/Multiplayer_Test.capx

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Please, can anyone help ?

  • Welp, is this a help forum or... ? I'm starting to think it was useless to wait.

  • Welp, is this a help forum or... ? I'm starting to think it was useless to wait.

    Patience is a virtue and you should remember that many people here will help you when they have time.

    You need to study the multiplayer full-game example that comes with c2. Many of the events contained in that demo are necessary for the multiplayer plugin to work properly; I am not sure if you have followed any tutorial or example because many events are missing.

    Edit:

    For example, where do you create the peer player? Where do you assign the peerid to each player object variable - where do you send multiplayer message "PeerID" (the event line 5 is incorrect in basic c2 concepts)? These events are missing and are part of the problem you have encountered.

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