- Home /
what is the best approach to implement single and multiplayer in one game(single is with AI and multiplayer is with live players), should i make two different scenes or something else ??
i tried implementing single player and multiplayer game in two different scenes but there need to make every change in both the scenes , and changes are needed to place in two scenes , can we use something like inheritance in unity or what is the best way ...
Answer by GetLitGames · Jul 12, 2021 at 07:00 PM
You should use the same scene, and you can set things like the AI to disabled and then enable the gameobject with the AI script when it's needed (this is a simple explanation). But from a design perspective you will have a separate class for handling AI versus the human, and only one or the other will be there at all. You might even make a base class with some functionality and the AI and Player classes inherit from that class. You can use Prefabs to avoid duplicating work in two scenes, but you shouldn't do multiple scenes. Look up Prefabs, and look up C# class inheritance.
Answer by Nistroy · Jul 12, 2021 at 05:23 PM
I think the best way is to do two different scenes with different scripts that are similar. It takes after that you are an all-encompassing script (like eg GameManager) with the save and load system.
Answer by JxWolfe · Jul 12, 2021 at 09:28 PM
2 scenes would be better. Less potential troubleshooting issues, but more importantly - the client isn't loading the game and then turning off all the singleplayer stuff. Instead it just loads the game. Disk space is so massive these days even decreasing the loading screen by a second is better than adding say a gig of storage. (If it's more than a gig then don't do two scenes.)
Your answer
Follow this Question
Related Questions
why if i load a level with ServerChangeScene there spawn dozens of scenes 0 Answers
How can I get a variable from another player? 0 Answers
Photon Multiplayer - nick above model head, I have no idea how to repair it 1 Answer
MLAPI Client can't see a gameobject 0 Answers
Unet Procedure Calls? 0 Answers