Search Unity

Question All player's cameras see the camera of the newest joined player.

Discussion in 'Getting Started' started by Monkey042, Jul 29, 2022.

  1. Monkey042

    Monkey042

    Joined:
    Mar 6, 2022
    Posts:
    1
    I am making an online multiplayer game, and Just implemented the online multiplayer, this was my first time and I needed a tutorial. The tutorial I followed worked perfectly, except that the game he made was top down and everyone shared a camera, but mine is first person. Everything but the camera works perfectly. The issue I have is that all my players are from prefabs with their own cameras, so I thought it would be fine and they would use their own cameras, but no. All players in the current session change so that they see out of the newest created camera. I found an old forum post with help but the code is outdated, and I was wondering if anyone had a solution, I will also show the old forum post to see if anyone can make a more modern and working version of it.

    1. public var myCam : Camera;
    2. public var myAudioListener : AudioListener;

    1. function Update(){
    2. //Client code
    3. if(owner!=null Network.player==owner){
    4. //Only the client that owns this object executes this code
    5. if (myCam.enabled == false)
    6. myCam.enabled = true;
    7. if (myAudioListener.enabled == false)
    8. myAudioListener.enabled = true;
    I am new to unity forums if it's not obvious