Search code examples
unity-game-enginemobileserverbackendgame-development

Backend for unity mobile game


I would like to create a simple match-3-like mobile game in Unity. The game will be using NFT and blockchain features. I also need a server for the game. I have experience with creating mobile apps and games, but I don’t know much about backend development for mobile games. My first thought was to create a custom server in Node.js. After a quick research, I realized that there are already a lot of different and developed server solutions for unity like Mirror or Photon.

My server has to have the following features:

  • be the authoritative server and run the whole logic of the game
  • access NFT, interact with smart contracts and send all required blockchain-related data to the client
  • supports PVP, PVE and co-op type of gameplay
  • supports a microservices architecture
  • allow for easy deployment scalability with services like AWS or Google
  • expose an APIs
  • ofc be secure and attack-proof
  • has all the features that a decent mobile game needs

As I said earlier I don’t have much experience with creating a backend for mobile games and I’m really confused about what solution should I pick. I am afraid that creating a custom server might be overkill but at the same time, I don’t know if the server solutions available for unity can handle all of my requirements.

I’m wondering:

  • What's the standard, a most common technology used for creating backends for the mobile games?
  • Is there any Unity backend solution like Mirror or Photon that supports all of the requirements that I mentioned above?
  • Is it common to have a mixed solution where the game uses Mirror or Photon strictly for running gameplay, and a custom server that e.g. interacts with smart contracts, exposes APIs, etc?

Solution

  • You will need to make your own server, but you can be flexible on how much you implement, and how much you leave to a third-party Unity server (like Mirror, Photon, or some other solution).

    For example, exposing APIs and interfacing with NFT/blockchain is something you would need to implement on a server yourself, as there are security issues with having that code on the client, and Unity integrations aren't suited to implementing these features.

    As for the game netcode: Match-3 style gameplay is easy to make yourself on a custom server, and it would be a lot more efficient than an external solution, which are usually designed for more complex games with lots of GameObjects being synchronised at once, rather than a simple game board and a small amount of state. On the other hand, using Unity netcode is a lot easier depending on how you design the game, and the tradeoff could be worth it if you find it easier.

    Ultimately, where you draw the line between external Unity backends and your custom API server is up to you. If your game has simple gameplay, then networking will not be a bottleneck even if it isn't efficient, so it could be worth the tradeoff of a secondary Unity backend solution when it involves less work.

    To summarise, Unity backends are designed primarily for synchronising GameObject state between multiple clients of a Unity game, not so much for external API calls and other functionality.

    There is no standard server technology because at the end of the day, a server is a server. No matter your underlying language or libraries, the way your server behaves to the network is defined by you. It doesn't make much difference how you implement it, because you will need to write the "glue" code between the server and the client regardless.