Game Dev

Networking (bis)

It’s funny when you go back to your project after a break and you realise most of the things you did before leaving were actually shit, isn’t it? Yeah, that was my feeling 2 weeks back regarding this “Networking” implementation.

Changing the game from a single player to multiplayer seemed quite straightforward at first glance. Especially when Unity provides such a page: https://docs.unity3d.com/Manual/UNetConverting.html

But it all depends on your code base and your understanding of network challenges… My code base was quite big already I guess. But still, size isn’t what matters the most here (and keep your dirty thoughts for yourself). The biggest difficulty is the networking itself. It takes quite a time to get used to Unity’s way of handling networking events (via Commands, Client RPCs), handling synchronised objects (via NetworkIdentity, Network Manager, Network Transform and Animator), handling of players (server, client, with, local player with or without authority and so on…). And once you are done understanding, you try, then you fail, then at some point you half succeed, and finally you start over and fail again. That was my own experience. I believe the more you wait to integrate such a feature in your game the more foolish you are. Of course, if you know upfront networking is relevant for your game, do it upfront. Don’t copy me. And I won’t copy my own self in the future either. 🙂

That being said. Here I am, fixing networking issues. The good news is, since my enemies have most of their states in common, upgrading to networking was quite easy once the state machine itself got refactored.

networking_bis.gif

 

Advertisements
Game Dev

Networking

Yeah.. I know I may be doing a big mistake here. Since most of the game mechanics are there, ready to make a single player adventure, I could simply continue on that path till I ship something… But no… I changed my mind. Again. But, before killing me, let me explain the “why”.

I’m making this game for fun. Having a deadline is a good thing but I don’t have one, and I don’t think I’ll bother with that anymore. Not for this game.

So, I decided to make it ready for multiplayer. This way you can play the adventure solo or in coop (2 players, no more). Why? I simply asked myself “where is the fun in this game?” and couldn’t come with an answer. That’s where my poor game design skills show ! But the networking will allow me to place the game in a less common category. So even if the gameplay doesn’t shine, at least, it will have a coop mode to step out of the melee.

Then, you could ask “why not get the networking done once the regular solo game is finished?” : Well, the networking requires a specific architecture (client/server) where each of the clients can be properly identified and synchronised with no conflicts in their 3Cs (Camera, Control, Character). It means : having the networking from the very beginning or go with refactoring. And here we speak of refactoring… A lot.

I already have the basic things working fine other the network : HUD, controls, cameras, and even a friendly fire (I’m not sure I’ll keep it though).

multi