How hard is to add multiplayer support in a game that was not coded with that in mind?

Or in other words, should I take care of the multiplayer part from the very beginning?
If I ignore it, will it be too hard to implement in a later stage?
In general terms obviously, I know every case is different.

If you ignore it then later you basically build an entire new game.

I find I save myself a lot of work if I work not only on multiplayer overall from the start, but every individual system as well. There have been a few game systems I have worked on where I didn’t pay much attention to multiplayer during initial design, and when I had to revisit the system to implement multiplayer correctly, I ended up scrapping a fair bit of work, which becomes an even larger problem with interconnected systems.

What I’ve described is best-case scenario. I have some hobby projects that I have abandoned as a result of poor planning when it comes to multiplayer.

#1. If its a high-speed high-precision game with lots of custom movement then PANIC or call Rama… :stuck_out_tongue: … Otherwise it’ll probably be a major PITA… But it is possible to add multiplayer if you’re still at prototype stage and / or the game is quite simple (card-game / simple-FPS / strategy-spaceship-shooter etc). Its still an unpleasant experience overall though, just to warn you. Your guts will probably sink as you watch all your single-player hard work crash and burn just by typing 2+ into ‘Play’ … Number-of-players box. Any work on split-screen / local-multiplayer won’t help much either, in fact it may complicate things. Overall RPG / RTS games with 100’s of NPC’s / Players will be nearly impossible. And rewind physics / custom-movement will be tricky to get right and may take adjusting your mindset to…

#2. Even after all the core replication work is done (solving gotchas like net lag and headshots in a fast moving FPS etc), you still have all the matchmaking / online-sessions / hosting work to do, each bringing its own gotchas. But by far the biggest issue is just getting started and finding tutorials / wikis / docs that actually work etc. People rave about eXi’s doc. Some find a multiplayer tutorial series that helps them. Essentially I found the most useful thing was just throwing that all away for now and making a long list of all things that were broken and getting on with fixing each one. BTW: Try to avoid Level-Streaming / Large-Worlds traps.

#3. You’ll still have to optimize later and formal learning resources will help then… But just getting things running for now will help your confidence. But before that, you must start thinking in a different mindset. Imagine a Listen-Server and 2 Clients focusing on the POV of the first Client for now. What does Client-1 know, what does it need to know (show)… What does the Server know, what does it need to know (show). What does Client-2 know, what does it need to know (show) etc. Overall, the framework is different in MP, but you may not need to re-work all of that initially. The biggest part is just getting the players in. Multiplayer is a winner-take-all enterprise, so it can be surprisingly tricky to get enough players to just make your Indie multiplayer game work. Its a Chicken & Egg scenario, as empty lobbies will kill your game quicker than major bugs. And even after addressing all of that, you still have to tweak and optimize the game which isn’t trivial… (Related GDC talks can help there)…

Almost every variable and function call that sets or gets those variables will have to be refactored and you will have to insert a lot of extra events and solve all the ownership issues with a complete restructure of classes… in other words… it is a nightmare and will be far quicker to just recreate the game.

Thanks for all the feedback.
What I am planning is a 3rd person survival with just cooperative multiplayer.
So far I have 3 months of work where if mostly focused in UI, inventory/storage/crafting stuff.

Do you think it will be that bad even for this case if I don’t address it right now?

And also, any reading material you guys can suggest for the multiplayer part (C++)?

It depends on how intertwined your classes are. UI only exists on the clients so if it is well encapsulated you probably don’t need to change much there. Back end systems like Inventory, storage and crafting is a different story and might be very difficult to convert to multiplayer.