Search Unity

NetworkBehaviour stopping script from being used in local only game.

Discussion in 'Multiplayer' started by SpaceMidget75, Feb 5, 2016.

  1. SpaceMidget75

    SpaceMidget75

    Joined:
    Feb 7, 2014
    Posts:
    21
    Hi,

    I have a 2 player local game that I've converted to networked. I've made the scripts compatible with both so now you can set the game to network and use the NetworkManagerHUD to play a network game or set it local to play a local 2 player game. The problem is that with a local game, the NetworkManager and NetworkManagerHUD still show and you have to click the Start Host button to get it to load. To attempt to fix this I removed these components from the Local Game Scene but then the NetworkBehaviour (and NetworkIdentity) of the game objects stops them from running Start() & Update().

    What's the best way of handling this? I don't want to have double the scripts for local and network games just so that one can inherit from MonoBehaviour and the others NetworkBehaviour.

    Is there a way to for scripts with NetworkBehavour to start their Start() and Update() methods without having to click Lan Host or show a network GUI?