Search Unity

Instantiating only one listener

Discussion in 'Multiplayer' started by Crey, Nov 30, 2009.

  1. Crey

    Crey

    Joined:
    Nov 24, 2009
    Posts:
    16
    I have a problem with instantiating over the network. When I have 2 or more clients online, the two clients have 2 cameras, 2 network views, 2 audio listeners, etc. This means that one client ends up controlling all clients movement.

    How do I instantiate an object and make it private to the client who instantiated it? The prefab contains a camera so I don't want my script controlling everyone's camera.

    Thanks
     
  2. perlohmann

    perlohmann

    Joined:
    Feb 12, 2009
    Posts:
    221
    That is because you have to instantiate 2 different prefabs depending on if it is a local player or a remote player (usually a client/game has 1 local player and n remote players) another solution is to disable components that are not needed in the remote player case by a script.
    i.e. based on the networkView.isMine property in a start or awake function.

    //perlohmann