Posted August 13, 2021 by Juki
#multiplayer #floating origin #unity
Well, this took longer than expected!
I've wanted to add multiplayer since very early in the project and I thought I was doing the right thing by doing it early.
NO. From the start. The start, every time. Anything else is madness! This particular ticket grew and grew into a 2 month monster.
I started by creating a simple proof of concept which actually only took a few days. This POC is available here to play around with and focuses on handling the floating origin / infinite world size problem in a multiplayer mirror environment. See the above video for more information on that.
But really it wasn't the positional syncing that caused me so much grief - it was the state management and ripping out all the existing loader logic to handle that with lobbies etc.
Then it was all the dumb stuff you never really think about - in a free roam environment, where do you spawn new players? How do you make sure they don't collide? I eventually ended up going down this awesome Fibonacci lattice approach to generate positions and test against geometry and other players, increasing the radius until a successful position was found.
40 spawned test clients
Ultimately, I think I've ended up with a solid foundation to build on - really not much has changed from a gameplay perspective but now you can do it with other people and that's not nothing.