Network Multiple Cameras

I am reasonably new to Unity and have been working through the Unity tutorials, specifically the Survival Shooter. I thought I may have a go at converting this tutorial game to a network multiplayer.

The camera in this tutorial follows the player from a fixed rotation. To accomplish this the tutorial uses one camera (Not a child of the player), tracks the players position and updates the camera position accordingly.

I want each player who joins the network game to have the camera to follow their character with a fixed rotation (same as the tutorial).

I first attempted this by instantiating a new camera for each player, but I found that the new camera was overriding the last. I also attempted to disable the other cameras if they were a local player but found that the other players cameras were being disabled when a new player joined.

I then scrapped the multiple camera idea and attempted to use one camera, but with a similar result where it would only track the latest player.

What is the correct solution to network multiplayer cameras that are not a child of the player?

public Camera cam;

	void Update () {

        if(!isLocalPlayer)
        {
            cam.enabled = false;
            return;
        }

I had the exact same problem, and this solution I came up with.
Have a good day!

Wow thanks dude. I just got this problem and instead of hitting my head against a wall for hours trying to figure it out on my own I looked it up. Lots of help. Much Thanks

when i do this it ignores all culling Masks on the connecting clients and culling Mask don’t work at all on this Camera anymore! Please Help

Just attach a Camera to the Player preFab and add this line to the Start method of the Player script:

GetComponent<Camera>().enabled = isLocalPlayer ? true : false;