Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

What determines NetworkView owner?

Discussion in 'Multiplayer' started by User340, Feb 11, 2010.

  1. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    How do you set the owner of a networkView? Whenever I put a networkView onto a gameObject, it always seems to force the clients to follow the server. Is there a way to make a server's networkView follow one of it's clients?
     
  2. DrHotbunz

    DrHotbunz

    Joined:
    Feb 14, 2009
    Posts:
    315
    I recommend you use Network.Instantiate to spawn prefabs on your clients which will set up your objects correctly. Why set them up manually ?
     
  3. SixTimesNothing

    SixTimesNothing

    Joined:
    Dec 26, 2007
    Posts:
    167
    When setting up networked objects manually, control over a GameObject falls to the client/server who calls Network.AllocateViewID(). This returns a NetworkViewID which can then be sent between the client and server to set up the object on the server or other client instances as required.

    Network.Instantiate is the simple option, and a good idea if you don't have a complex application, but doing it manually gives you more control over ownership of objects. You would typically need this when there are both player and NPC (server controlled) characters in the game.
     
  4. User340

    User340

    Joined:
    Feb 28, 2007
    Posts:
    3,001
    Thanks