Hacker News new | ask | show | jobs
by gremlinsinc 1959 days ago
Can you explain more on this ?

Are you wanting something like a cloud-based ... browser/cache basically a users localstorage/db/browser data would be synched in the same format in the cloud?

How are you imagining this? (Burned out dev, looking for a side project).

1 comments

Context: I started building a synced browser game, having never done anything similar before, and realized that multiplayer game state isn't supposed to be stored in a database, the way firebase works. It's just kept in a server's active process memory, so there's no reads/writes to a DB involved. Otherwise realtime speed would be impossible. I never knew this before, having never worked on it or thought about it. But if you want such a setup, you basically have to write it yourself. And that's hard.

I just wish there was a SaaS (much like firebase) where you sign up and have an API that lets you define the data that your game-state involves (which may be a large schema), and then provides you with a suite of methods for letting clients create, find, and join group sessions ("games", "matches", however you want to call them) where the game-state is synced across all clients in that session until the game ends, with each client being able to modify the game-state within defined limitations (i.e. play the game.) I suppose the server would have to know under what conditions a game ended so that it could notify all players and end the session.

It just seems very daunting to me.

You will need things like client-side prediction, input queues, dead-reckoning, entity interpolation, lag compensation etc etc which means your net code will be need to be tailored for your game. Just outsourcing it like Firebase has done with regular web apps will be really hard without making a lot of assumptions about the client. Adding server authority adds another layer of complexity where you basically need to either run the same engine on the server or simulate the same processes.

With that said, I also want something like this and definitely think it's a problem worth pursuing. I know there's Photon for Unity but I don't know what it actually provides and it's obviously tied to a specific engine.

Yes! It is a complicated problem. And it just leaves me laying awake wondering how a 19yo solved it so effectively by himself. (agar.io's author) How could he possibly have such depth of skill and knowledge at such an age?

I know, I'm side tracking from productive conversation, sorry for that.

If you're looking for resources on learning the basic principles of multiplayer games I invite you to read the very well written and illustrated tutorials by Gabriel Gambetta https://www.gabrielgambetta.com/client-server-game-architect....
On a lower level, I have been using Colyseus (https://github.com/colyseus/colyseus) which is, in the words of the author: "[...] an Authoritative Multiplayer Framework for Node.js, with clients available for the Web, Unity3d, Defold, Haxe, and Cocos2d-X.". I have been using it on multiple projects as a state synchronisation library for my browser-based games. It takes cares of all the data synching aspecta among all players in a "room". The community is very active and you will get a lot of help to begin with and scale your creations.

Of course, a lot will have to be done by you for anything like client-side prediction, server reconciliation, lag compensation, entity interpolation, but knowing that the state manages itself is already a huge relief if you are unfamiliar with these concepts.

Another project which already includes many of these features is https://github.com/timetocode/nengi. It is more opinionated and well focused on fast-paced games.

On my side, I have been creating an open-source multiplayer game for the browser that includes client-side prediction, entity interpolation and server reconciliation https://github.com/halftheopposite/tosios.

Ooh, this looks very good. I might try colyseus. Thanks for the link. My game is only a card game so it's actually a very simple use case relative to many others. But it isn't turn based, so it's still realtime.
Your spec is a little all over the place; Different multiplayer games need different setups, or more specifically different parts have different requirements. Matchmaking, lobbies, and rooms are one thing. (Database) Running an instance of a game (joining, game state, sync points, state authority, game complete) Is another. Live movement of players which dont affect game/rule state, (ie, jumping up and down doesnt score a point) but wants low latency is another.

For the middle part, i developed https://github.com/NewChromantics/PopNotPoker as an alternative to boardgame.io for easy room creation, sharing, and most importantly to me, exetremely easy game rules (all async js)

The "netcode" would be stuck on top (player movement, voice chat etc), using a bit of player meta for say webrtc session sync (or udp addresses etc etc)

This is an approach I used for 25 years on pc, console and now vr & web games; have "keyframes" where the server/authority dictates new game state to everyone, and everything else is client side predicted and throwaway

I've done this before myself for a pretty simple game and had to build the system alongside it. It's quite fiddly to get right.

I've been working on a new game on and off which is a bit less working with websockets directly and I looked at ably[0] to be that firebase like system, I've found it works reasonably well if you squint, though it's definitely not the same thing.

You can hack together a pretty nice implementation which gets you started using for example using presence[1] to store a minimal dataset associated with synced state. Then derive gamestate off that.

Which you can then expand on.

Though maybe you were wanting a more complete solution =)...

- [0]: https://www.ably.io

- [1]: https://www.ably.io/documentation/realtime/presence

I'm in the same boat as you! Looking to build a real-time multiplayer application (think Figma), and I'm not so sure of what to go for: Mongo is fine I guess but I have a feeling it'll bite me at some point. I've looked into CouchDB, as well as Redis and SQLite.

If anyone has experience with building this kind of thing, I would gladly pay for some consulting.

I made an open-source multiplayer online system/standard: http://fuse.rupy.se/about.html

It has all the parts you would need to get any multiplayer game (from 1vs1 to MMO) working.

From what you've written it sounds like it's a great implementation for solving this problem! But I'm only a so-so dev and I just can't do much without great documentation-- the tutorial section on this page just isn't enough for me to feel confident that I can wield this tool in a meaningful way.
Yeah, it's hard, even with documentation there is so much that can't be communicated efficiently.

I'm working on a client that I will try to make more accessible (just like particubes and roblox are trying to do), but no matter how you turn it you're going to need some basic programming skills:

http://talk.binarytask.com/task?id=5959519327505901449