Hi,
I’m making a multiplayer game and I want that each player has their own main camera and I want each player to be able to manage the movement of their own camera. Is it possible?
Attach the CinemaMachineBrain component to the main camera.
Attach a VirtualCamera to the player prefab.
In a script attached to the player, reference the virtual camera.
[field: SerializeField] public CinemachineVirtualCamera VirtualCamera { get; private set; }
Assign the PlayerPrefab’s new VirtualCamera to the attached script while in the Editor.
Then change priority for the owner.
public override void OnNetworkSpawn()
{
if(!IsOwner) { return; }
VirtualCamera.Priority += 1;
}
{
You can also have the VirtualCamera Component(not the VirtualCamera GameObject) disabled by default and then enable it aftrer assigning priority.
public override void OnNetworkSpawn()
{
if(!IsOwner) { return; }
VirtualCamera.Priority += 1;
VirtualCamera.enabled = true;
}
{
I’m pretty new at all this myself but I think that’s what your looking for.
Obviously, if you are using other camera types then you reference those instead.
[SerializeField] public CinemachineStateDrivenCamera StateDrivenCamera { get; private set; }
[SerializeField] public CinemachineFreeLook FreeLookCamera { get; private set; }
[SerializeField] public CinemachineVirtualCamera VirtualCamera { get; private set; }