Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Another networking noob question

Discussion in 'Multiplayer' started by bigkahuna, Aug 26, 2008.

  1. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    How would you recommend I do this:

    I have a character that my player will move about his world. There are two cameras in the scene, one is a a view from the character's viewpoint and is a child of the character. The second camera is a top view of the character and also a child of the character. I'd like the controlable character and the first camera on computer #1 and just the second camera on computer #2.

    Any ideas?
     
  2. ProtonOne

    ProtonOne

    Joined:
    Mar 8, 2008
    Posts:
    406
    I would create a "PlayerNetworkInit.js" script.

    Something like:

    Code (csharp):
    1.  
    2. var cameraFPS : Camera;
    3. var cameraTopView : Camera;
    4.  
    5. function OnNetworkInstantiate (msg : NetworkMessageInfo)
    6. {
    7.     // This is our own player
    8.     if ( networkView.isMine)
    9.     {
    10.         cameraFPS.enabled = true;
    11.         cameraTopView.enabled = false;
    12.  
    13.         // Enable input
    14.         GetComponent( FPSWalker ).inputEnabled = true;
    15.     }
    16.     else
    17.     {
    18.         cameraFPS.enabled = false;
    19.         cameraTopView.enabled = true;
    20.  
    21.         // Disable input
    22.         GetComponent( FPSWalker ).inputEnabled = false;
    23.     }
    24. }
    25.  
    26.