Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by OP_toss · Aug 22, 2013 at 11:06 PM · networkingofflineauthoritative

Authoritative Server with Offline Single-Player

Hey guys,

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:

 GameManager
 |-NetworkedGameManager
   |-ServerGameManager
   |-ClientGameManager

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!

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

3 Replies

· Add your reply
  • Sort: 
avatar image
0

Answer by Komak57 · Dec 17, 2013 at 12:38 PM

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.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image OP_toss · Jan 09, 2014 at 12:57 AM 0
Share

Not quite what I'm going for. The user will explicitly pick Single Player or $$anonymous$$ultiplayer. But the gameplay is largely the same. A singleplayer game has to be able to have 100% of the code, while a multiplayer client should only have the clientside code, for security, etc. and likewise a Server should only have its necessary code, most of which is needed for singleplayer.

I ended up with a bad system, but I'm too late int he game to refactor it. I wish I'd separated server logic from client logic, but allowed both to be added to the same game when singleplayer. Hard to explain, and harder to design and implement...

Thanks for the input though!

avatar image
0

Answer by nastasache · Dec 17, 2013 at 07:45 PM

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:

 GameManager
 |-OfflineGameManager
 |-NetworkedGameManager
   |-ServerGameManager
   |-ClientGameManager

the only #3 levels sharing the network logic, the #2 levels sharing the shareable logic for singleμltiplayer, 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:

   if(!multiplayer) {
             
       Network.Disconnect();
       MasterServer.UnregisterHost();            
                 
   }
   // Whatever to continue
Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image OP_toss · Jan 09, 2014 at 12:59 AM 0
Share

Yeah as I noted above, that's roughly what I ended up with... cept separated into classes that inherit in order of complexity. Definitely not ideal.

As stated above, I want a system wherein singleplayer is just client + server. But that's not easy with how complex things are, especially concerning all the network code... O well, thanks for your input!

avatar image
0

Answer by baelthanoc · Dec 10, 2015 at 05:23 PM

@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.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

18 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to validate client input on authoritative server? (preventing speedhack or networtk send rate manipulation) 2 Answers

Authoritative server security? 2 Answers

Turn-based small scale multiplayer: server-only-logic possible? 2 Answers

ontriggerenter will not work with !islocalplayyer 0 Answers

Multiplayer on Android? 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges