Multiplayer peer problem

0 favourites
  • 1 posts
From the Asset Store
The official Scirra Multiplayer Signalling Server for helping peers find and connect to each other
  • So I've been trying to create a multiplayer game, and with some success. Currently I have peers connecting to each other, a chat room with a couple commands, and a completely broken rest of the game.

    First I followed Multiplayer tutorial 4: real-time game and created a simple "you can move around and the other player sees it" game, and it worked! I made a multiplayer thing! So everything in the project to do with the player object and multiplayer is essentially identical to the tutorial.

    Anyway, after doing that I thought "the whole, [on peer connected] thing doesn't suit my game, since they're already connected in the lobby (chat room) and so it won't trigger when you go to the actual game, or more importantly, when a player dies".

    So I tried something.

    I disabled the normal method, because I was about to replace it elsewhere:

    And then I created a different method, on the host's side, for spawning an object for each peer:

    I thought a for loop would be perfect. It could cycle through each peer and assign an object to each one.

    The bit on the end is the debug method of determining what object is associated with each peer.

    It didn't work. On the peers' side, every object is associated with the host, because it was previously relying on [on peer connected] to get the Multiplayer.PeerID for when it was created:

    Having spent about 10 hours straight trying to work out a way to fix this, I feel like I've tried everything at this point.

    • Having the peers send a message to the host to create an object. This should mean the host would have a Multiplayer.PeerID to send to each peer other than it's own. It didn't work. For some reason, it still thought it was from the host.
    • Making player.peerID synced with peers. I can't see how this wouldn't work, but sure enough, same as before. In fact, I remember it doing other weird things, like having a blank peerID.
    • Having the host send a message with the UID of the object and the Multiplayer.PeerID to associate it with. Having explicitly asked it nicely not to, it somehow screwed it up.
    • Only spawning a single instance of the object, instead of the for loop, and then forcing it to associate with a single peer (with Multiplayer.PeerIDAt(1)). Again, no progress.

    So, is there a proper way to do it? Have I missed something? I need to be able to create new peer objects whenever I want, but at the moment it seems like [on peer connected] is the only viable option.

    Thank you so much if you have any advice!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)