I’ve been looking around at solutions online and Firebase seems really appealing to me. It’s got tons of documentation, lots of features (auth (with anonymous auth), analytics, blob storage, etc), and doesn’t seem to be one of Google’s graveyard bound projects (hopefully).
There’s some things I’m not sure firebase can handle that I would like in my game: - complex interactions in my game. Firebase seems good for easy I/O (with their cloud functions feature). You make an api request, Firebase handles the request, maybe manipulates some data in the real-time DB, and then returns you some result. Maybe it also tells a bunch of other clients that result. If a player in my game walks forward, I would make an api request to have that player move forward, the request would update the player’s location in the real-time db, and all other players would be notified and updated of the movement. Cool. But what about more complex interactions? What if a player places a bomb that explodes in 10s? Could Firebase somehow get triggered after 10s to perform an action? We can’t trust the frontend to handle the 10s timer. Or what if I want the world to be alive, with NPCs walking around. Can Firebase run a game loop like thing in the backend to have NPCs walk around? - price: if I’m constantly sending / receiving requests from clients (ex: a client moves their mouse around the screen and I want to update each other client with the position of the mouse, that would be a lot of api requests per second) and handling each of those requests in a cloud function, I feel like that could add up pretty quickly
As easy as Firebase sounds, I’m afraid I may rely on it only to realize months later that it can’t do certain things.
Any alternatives you would suggest?
Thanks for the help!
I've liked Dapper Dino's videos for learning about these things. Looks like he's started an updated version: https://www.youtube.com/watch?v=eymqAMmnqPg
My advice is to just make the game, and implement the simplest backend possible (using a basic server/VPS) without worrying about scaling at all.
What type of game is it?
> I would make an api request to have that player move forward, the request would update the player’s location in the real-time db, and all other players would be notified and updated of the movement.
You can store all this data in memory of the server running the game loop. Note that you need a server, otherwise the game would be client-authoritative, so prone to cheating/hacking/desyncs.
I would suggest creating a Node.js server on a VPS and using web sockets for communication.
Realtime Database (RTDB) client update latency (in ideal situations) is below 100ms (blazing fast). You could absolutely track the state of the game in RTDB (e.g. players' position, artifacts, etc). You do that using the RTDB SDK and all clients listening to the same document will get updated.
For time dependant events (like bombs) you can use scheduled functions : https://firebase.google.com/docs/functions/schedule-function...
The client setting the bomb calls the function, the function updates RTDB with the location of the bomb and schedules the explosion. 10s later it updates RTDB with the explosion happening.
My 2c