I’m currently continuing to build on top of my LD48 jam entry. I’m currently prototyping a two player online multiplayer version and the idea is to get a brief idea on how long this will take. I’m very aware that adding a multiplayer networking isn’t that simple… so the first step is to learn and see if a multiplayer game is even possible for me to do in Unity. And while there are fine articles about the topic (such as this: Don’t make multiplayer games) I want to test it out myself before I decide one way or another.
I have quite a bit of low-level networking experience (I once built my own medium-high level UDP framework), and I don’t want to do that low-level stuff again. But Unity seems to have a decent higher level network available, and so far it’s proven to be pretty good. Here’s some challenges I’ve experienced.
So, what happens when you add a multiplayer feature?
I started adding 2 player multiplayer support on my LD48 jam entry and it really affects everything. For example, earlier I wanted to set a wooden branch on fire, and in the game it would happen like this: I’d call a function item.setOnFire();
And that’s it. Now I had a wooden branch on fire.
Add multiplayer, and… now only server sees fire on his local machine. I cannot just instantiate fire like that. Now I need to have networkViews, I need to call RPC functions. I realize I want server to be authoritative, so I also add RPC call for “pleaseLetMeFireThisStick” where client asks server to start the fire, server instantiates fire and let’s the client know about this.
And of course I then realize that actually, I don’t need to instantiate fire as a network object. Instead I change the fire ignition code so that we only track the “isOnfire” (owned by the server) and client instantiates particles locally, and server instantiates things locally.
And this was only about fire starting. Let’s not even go talk about what happens when I want to chop down some trees and I must Network.destroy() and Network.instantiate(…) things, and then realize client didn’t yet connect so he sees a ghost palm trunk…
I hope you get the point. And the point is this: I saw the tip of the iceberg when doing a single player game. Then adding a multiplayer means revealing the whole iceberg. There’s quite of bit of slippery stuff ahead.
And I keep going
Explaining “why” on the next blog post.