Switching to scene camera after death ? (networked game)

Hi,

When a player has died in my multiplayer game, I want that player to see through a different camera than the one that’s attached to the player.
There’s a camera in each level that shows the entire scene and it’s not attached to any player. I tried this, this code is from each players Health script:

public Camera playerCam;


//in Update when the player dies I do the following:

if (playerIsDead)
                {
                playerCam = GameObject.FindWithTag("RoundCam").GetComponent<Camera>() as Camera;
                }

But nothing happens. I can’t just disable the playerCam, because it defaults to the “MainCamera” which is in use elsewhere, so how do I change what camera a player looks through?

All cameras in the scene that are active and enabled are always rendering to their targets. You can change the order in which they are drawn to the screen by changing their depth value.

Generally you would just disable the playercam and enable whatever other can you want to switch to. Not sure what you mean about the main camera, is it being used for some viewport or a RenderTexture or something?

1 Like