added multiplayer - 29 Jan 2022
The foundations for multiplayer are now up. First off, it is VERY unstable. Chrome and safari work better than firefox. Though whatever browser is used, multiplayer will still be a buggy mess. Even though multiplayer is far from “ready”, I decided to put up anyway. I figured it could be fun to play around with. Not everything needs to be perfect from the start.
Also, many of the issues are only apparent when I run the game online, as opposed to running local builds. Pushing multiplayer to the website allows me to debug in the intended execution context. While I could set up a test server specifically for this purpose, I see no harm in letting everyone see how janky everything is at the moment.
Issues that I know about so far include the following:
- Synchronization issues while editing (placing and deleting objects, etc.)
- Synchronization issues for entities (players, characters, items)
- Connectivity issues, most notably in firefox
- Lack of client side prediction
- And more!
I’m using webrtc, which means that agreeing on what is the proper state of the game is a bit tricky. Because of latency, drift, and so on, peers will disagree on the exact positions of, whether or not an enemy has been killed, etc. With a classic client/server setup, clients rely on the server to decide on what is the “true” state of the game. Here, I’ve decided to let the host peer to be the source of truth for most things. There are exceptions, mainly that every peer gets to be the authority on their own player.
I also have concerns regarding user friendliness. For example, every player can switch the game mode which is kept in sync. So if someone decides to go back into the editor, the game gets reset for everyone. This can be incredibly frustrating. For things like these I need to come up with a good strategy. Perhaps only the host can change the game mode. Perhaps everyone has to agree to a mode change. Or perhaps everyone can be in different modes and when desired sync their state and play together. The last one seems hairy to implement though.
Anyway, I hope some fun can be had with the super-janky multiplayer. Expect it to become more stable over time. If you want to try it out just open the game and click the button with the three ducks, shown in the image below.