Questions about Multiplayer

0 favourites
  • 4 posts
From the Asset Store
The official Scirra Multiplayer Signalling Server for helping peers find and connect to each other
  • Hello, few question about the Multiplayer plugin,

    1. Does the built-in plugin handle immediate reconnection to the host when kicked for no reason or disconnected for timed out ? I've read people had problem with reconnecting and made request for the plugin to reconnect himself from inside C2 code.
    2. How to recreate synced objects that have been destroyed after long timed out and synced them again properly ?
    3. And how to re sync objects between host and peer for a peer that manually (by C2 events) reconnects to host after being kicked or disconnected ? Do I have to recreate objects or does C2 respawn all synced declared objects when a peer connects ?
    4. My project is a real time RTS with 4 players max (1 host and 3 peers) with lots of objects synced and few peers. I did optimize and minimize the data transfered and synced objects. I tested outbound bandwith from host to peer with like a hundred synced objects and ponctual game events sent as messages and got at most 32kB per seconds for 1 peer (so 96kB/sec with game room full). It is suitable ? I tested it online and game is smooth but I encountered not so rare objects desync and disconnection.

    I hope it's clear enough :)

  • You'll have to manage 1,2,3 with your own events.

    The plugin doesn't have that built in.

    For #1, have the peers save the name of the room, and if they are disconnected, reconnect to the saved room name.

    For #2, They should automatically be recreated when something about them is updated that should be synced. The reason they time out is because they don't have any synced data changing over about 3 seconds. I found that if you have the host constantly change a synced variable, such as a bit from 0 to 1 every second or fraction of a second, then the object will be less likely to timeout. There will always be rare occasions that they do, and you will need to implement a means to resync the data of any unsynced variables when those objects are auto-recreated(when something synced in the object changes).

    To do this, you can have an unsynced variable such as "sID".. and the host can give it a unique number, then send that number to the peer. It will act like a tagname for the object. Then when an object is auto-recreated, if that variable is set to 0 (default value)- then that means it was recreated and there are potentially unsynced data. Have the peer send a request to the host to send them the unsynced data of that object (the variables that aren't being autosynced).

    This way, you will be able to resync the object's unsynced variables of the objects that timed out and were destroyed,recreated. It is a bit long-winded, but I have successfully implemented this procedure and know it works. It just takes a bit of time and testing. To test it, you can simulate the latency via the event that adds simulated latency and then minimize the browser to force the host to stop sending data- this will make objects more likely to time out- in which case you can then test if things get recreated when you maximize the browser and allow the host to continue sending data.

    For #3, if the objects are synced, they should be recreated when joining. The peer should destroy all objects prior to joining. The synced objects will be created. If the variables of those objects are synced, the variables will be updated. If not, the host will need to send a message to the peer with the current data for any unsynced variables in the object.

    For #4, I don't know. You can try simulating latency and see if it still works. That will give you an idea of real-world situations when lag/etc is incorporated.

  • Thank you Prominent for your complete answer, I will try all of it.

    Another thing maybe : have you already made some bandwidth tests for a multiplayer project ? If so, what kind of project and what amount of data transfered ?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I haven't. My project is basically a deathmatch style game where players join and run around and fight each other. So maybe 16 players- and various objects.

    The multiplayer plugin is designed to automatically not resend data if it doesn't change (synced variables), this is to help lower the amount of data being sent.

    I basically just try to limit whatever I need to sync. If there is a way to let the peer handle stuff, I will do that. Like if an object is picked up by a peer, then host sends signal to peer that it picked it up.

    A small rts game with a few players doesn't sound too bad. I would think you can design it in such a way so that only objects nearby players are synced, or exist at all on the host, etc.

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