Search Unity

network.instaniate and culling mask question

Discussion in 'Multiplayer' started by tigerspidey123, Sep 17, 2009.

  1. tigerspidey123

    tigerspidey123

    Joined:
    Jun 25, 2009
    Posts:
    67
    Hi, I am pretty new with networking trying out network.instaniate function, I have a camera that is attached to my instaniate prefab, and the camera itself is culling my prefab which is set to certain layer, which means I can't see the prefab when I started the game.

    Problem 1:
    However, because of the instaniate function, the other person is also under the same layer, which makes my camera culling out the other players on the networks too with the same prefab. Is there anyway around this?

    Problem 2:
    And if camera have audio litseners attached, which will duplicate and will give me warning saying more than one litsener in the game which might slow down the frame rate. Anyway around this one?

    It's a racing game where you don't see your own car.

    Thanks!
     
  2. Dreamora

    Dreamora

    Joined:
    Apr 5, 2008
    Posts:
    26,601
    1. I would personally not use the same prefab.
    I've always two prefabs:
    - LocalPlayer
    - RemotePlayer

    That gives you distinct setups instead of complex script code that adds and removes component (which you will have to do as the control component etc must not be present for remote players or you control all of them)
    Same goes for cmaera etc that are directly related to the prefab potentially
     
  3. tigerspidey123

    tigerspidey123

    Joined:
    Jun 25, 2009
    Posts:
    67
    Thanks, That helps(I can tell inside the editor that which one is remote which is not, but how would you able to find the type inside the code) but what about the audio listener, wouldn't it still create multiple listener because it is with the camera parented to the prefabs. I made an empty object and attached a script that follow object(transform), in this case will make it follow the prefab. When it instaniate the prefab, I made the audio litsner follow that prefab(updates position inside fixedupdate()), however I get popping sound some what(worse with late update and update(), since all my audio is with physics inside my car script) Any ideas?