GDevelopApp / GDevelop-examples

Repository of examples and templates for GDevelop - the open-source, no-code game engine
https://gdevelop.io
54 stars 20 forks source link

Match Making System Example #427

Open planktonfun opened 1 year ago

planktonfun commented 1 year ago

Describe the example

A matchmaking system using with p2p and firebase consolidated in four events to make it simpler for developers.

image image

Flow:

sequenceDiagram
    participant firebase
    host->>firebase: register as host in the pool
    client->>firebase: finds a host from the pool
    client->>host: connects to host
    host->>client: checks for enough players
    host->>firebase: remove itself from the pool
    host->>client: sends client to next scene
    host->>host: sends itself to next scene
    client->>host: disconnect and restart scene on connection timeout
    host->>host: subtracts client count upon client disconnection

Requirements is a firebase account and a few tweaks:

1.) Go to firebase project settings then get config then paste it in gdevelop settings (important: don't forget to add double quotes to the keys ) image image

2.) Enable anonymous login so users don't need to login to use the server image

3.) then finally enable realtime database, change its rules and use that as a prefix on the matchmaking action image image

Checklist

Game folder

matchmaking-example.zip

Bouh commented 1 year ago

I wanted to point that if the user need to configure Firebase the instruction needs to be added in the description of the extension. Or add a help link leading to a new page on the wiki.

Can we have your opinion @arthuro555? Especially for the multiplayer structure, and the usability of events?

I ask you because you seem to me to be the person with the most experience in multiplayer with GDevelop :)

arthuro555 commented 1 year ago

I'm gonna be honest, imho, it's a big mess. I can't see anyone learning anything from this example. Most of the logic is contained within a "matchmaking" extension that doesn't just do matchmaking, is messy, and has JavaScript code sprinkled everywhere.

Additionally, P2P & Matchmaking is not a very good match... P2P, by design, sends both local and public IP addresses to whoever connects, and while that is OK when playing with friends, that is generally pretty frowned upon when playing online with strangers.

planktonfun commented 1 year ago

I rarely seen developer make multiplayer games, main reason is of its complexity, please elaborate on why simplicity is frowned upon?

arthuro555 commented 1 year ago

You got this backwards, simplicity is encouraged, but your example and extension are the inverse of simple. The events are not easy to understand because of how messy they are, by introducing firebase and P2P users need to learn and understand their setup (and I have seen oh too many people struggle with just that), the extension, by being not on the extension repository (at least as far as I know), will confuse users that try to apply the example to their project...

Not to mention, quality is just as highly regarded as simplicity. As far as I remember, your networking is full of anti-patterns, the example and extensions events are super messy and lack insightful comments/groups, is unoptimized...

This makes this project fail at being an example, as an example is supposed to show a clean and correct way to do things for people to learn from. Nobody can learn anything from that because of the sheer complexity, and even if they could they likely shouldn't, imho.

planktonfun commented 1 year ago

Everything is consolidated in 4 events, its simple as it can get. developers won't look inside the extension, and since its a community extension, code breaking standards is unnecessary. Its like saying users will check gdevelop source code in order to implement a simple hello world.

planktonfun commented 1 year ago

Plus developers only look for functionality over code standards

Remonvs commented 1 year ago

I am trying this out but the Firebase instructions are not clear enough. It would need to be a neat step by step instruction. How the and which strings need to be set up in the firebase properties of Gdevelop. Including creating a new project and generating new webkey. It would be also nice if the example simply comes already configured to a existing firebase host. That way one can simply see it immediatly working. It is far from easy at this moment. I would still prefer to use the websocket extension as it has more possibilities of making your own server. I think the idea is very nice but it will lack a lot of possibilities. Also p2p most often stops working as soon as one is not in the same network as the other user.

planktonfun commented 1 year ago

I am trying this out but the Firebase instructions are not clear enough. It would need to be a neat step by step instruction. How the and which strings need to be set up in the firebase properties of Gdevelop. Including creating a new project and generating new webkey.

There's a link in step 1: https://wiki.gdevelop.io/gdevelop5/all-features/firebase/quickstart Which step are you stuck with? I could guide you step by step and I'll revise the instruction that is not clear after.

It would be also nice if the example simply comes already configured to a existing firebase host. That way one can simply see it immediatly working.

Updated !update MatchMakingExample.zip

I would still prefer to use the websocket extension as it has more possibilities of making your own server.

well yes, the extensions responsibility is solely for match making logic, not everything. It depends on the developers requirement.

also the cons and pros vs websocket server, own nodejs server:

  1. Its free up to a certain limit, you can check here: https://firebase.google.com/pricing
  2. You don't have to keep a server running, you can use serverless service too but it would be too slow for a matchmaking system.
  3. since there are no servers, no server coding needed
  4. server logic is on the client side, you don't have to perform maintenance and restart the server for every code changes

    Also p2p most often stops working as soon as one is not in the same network as the other user.

    What do you mean? I tested it with mobile data and local network (2 different networks), still works.