[multiplayer] how do I wait for synchronization ?

  • Hi,

    I'm working on a two player online minigolf.

    I read the chat and pong tutorial.

    In my game, I want to call a function only when the client(s) has finished spawning all the elements from the server (both players balls).

    Actually, the function (which targets one of the two balls) is called before the client has spawned the balls so the client can't find the targetted ball when it receives the server message sent from the function.

    I don't know if I explain well.

    The purpose is having, on the first turn of the game, each player seeing only the first player (chosen randomly) ball, whether the first player is host or client.

    The 2nd player ball will be visible only then the first player has ended his turn.

    In my events, the server immediately starts determining which ball to display in order to send this information to the client, but the client hasn't spawn both balls yet so it can't find it.

    So I'd like to wait until the client has no more balls to spawn before doing stuff.

    Any idea ?

    http://canapin.com/construct/canagolf/0 ... lf-06.capx (open two windows)

    Event 41 : this is where the server will broadcast the right ball (to set visible) to the peers

    Event 33 : this is where the client creates all the players balls : because it takes some times, the event 41 is called way before.

    If I broadcast the ball peer Id during the event 41and I create an "on peer message" event for the client, the ball having this peer id doesn't exist yet client side and that's the problem.

    Sorry, english isn't my native english and it's quite difficult to explain with so little vocabilary.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Something like:

    event

    trigger once

    multiplayer.peercount = ball.count

    action

    send message: ready for the next command

  • I'm not sure to understand ; it your events are called server side, the server side ball count will always be updated before the client's one and the issue will remain the same, right ?

  • On the peer side, you want to know when all the balls are created for the amount of players, before sending a command to the host, that all balls are present, initiating the next step of the starting sequence.

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