Basic Setup with Cinemachine
Managing a Cinemachine Camera in multiplayer.
This guide will show you one way you can set-up your player camera for multiplayer when you are using the Cinemachine package.
1
Installing Cinemachine
The first step — if you haven't done so already — is to install Cinemachine through the Unity Package Manager.

2
3
4
5
Writing a PlayerCamera Script
Let's now add the following script to the Player Prefab that we will use to take control of our Camera once our player spawns in.
using FishNet.Object;
using Unity.Cinemachine;
using UnityEngine;
// This script will be a NetworkBehaviour so that we can use the OnStartClient override.
public class PlayerCamera : NetworkBehaviour
{
[SerializeField] private CinemachineCamera cinemachineCamera;
// This method is called on the client after the object is spawned in.
public override void OnStartClient()
{
// Simply enable our local cinemachine camera on the object if we are the owner.
cinemachineCamera.enabled = IsOwner;
}
}
This script uses the OnStartClient override method from NetworkBehaviour to enable or disable the Cinemachine Camera component on the player objects depending on if they are our local player or not.
6
Last updated