Unity 5 Swiching cameras causes missing scene
I'm making 2D multiplayer game where the player game object is being instanciated from a prefab. There is a Camera inside that player. When the player connects and is spawned. I want to swich from main camera to the camera inside that player game object so that the camera would follow the player when it moves. However when I connect as client and the player needs to be spawned I get following error:
Screen position out of view frustum (screen pos 455.000000, 341.000000, 1000.000000) (Camera rect 455 341 0 0) UnityEditor.DockArea:OnGUI()
I can understand that it is something with scene being on diferent position than camera because the scene gets missing too, but I can't seem to figure out how to fix it.
I have a script attcahed to the player and there I change cameras as follows:
if (isLocalPlayer) {
Debug.Log ("player");
Camera.main.enabled = false;
playerCam.enabled = true;
} else {
Debug.Log ("server");
}
It seems to be working - disables main camera and enables the one inside the player game object. Maybe there is something wrong with the camera setup that causses problems? Here is players camera setup:
Your answer
Follow this Question
Related Questions
Default plane object display error. 0 Answers
Camera Toggling Error 1 Answer
Top down 3D puzzle game: Help with making my level perfectly fit the camera size. 0 Answers
Compile Error 0 Answers