pick up an item, and they would both get that item because the player 1’s “I picked this up" message would still be being relayed to the server while player 2 picks it up. This means 2 players could perform the same action at the same time, i.e. With a relay server you're essentially just passing on messages - sure you can do some validation over whether the message is “valid” according to your game, but as you’re not hosting the game on the server it’s not a source of truth. Server as the server - Relay Server By being an externally hosted server you don’t have to worry about whether a player can reliably connect (everyone can go to ) - with a relay server your server acts as a middleman for all messages. Also not all routers allow this tunneling to work, so even if it was reliable you can’t guarantee that every player will be able to use it - so also not a good option here. The main problem with this is reliability, and I couldn’t find anyone who could give me information about UDP Tunneling reliability on a large scale - just random anecdotes from personal projects. When your friend also makes a connection to the server, the server swaps your details to each other, now your friend has your host’s IP + Port that they connected with, and vice-versa.Īs these are open (since pinging the server) you can then keep these open and communicate on it and the server is no longer needed. The idea of UDP Tunneling is essentially (prepare for a really bad explanation) where you have the host make a connection to a server, which will be on a specific port. TLDR: For APICO’s multiplayer we did TCP sockets “connecting” together through a Node.js relay server, the host player’s world is shared to all joining players so they all have a copy and then we only worry about relaying any actions made by players to keep them all in sync.Ĭlient as the server - UDP Tunneling This would be the same idea as above, except using the concept of UDP Tunneling to make a connection between the players without the host needing to do any port forwarding. I’ve tried to order it in the way that I actually wrote the multiplayer stuff at the time (I finished it all off a few months back now!), but it does take a few detours as you might expect from one of my thought dumps at this point haha Obviously there’s quite a lot of approaches you can take to multiplayer so this isn’t any sort of “this is what you should do”, just what I decided would be best for APICO and where it ended up taking me - I don't feel like there's enough deep-dives with indie games and I always find it interesting when there is! Me again, back with some bullshit! As some of you might have seen, we recently announced that our game, APICO, will have online multiplayer co-op - I thought it’d be a good opportunity to do a post like the one I did a few months ago around lessons learnt but from the perspective of adding multiplayer with GameMaker Studio 2 and the things I did!