Class BaseCameraConfigurationProvider
Abstract base for pawn-side components that expose follow/look-at targets and compatibility rules to a camera controller, decoupling the controller from any specific pawn type.
public abstract class BaseCameraConfigurationProvider : MonoBehaviour
Inheritance
Derived
Examples
Subclass pattern — gate on a specific camera component in IsCameraCompatible,
then wire Cinemachine follow/look-at targets in OnCameraSet:
public sealed class SwitchableCameraConfigurationProvider : BaseCameraConfigurationProvider
{
[SerializeField] private Transform _firstPersonFollow;
[SerializeField] private Transform _firstPersonLookAt;
private SwitchableCameraController _controller;
// Only accept cameras that carry a SwitchableCameraController — XR cameras
// and other camera types are ignored by this provider.
protected override bool IsCameraCompatible(Camera camera)
=> camera.TryGetComponent(out _);
// Called once, after FindCompatibleCamera locates the matching camera.
// Assign follow/look-at so the virtual cameras track this pawn's head pivot.
protected override void OnCameraSet(Camera camera)
{
_controller = camera.GetComponent();
if (_controller != null)
{
_controller.FirstPersonVCam.Follow = _firstPersonFollow;
_controller.FirstPersonVCam.LookAt = _firstPersonLookAt;
_controller.FirstPersonVCam.enabled = true;
}
}
}
For XR, check for an XROrigin parent instead and reparent the origin to the
vehicle head pivot so that 6-DoF tracking stays relative to the driver seat:
protected override bool IsCameraCompatible(Camera camera)
=> camera != null && camera.GetComponentInParent() != null;
protected override void OnCameraSet(Camera camera)
{
var origin = camera.GetComponentInParent();
if (origin != null) origin.transform.SetParent(XRPivot, worldPositionStays: false);
}
Remarks
The same SwitchableCameraController can drive both the vehicle pawn and the pedestrian pawn without knowing their concrete types.
FindCompatibleCamera polls Camera.main each frame because in
additive-loaded or XR scenes the camera GameObject may not yet be active during
Awake or early Start calls. Polling until it passes
Camera) handles both timing and per-platform camera types.
Properties
Methods
FindCompatibleCamera()
Coroutine that waits until a compatible camera is found. It checks for main every frame until one is available and passes the Camera) check. Once found, it assigns it to MainCamera.
protected IEnumerator FindCompatibleCamera()
Returns
IEnumerator
IsCameraCompatible(Camera)
Determines if the given camera is compatible with the camera configuration.
protected abstract bool IsCameraCompatible(Camera camera)
Parameters
| Name | Type | Description |
|---|---|---|
camera | Camera | The camera to check for compatibility. |
Returns
bool — Returns true if the camera is compatible.
OnCameraSet(Camera)
Callback when a compatible camera is assigned to this pawn. Use this to set up neccessary references or targets to the camera controller.
protected abstract void OnCameraSet(Camera camera)
Parameters
| Name | Type | Description |
|---|---|---|
camera | Camera | The camera that has been assigned as the main camera to this pawn. |
Start()
Unity Start method. Automatically begins searching for a compatible camera.
protected virtual void Start()