Hey guys i was just wondering how to go about scripting a multiplayer game. Specifically do i need to create a multiplayer script and single player script for each character? or is it ok to make a multiplayer script that uses RPC and just call them locally on that gameobject for single player.
Also is it bad to have networkview on a Gameobject that is in single player or should there be a seperate prefab specifically for multiplayer?
Thanks for your time and any advice will be greatly appreciated!
You just need to add a bit of condition checking into your scripts, you don't really need to make 2 versions.
What I did is you add some variables to keep track of who the owner of the object is and use that information to determine who should be able to control the object in the game.
You will set owner when instantiating the object to the Network.player that made it.
var owner : NetworkPlayer;
owner = Network.player;
owner is instantiating the objects or whoever should actually control the objects if the server is authoritative.
if(Network.player == owner )
//Allow this player to control this object
//Dont do anything and just wait for the real owner to update the object
This way with a little set up in the beginning you can determine which player should be able to control the object and you dont need multiple versions of scripts to do it.
Also you can check
to determine if the actions are something only the server should do, or if its something that a client can do.