Search Unity

Creating own backend for a 2d game with websockets

Discussion in 'Multiplayer' started by Jeunas, Jul 6, 2019.

  1. Jeunas

    Jeunas

    Joined:
    Sep 5, 2017
    Posts:
    14
    Hello

    My friend and I are trying to create a mobile 2d game, with a backend in Java Spring Boot, where multiple players can attack a monster. We thought that it would be cool that when someone does damage to the monster, other clients show that damage without the other clients 'asking' if there are changes. I researched this a bit and found that websockets (STOMP) could be the answer. After a lot of trying different things I can't really get it to work. I can get the backend to work, but I fail to integrate this into Unity, I can't seem to be able to 'subscribe' to a route so that the Unity client can receive the messages that the server sends. Is this the way to go or should we try something else?
     
  2. DrIndie

    DrIndie

    Joined:
    Jun 4, 2017
    Posts:
    3
    I've little knowledge about this topic, I'd tell you how I'm managing my game backend with little experience if you're interested in changing your approach.

    Firebase (Google Backend As a Service), provides Unity SDK which integrates authentication, push-notification, real-time database (via websockets), and cloud-function (for custom backend logic). You can develop simple-medium complexity games with it pretty easily or integrate it with Google-Cloud-Platform in case your backend requires more advanced products (which is unlikely).

    Features:
    - Authentication (Anonymous, username/password, and a lot more) totally free.
    - Real-time database (connection via Websockets) which has a sync functionality between connected clients to a specific node (room).
    - Unity SDK.
    - NoSQL database.
    - Cloud-funcitons for custom backend logic.
    - Total integration with other GCP products.
    And a lot more.


    I'm trying it for my game for a year now, really recommend it. It's very easy, and you can develop a complete, scalable and secure backend without advanced experience in networking and server securities.
     
  3. Jeunas

    Jeunas

    Joined:
    Sep 5, 2017
    Posts:
    14
    I have thought about Firebase, but I do a lot of checking in the backend that I don't want to leave to the client so the user can cheat less easily. Next to this concern, is it possible to update all clients with a message when some values change in Firebase?
     
  4. MrsPiggy

    MrsPiggy

    Joined:
    Jun 13, 2018
    Posts:
    154
    Creating your own backend is a very tall order. It requires experience and lots of time, I wouldn't recommend that unless you're really into network programming and building servers. Since you're already working in Java why don't you take a look at SmartFoxServer. It seems like the kind of product that would suit your use case. You can write your own game logic in Java and let the server deal with all the low-level stuff. It supports a ton of platforms, html5 included and it comes with lots of material and documentation to study.
    Take a look at their website: www.smartfoxserver.com and see if it's what you need.
    Good luck
     
    Joe-Censored likes this.
  5. Jeunas

    Jeunas

    Joined:
    Sep 5, 2017
    Posts:
    14
    Thanks for your reply. I will look into it!