title: How to initialize the camera for players in Photon
body: <p>I making 2D game, the problem is that when the first player creates and appears in the room his camera is working normally, but when a new player enters the room, the first player sees everything through the camera of the second player. Further, if a third player connects, the first and second players see everything through the third player’s camera and so on.</p>
  
  <p>Player prefab instantiated in the GameManager class which is only on the game scene</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class GameManager : MonoBehaviourPunCallbacks
      {
          public GameObject playerPrefab;
          public Transform spawnPoint;
  
          public void Start()
          {
              GameObject player = PhotonNetwork.Instantiate(this.playerPrefab.name, spawnPoint.position, Quaternion.identity);
              player.GetComponent&lt;FireFighterHeroController&gt;().enabled = true;
              player.GetComponent&lt;CameraControler&gt;().enabled = true;
              player.GetComponent&lt;CameraControler&gt;().SetTarget(player.transform);
          }
  
          #region PUN Callbacks
  
          public override void OnLeftRoom()
          {
              SceneManager.LoadScene(1);
          }
  
          #endregion
  
          #region Custom Methods
  
          public void OnClickLeaveRoom_Btn()
          {
              PhotonNetwork.LeaveRoom();
          }
  
          #endregion
  }
  </code></pre>
  
  <p>Simple camera controller</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class CameraControler : MonoBehaviour
      {
          private Transform target;
          public GameObject camera;
          public Vector3 offset;
  
          public void SetTarget(Transform target)
          {
              this.target = target;
          }
  
          public void LateUpdate()
          {
              camera.transform.position = target.position + offset;
          }
      }
  </code></pre>
  
  <p><strong>UPD Found a solution</strong></p>
  
  <p>I moved the script of the camera controller to the player’s camera, and in the player’s instance I search for this camera, turn it on and transfer the player’s transform to it.</p>
  
  <p>Not sure about this method, but it at least works.</p>
  
  <p>Here is that monster</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class GameManager : MonoBehaviourPunCallbacks
      {
          public Transform spawnPoint;
  
          public void Start()
          {
              GameObject player = PhotonNetwork.Instantiate("Player", spawnPoint.position, Quaternion.identity);
  
              if (!player.GetPhotonView().IsMine)
                  return;
              player.GetComponent&lt;FireFighterHeroController&gt;().enabled = true;
              player.transform.Find("Camera").gameObject.GetComponent&lt;CameraControler&gt;().enabled = true;
              player.transform.Find("Camera").gameObject.GetComponent&lt;CameraControler&gt;().SetTarget(player.transform);
              player.transform.Find("Camera").gameObject.SetActive(true);
          }
  }
  </code></pre>
  
  <p>And Camera Controller</p>
  
  <pre class="lang-cs prettyprint-override"><code>public class CameraControler : MonoBehaviour
      {
          private Transform target;
          public Vector3 offset;
  
          public void SetTarget(Transform target)
          {
              this.target = target;
          }
  
          public void LateUpdate()
          {
              gameObject.transform.position = target.position + offset;
          }
      }
  </code></pre>