So this is a design question with regards to my real-time multiplayer game using uLink (basically the same as Unity Networking).
I currently have an authoritative server instance, to which clients connect and RPC data. I separated the Server and Client scenes and scripts to prevent the Clients from having Server code and to organize them. My inheritance looks like this:
This same setup is mirrored for other manager classes as well. This all works great! But the problem is now I can’t have the client play single-player, offline. I don’t want to require the clients from needing access to internet to play Single Player.
The only solution I can see, which I don’t like, is to move all the necessary code to
NetworkedGameManager, and check
uLink.Network.isServer before anything that should be server only. This ruins the benefits of inheritance, makes one really large file, and feels less secure since the clients no longer depend on the server.
I also tried just adding the
ServerGameManager script to my client scene, but these things are so interdependent and that would create a lot of repetition in the code, although I prefer this option if its doable.
So what is the normal approach here? One monolithic system that has all Client and Server code? Some sort of modular setup with Client and Server in the same scene? Make a third class that extends Client and adds repetitious server code?
Thanks for any and all advice!
I’m getting a pretty rough idea of what you’re trying to achieve, but I may be missing some details, so don’t hate me if I was misled.
From what I understand, you have Solo, and multiplayer content in easy access of each other, but no clear-cut separator (like buttons on the main menu). This style makes me think of Dark Souls. In such a case, you would have the game ‘assume’ offline mode, until an event or some such (successful connect with legit login, cued when disconnected each time the user views the local/online players) powered the online communication features.
In the case that you want online activity as soon as you started the game, with the option of jumping on without a legit login for offline mode, might I suggest creating 2 separate clients? For Steam, this means players will get to have the option of choosing online or offline mode from a single button, and you can safely store all your online-only content in your online-only client.
Since single player have nothing to do with network, server or client, I think the application design have to be a bit different, probably something like:
the only #3 levels sharing the network logic, the #2 levels sharing the shareable logic for single&multiplayer, and #1 used as general controller.
Probably it’s a too high level map, I have no idea how to implement this in practice.
I prefer a monolithic non-OOP system, with simple:
// Whatever to continue
@OP_toss This is a really old post, but I’m a software dev new to Unity, and thought I’d throw in a thought for others that may land here. It seems to me you could just run a server on localhost for single player. It doesn’t require internet access, it’s all on the client machine, and requires no design changes.