how do you enable/disable a camera from the new unity 5 fpscontroller camera for a multiplayer game using PUN
first of all I'm making a multiplayer game using the free PUN. and so to avoid that "bug" where when you got 2 or more players in your game, they follow your every move even though your only controlling 1 game. and the way we remedy this is to manually disable the controller and the camera from the editor and enable them in script so that only that player will be doing the controlling. I've succesfully did the controller but the camera won't enable. I've tried everything.
here is the code I use for the controller.
GameObject thisPlayer = (GameObject)PhotonNetwork.Instantiate ("FPSController", playerSpawnPoint, Quaternion.identity, 0);
((MonoBehaviour)thisPlayer.GetComponent ("FirstPersonController")).enabled = true;
// no problems here.
and here are the codes that I tried for the camera.
thisPlayer.transform.FindChild("Camera").gameObject.SetActive(true);
thisPlayer.GetComponent<Camera> ().enabled = true;
Camera cam = thisPlayer.GetComponent<Camera>();
cam.enabled = true;
thisPlayer.transform.FindChild(" Main Camera").gameObject.SetActive(true);
//keep in mind that all this scripts are valid(meaning they won't get any error) but again this codes won't work for me as they don't enable the camera.
Answer by XenonSpher · Dec 14, 2015 at 02:54 AM
I got it to work on my own.. the script I use is
thisPlayer.transform.FindChild ("FirstPersonCharacter").gameObject.SetActive (true);
I use the whole child instead of just the camera.. now I'm gonna try to work on 2 games to see if this worked for PUN.........
and IT WORKED!!!!! now the 2 games at once are different and wont follow each other.!