Search code examples
2dphotoncinemachine

unity instantiated player with photon attaching to cinemachine


So before i used photon i used to have the player attached to the cinemachine camera in the inspector but now that im instantiating the player at runtime i really have no clue how that works, im making a 2d topdown game so i cant have the camera on my player prefab because it will rotate all crazy when i move my mouse.

is there a way to have all players each their own camera? i also dont want to destroy other people's cameras but disable them so i can re enable them later (spectating).

thanks!


Solution

  • The solution seemed to be really simple, i simply disabled the camera objects by default and enabled them if IsMine is true

            if(view.IsMine)
        {
            myCinemachine.SetActive(true);
        }
        else
        {
            myCinemachine.SetActive(false);
        }