single/multiplayer workflow?

Hi, what’s the workflow of implementing the single player and multiplayer into a game?
-single player first, then multiplayer?
-Do I need to make 2 different sets of code/prefabs for single/multiplayer? will the code still be working if uses the same piece of code?
I need some advices, thanks.

Best thing you can do if you know for sure there will be multiplayer support in your game, is to start with it as soon as possible. Get a very, very basic version of you game working, then add connection and datatransfer scripts. The further your game is in development, the harder it will be to add multiplayer support.

No, you don’t have to make 2 sets of anything. Just think of a system. Objects in my game that can be controller by the player (character, car) simply have a boolean isOwnedByMe, that is set to false if the object is a representation of some other player’s object. In controlling scripts as movement I check this boolean. I even believe there is a standard variable for this somewhere in the Network class.

Thanks for the information.

When I’m doing a multiplayer, I need to add network view to my character, and synchronize the animations, and put into a prefab.
But if in single player mode, do I still use the same prefab or make another one without network view…??

I would not bother and simply use the same prefab (and even the same scripts). In fact, In a simple game I would even have the singleplayer use the networking code and have it run as a server for just the local player.

However, that’s assuming you use the built in unity networking.

You can check in the Network class what the peertype is, so you can see whether the player is server or client, or not connected at all. This way you can built in specific single player code in your scripts. This way you can use the exact same prefabs.

Leepo’s idea is a good way to do it as well, but you must keep in mind that a player with no connection ability at all (and thus can not start a server), should be able to play singleplayer as well.

You don’t need any connection to start a server. Why I did this in my game was to make sure I could still use all of my networked scripts game logic (as you wouldn’t be able to use RPC calls without running as server or client).

This singleplayer game can run a “server” for just itself, without connection.

Ah, sorry then, I didn’t know that was possible. In this case Leepo’s idea is indeed the way to go.