How do I restart a multiplayer game?

0 favourites
  • 4 posts
From the Asset Store
In this template the music plays without looping in your game
  • How do I quit a multiplayer game and restart it by going to the 1st layout and then to the game layout again? Right now when I quit and restart in game, I cannot take control of the paddle. What am I doing wrong or what am I forgetting?

    I am using the Pong Multiplayer example. I have added the following:

    on escape pressed
     reset glob vars
     disconnect from room
     disconnect from signalling server
     go to layout 'login'
    

    (and I have added an event that says: when pressed on ESC, go to first layout)

    How to reproduce:

    1. - start a multiplayer match (change the room or game name, so nobody will join or is host already)
    2. - exit by pressing ESC.
    3. - start a multiplayer match and you see that you cannot take control of the paddle.

    Observed result: cannot take control of the paddle, while no peer present yet.

    Expected result: you get to control the paddle by mouse, while no peer present yet.

    Tagged:

  • bump :)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Multiplayer signaling actions are asynchronous. If you put them in the same event as the layout change action, you will leave the layout before either of the signaling actions complete. Notice that the "Signaling: left room" and "Signaling disconnected" message logs never show up, even though there are events to log when they happen. So basically what is happening is that you never left the room as far as the signaling server is concerned, therefore the "join room" action will no longer work even if you leave the layout and come back with a new peerid/alias. The second time you go to the game layout, since you're already in a room and the auto join room action fails, the following "On Signaling Joined Room" event does not run and assign paddles to host/peer.

    If you do the following, it works fine:

    + Keyboard: On Escape pressed
    -> Multiplayer: Disconnect from room
    -> System: Reset global variables to default
    
    + Multiplayer: On signalling left room
    -> Functions: Call AddLog (message: "Signalling: left room")
    -> Multiplayer: Disconnect from signalling server
    
    + Multiplayer: On signalling disconnected
    -> Functions: Call AddLog (message: "Signalling disconnected")
    -> System: Go to Login
    
  • Thank you!

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