Search Unity

networkView Doubt

Discussion in 'Multiplayer' started by Jrolff, Sep 18, 2009.

  1. Jrolff

    Jrolff

    Joined:
    Jul 24, 2009
    Posts:
    3
    Hi all,

    I have a basic question to ask, in the networking example, on the ThirdPersonNetworkInit script

    Code (csharp):
    1. function OnNetworkInstantiate (msg : NetworkMessageInfo) {
    2.     // This is our own player
    3.     if (networkView.isMine)
    4.     {
    5.         Camera.main.SendMessage("SetTarget", transform);
    6.         GetComponent("NetworkInterpolatedTransform").enabled = false;
    7.     }
    8.     // This is just some remote controlled player
    9.     else
    10.     {
    11.         name += "Remote";
    12.         GetComponent(ThirdPersonController).enabled = false;
    13.         GetComponent(ThirdPersonSimpleAnimation).enabled = false;
    14.         GetComponent("NetworkInterpolatedTransform").enabled = true;
    15.     }
    16. }
    which is the networkView that the script is referencing? do i need a networkView in the same gameobject? or it's using the NetworkMessageInfo networkView?
     
  2. MikeHergaarden

    MikeHergaarden

    Joined:
    Mar 9, 2008
    Posts:
    1,027
    it's using the networkview that is attached to the same object the script is attached to.

    networkView.BLA or GetComponent(NetworkView).BLA are equal in this case.
     
  3. Jrolff

    Jrolff

    Joined:
    Jul 24, 2009
    Posts:
    3
    Thanks, that's what i thought :)
     
  4. Jrolff

    Jrolff

    Joined:
    Jul 24, 2009
    Posts:
    3
    Well, surely everybody is aware of this, but i have to share it anyway :)

    If you do a dedicated Server, and want to sincronize the networkView between clients, you must have the scene in the server (at least the sincronization script), indepentendly if you use it or not, if not, the script sincronization doesn't work, cause as the server doesn't have the script, send empty data when it sincronize.