P2P Public Game

Hi! I have a project I’ve been working on for the past couple of months and uses servers to play chess. I want to add a “Public game” option, which would work like this:

  • Players select “Public match”, get directed to a scene called “Connect Private”, where there’s a brief explanation of how public matches work and two buttons: One says “Menu”, the other one “Connect”. I want the game to load when two different players (or peers) have clicked on the button “Connect” (at the same time or not).

I know it sounds easy, but I still can’t beleive that I spent hours trying and haven’t figured it out yet. For the private matches you had to enter the other peer’s ID, in this case I have to have both IDs, check if both people have clicked on the button and grab two players that did, pair them up and send them to the game. I don’t know how I’ll do it if there’s hundreds of player clicking/that clicked the button.

I won’t upload the events, for now they are incredibly strange, because I tried many, many options, now I’m kind of guessing. PS: I’m using my own, custom broker server.

If someone needs specifics, I’ll gladly give them.

Thanks in advance!

1 Like

I think you would need to store the IDs of people waiting, maybe on your own server or on Firebase, and when there are two IDs or more, connect them together and delete the IDs.
…but I might be wrong, I’m not a P2P expert at all. :sweat_smile:

Hi! Thanks for replying so quickly! Do you know how to do so or where I could ask?

1 Like

I know there are Firebase actions to check for existence of a document/variable/field, so I think you could use that to check if two values are stored.
For the rest, I can’t help, but you can check out some Firebase examples while waiting for input from other people.
Aside from that, are you aware of the new THNK features? Maybe this would help you.

I know! I was just digging around it. I still don’t know how to implement it though. I’ll check out the example. Thanks!

1 Like

@arthuro555 Can you help me with this problem? I spent about 5 hours studying THNK, but I just can’t achieve what I’m trying to do! Plus, I realized that if it works, I have to re-do the private matches and the whole game, since it’s all run in P2P! Not counting all I would need to learn of THNK and wait until more is explained! In the other hand, THNK is much safer and reliable, P2P sometimes doesn’t register the moves of the pieces, but I’m sure if I learn THNK, I can replicate it better. Plus THNK is meant for BIG muliplayers, not 2 players games. Anyways, can you help me do a decision?

Can’t help here but i’d like my game to have a 2 player online option too with the same sort of easy accessibility that you have in mind. Haven’t even attempted it yet because the only example I saw so far depended on the copy/paste ID method which is a little prohibitive. It’s mainly useful to play with a friend who you already know. At least that’s how it seems to me (maybe I’m wrong). The ideal situation would be having the ability to just click connect and play with a random stranger online. When you find a solution, hopefully you’ll share it here.

You said that you’d have to re-do the whole game because it’s all run in P2P. Do you have a working system already using the copy/paste ID method?

Yes I do! How do you want me to send you the code?

1 Like

Also mine uses 6 character long IDs

1 Like

Thanks for the offer! You could drop the link here or DM me the link if its ok? In my game the player walks around like a platform game character, but they also collect letters to spell words. At the moment I have an enemy AI as the opponent, who also collects letters, but I want a two player online mode so that two human players are competing against each other. Do you think your code would work in quite a fast paced a game like that?