Problems with enabling multiple cameras in Multiplayer Networking

Hey guys. I’m 100% new to doing a multiplayer game and I’ve been having some issues. Specifically, I have two cameras attached to my player controller. One is purely for sight, while the other is for rendering the weapon view. Both are attached to children. I’m trying to activate both of them on a player’s spawn. This poses problems when I try to do a GetComponent as it only enables one. GetComponentsInChildren doesn’t seem to work either, as it says .enabled isn’t allowed with Cameras in Unity. I tried creating a separate script to activate it but that wasn’t really working either. Furthermore, if I leave the component active prior to a player spawning, it is active for all players (Every player in game sees the hands/gun of every other player in game).

For some reason, the actual camera view is working fine, but the weapon camera is not. I have attempted attaching the weapon camera to a separate child and activating it with a transform.find(weaponcamera).gameObject.SetActive(true);. This succeeding in activating the camera, but reproduced the problem of everyone seeing it. Here’s what I have so far. Thanks!

		void OnJoinedRoom () {
			Debug.Log ("JOINEDROOM");
			SpawnSpot mySpawnspot = spawnSpots [Random.Range (0, spawnSpots.Length)];
			GameObject Player = PhotonNetwork.Instantiate("PlayerController", mySpawnspot.transform.position, mySpawnspot.transform.rotation, 0) ;
			Player.GetComponent<PlayerInput>().enabled = true;
			Player.GetComponent<PhotonView>().enabled = true;
			Player.GetComponentInChildren<Camera>().enabled = true;
	}

}

I did this yesterday actually lol. What I did was attached the second camera to the first camera and then just set the first camera inactive. Noticed I did NOT set the second camera to inactive, just the first. Now in code, just set the first camera active and the second camera will be active as well.

When you set an object inactive, all of its children are inactive as well. So if you just enable the main camera, as long as the second camera was already enabled in the editor, you’ll be able to enable both with just enabling the one.