Search Unity

Two NetworkManager, one for the Server and one for the Client, Mistake?

Discussion in 'Multiplayer' started by BouncedPhysical, Jul 26, 2017.

  1. BouncedPhysical

    BouncedPhysical

    Joined:
    Jul 16, 2016
    Posts:
    58
    Basically i'm new to Unet.
    I was trying to not have the Server unity instance also as a Player.

    What i've done is:
    Have two builds of the game, one with a bool "Server" one triggered and one not.
    What the bool does if it's triggered it loads "ServerScene" where there is only a NetworkManager and there is an automatically call of "StartHost()".
    If the bool is not triggered the Scene to load is just what the player must do, passing from "LoginScene" to "CharactherSelectScene" then a "LoadingScene" that loads my map (of course not automatically, by buttons!).

    The "Login" scene contains a NetworkManager, then a button to do the StartClient() and it works! I'm able to connect to my Server.

    But i'm having problem with spawning now! So the first question, before i ask help about spawning is: is this the correct way to have a Server that is not also the client? Or i just messed around?

    Many thankses in advance!
     
  2. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    You can use StartServer instead of StartHost, that way you will have only server instance, without client;

    Btw, building login system on the Unet HLAPI is a bad idea.
     
    BouncedPhysical likes this.
  3. BouncedPhysical

    BouncedPhysical

    Joined:
    Jul 16, 2016
    Posts:
    58
    I will surely use StartServer, thank you!
    The login is all made in PHP, With Unity i just use the WWW class to send data from Input Fields.

    So is this the correct way to achive that? Have a ServerScene and a NetworkManager specific for the Server Build?
    Thank you for your answer :D
     
  4. xVergilx

    xVergilx

    Joined:
    Dec 22, 2014
    Posts:
    3,296
    There is no way to it in "correct" way. It depends on what you're doing, and what you're trying to achieve. If it works for you - then it's fine.
     
    BouncedPhysical likes this.
  5. BouncedPhysical

    BouncedPhysical

    Joined:
    Jul 16, 2016
    Posts:
    58
    Yeah i mean this can work or it's just broken at the start? Ahah it's that that i don't understand.