The eleventh episode of Jelly Brawl's devlog is out now! Feel free to either read the written version below or catch the five minute video version on my YouTube channel right here!
Online Multiplayer is coming to Jelly Brawl!
So why am I doing this? Good question. I’ve received one question about Jelly Brawl more than any other, will there be online multiplayer. And I want this game to do well so I guess I gotta give the people what they want.
So how do I do this? Well I have to start by choosing a networking framework cause lord knows I’m not making that myself. I went with photon and more specifically their PUN package for a few reasons. Number 1 Photon has been around for a while and proven they can keep up with demand I can rely on them to provide good support and they're system is easily scale-able. Number 2 the API is pretty high level which is nice cause I need this done fast. Also I am baby when it comes to dealing with actual networking code
So what’s the implementation plan? I don’t want to rewrite all of my game systems and input systems that I’ve developed just for this. Essentially I want to layer all my networking code on top of what I currently have. I will develop a similar system to my input management that I created a while back except it will be shared across the connection. I have a NetworkInputManager that is made when a host creates a lobby and is instantiated for any client who joins as well as updated. This keeps track of how many players are currently in the lobby and basic information about them.
To accompany this, each player gets a network input object that is shared across all clients as well and has values for each button. So when you press a button locally your network input object, it signals the networked object as well so that it can be reflected in other clients games. This way I don’t have to change a single line of input code as my network inputs do the interfacing for me as if they were controllers. I manage this by only allowing you to write to your own network input object while anyone who is not the owner has to be reading the stream to check for writes. This works surprisingly well and keeps overall data needed to transfer down.
However, while this should cover everything in theory treating everyone as if they’re local and simulate all as normal, turns out simulations aren’t consistent. So players will actually diverge in their actual locations quite quickly. To counterbalance this I have every client send their local players location, velocity, and rotation to all other clients to update accordingly.
But this creates a new issue. What do I do when you interact with another player?
If you’re the only one in charge of your location, how can another player knock you about? Because there will always be a slight delay between them sending the fact that they are moving to you they will run into you on their screen before you can register and send it back causing you to be unaffected for a few frames on their end and ultimately making the game frustrating.
Right now my workaround is to instead transfer ownership of a players physics to whoever they collide with so the one who started the collision gets the immediate feedback and ownership to the original client is restored upon input. And this works but it’s far from perfect.
The long term solution I am looking into would be that no one truly has control of their physics and instead they are all simulated only on the host/server and the data is returned to everyone for them to respond. This would create slight input delay theoretically but reduce the spikes of possible lag upon interaction. However, because this solution was discovered by me later in the week it would involve me rewriting a bit of my network code which I don’t currently have time to do so I am going to return to it to finish the job in a few weeks.
However, for now. I have a mostly functional multiplayer in Jelly Brawl! I’ve got the back end sorted for quick matchmaking as well as private lobbies so you can host one with just your friends. So for now the game is pretty much playable in a multiplayer game other than some synchronization issues.
In the meantime though, I am preparing a new patch for the currently Public demo! I mentioned in the last devlog I would be releasing thee demo and it is currently out and about for you all right now! The patch will feature some new content such as a new conveyor obstacle. fixes and improvements. As well as some changes to accompany the Steam Games Festival which Jelly Brawl will be participating in!
I will be hosting a live dev chat the opening day of the festival June 16th at 1pm pacific standard time. The chat will be in the Jelly Brawl discord which you should totally join if you haven’t already or you can post in the Steam forums, @ me on twitter. I’ll be around!
Next devlog I’m hoping to go over the numbers from the Steam festival as well as the demo so make sure to stick around for that by subscribing and maybe turning on notifications. Do people do that? I’ve actually never done that if I'm being honest but I respect it. Anyways I’ll see you all next time when i tell all.
Join The Discord!:
Let me know about the new changes and what else you would like to see Thanks for taking the time to read/watch!