Does single player code translate well to multiplayer?

So as per the advice ive seen in relation to the engine, i wanted to start with the most complex feature of my game first. Which is networking. Which i dont understand at all. Which really confuses me to the point that i dont actually do work and my head just hurts.



So that being said, does code made for one user translate fairly well into code that would be used by multiple users.



I know that there is server side things and client side things that would be different from just a single player application working.



But say i got good code for my character walking around the world. Does that code have to basically be re-thought from scratch when i want my player to walk around on a world on a server? I feel like if you made a game singleplayer and made the exact same game multiplayer the code would never match up beyond variable names and other such conventions. Im basically trying to see if i have to invent 2 different wheels to make it work.

Well, if I were you, I’d try to start with the simplest part of your game. Networking is really hard to understand, and even harder to master.

As you seem to be at the beginning of your “game career” I suggest going with the singleplayer version without thinking too much about netwroking yet. Every game has some “rewrite phases” at some points when you find that some of your systems need to be extended so that will probably happen anyway. Since there will be many problems small and big coming towards you I guess its best tackling them without the added complexity of networking in the background. This will give you a solid ground to work on (also experience/knowledge wise) that will make it much easier for you when you start a networked game (or transform your singleplayer one).

To anwer your last question, much of what you coded surrounding the local player can remain the same, however depending a bit on how hacksafe you want your game to be. Keeping everything related to local player on the client side means an open portal to hackers, if that is of any concern to you.



Other than that, networking can be built on top of your single player code assuming that you made your world manager in a good way.

I will echo some of the others and say you may want to skip multiplayer now.



If you do networking properly then networked version of the game will certainly be very different. While you can design a multiplayer game to work multi and single player pretty easily, in my experience, trying to shoehorn networking into a single player game takes about as much time as rewriting the game from scratch. Unless you already knew what you were doing and took those precautions in the first place… in which case we wouldn’t be having this conversation.



Finish a single player game. That’s pretty hard already. For your next game you can tackle multiplayer from the beginning.

@pspeed said:
I will echo some of the others and say you may want to skip multiplayer now.

If you do networking properly then networked version of the game will certainly be very different. While you can design a multiplayer game to work multi and single player pretty easily, in my experience, trying to shoehorn networking into a single player game takes about as much time as rewriting the game from scratch. Unless you already knew what you were doing and took those precautions in the first place... in which case we wouldn't be having this conversation.

Finish a single player game. That's pretty hard already. For your next game you can tackle multiplayer from the beginning.


Exactly what I'm going to do, if I can. I'll go and try to throw a networking in my single player game. If it took me more than 6 months to put the networking, I'll give up.

I wouldnt put timelimits in, networking can be very simple or ultra complex depending on game type.