Search code examples
unity-game-engine2dphotonphoton-puncinemachine

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 I'm instantiating the player at runtime, I really have no clue how that works. I'm making a 2d top-down game, so I can't have the camera on my player prefab (because it will rotate with the player when I move my mouse).

Is there a way to have all players each their own camera? I also don't want to destroy other people's cameras, I'd rather disable them so I can re-enable them later (spectating).


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);
    }