Multiplayer peer problem

Get help using Construct 2

Post » Wed May 11, 2016 2:58 am

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:
Image
And then I created a different method, on the host's side, for spawning an object for each peer:
Image
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:
Image

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!
B
42
S
14
G
3
Posts: 165
Reputation: 5,115

Return to How do I....?

Who is online

Users browsing this forum: R0J0hound, StillSarah and 25 guests