Cinemachine 3 integration
Blend PBADOF autofocus with Cinemachine 3 camera sequences using the optional adapter, with configurable lens authority modes and conflict detection.
Cinemachine 3 integration
Use the optional HIBIKI entertainment adapter to combine PBADOF autofocus with Cinemachine 3 camera sequences.
Cinemachine 3 integration is optional and experimental. The core autofocus assembly does not depend on Cinemachine. Features described here may change between releases. Experimental features are not guaranteed to always function as intended.
Prerequisites
- PBADOF v1.4.0 installed.
- Cinemachine 3.1.7 on Unity 6000.3, or the built-in Cinemachine 6.6 on Unity 6000.6.
- A Cinemachine Brain on your rendering camera.
- Timeline, if you are using the Cinemachine showcase sequence.
Adding the adapter
Add the adapter to the camera that renders the final view. The Cinemachine virtual camera rig controls the rendering camera through its Brain, so the adapter must not be attached to the rig.
Select the rendering camera
Select the real rendering camera in the Hierarchy. This is the GameObject with the Camera component and the Cinemachine Brain.
Do not add the adapter to the Cinemachine virtual camera rig.
Open the component menu
In the Inspector, click Add Component.
Find the Cinemachine 3 adapter
Search for the adapter, or navigate to:
HIBIKI entertainment > Depth Of Field > Auto Depth Of Field - Cinemachine 3
Confirm the component
Confirm that the AutoDepthOfFieldCinemachine3Adapter component appears on the rendering camera.
Keep the camera components enabled
Keep both the Cinemachine Brain and the AutoDepthOfField component enabled on the same camera.
The adapter must be added to the real rendering Camera, not the Cinemachine virtual camera. The rendering camera is the GameObject that Cinemachine drives through its Brain component.
Lens authority modes
The adapter's LensAuthority setting determines which lens parameters PBADOF controls while it works with Cinemachine. Choose the mode that matches whether your shot needs Cinemachine, PBADOF, or both systems to control the lens.
| Mode | What PBADOF controls | When to use |
|---|---|---|
| None | Nothing. Cinemachine owns all lens parameters. | When Cinemachine should fully control the lens and PBADOF only provides focus distance data. |
| Focus | Focus distance only. Cinemachine controls aperture and focal length. | When you want PBADOF to drive autofocus but Cinemachine to handle lens framing. |
| Focus and aperture | Focus distance and aperture. Cinemachine controls focal length. | When PBADOF should control the depth-of-field look, including focus and bokeh, but Cinemachine handles zoom. |
| Focus, aperture, and focal length | All lens parameters. PBADOF fully owns the lens. | When PBADOF should drive the complete physical lens model, including zoom. |
Start with Focus mode for gameplay, then switch to a higher authority mode during cinematic sequences where you want PBADOF to own more of the physical lens model. Change the authority at runtime through the adapter's LensAuthority property.
Conflict detection
The adapter monitors for conflicts between PBADOF and Cinemachine. The CurrentConflict property reports active issues so you can identify which system is competing for control.
| Conflict type | Description | How to resolve |
|---|---|---|
| Cinemachine autofocus enabled | Cinemachine's own autofocus is active and competing with PBADOF. | Disable Cinemachine's autofocus, or set LensAuthority to None. |
| Cinemachine DOF volume settings | Cinemachine depth-of-field volume settings conflict with PBADOF output. | Remove or disable the conflicting Cinemachine depth-of-field volume. |
| Camera mismatch | The adapter is on a different camera from the one PBADOF is driving. | Move the adapter to the correct rendering camera. |
| Competing camera drivers | Another component is trying to drive the camera's lens. | Disable the competing component, or use PBADOF exclusively. |
Resolve conflicts before tuning the lens. Multiple components writing to the same camera can produce inconsistent focus, aperture, or focal-length values during a blend.
Blending gameplay and Timeline
During gameplay, PBADOF can drive autofocus and, depending on LensAuthority, some or all of the physical lens. During a Timeline sequence, Cinemachine can take over lens authority or share control with PBADOF.
The adapter supports both Cinemachine focus racks and PBADOF's automatic focus pulling. Transition from gameplay to a Timeline shot by changing LensAuthority at the point where the shot needs a different lens owner, then restore the gameplay mode when the sequence ends.
The Cinemachine showcase sequence in the demo content demonstrates multiple shots with explicit lens authority. Open it through Window > HIBIKI entertainment > Depth Of Field > Showcase Launcher and select the Cinemachine Sequence showcase.
Working with the adapter from script
Use the adapter's namespace, component type, lens authority enum, and conflict flags enum to change lens ownership and inspect the current integration state at runtime.
using HIBIKIentertainment.DepthOfField.Cinemachine3;
// Get the adapter from the rendering camera
var adapter = GetComponent<AutoDepthOfFieldCinemachine3Adapter>();
// Set the lens authority mode
adapter.LensAuthority = Cinemachine3LensAuthority.FocusAndAperture;
// Check for conflicts
var conflict = adapter.CurrentConflict;
if (conflict != Cinemachine3FocusConflict.None)
{
Debug.LogWarning($"PBADOF-Cinemachine conflict: {conflict}");
}
AutoDepthOfFieldCinemachine3Adapter is the integration component attached to the rendering camera. Cinemachine3LensAuthority is an enum that selects which lens parameters PBADOF controls. Cinemachine3FocusConflict is a flags enum that represents active conflicts detected between PBADOF and Cinemachine.
Legacy Cinemachine 2 support
Legacy Cinemachine 2 support remains available as separate compatibility content. The core autofocus component does not require Cinemachine. If you are using Cinemachine 2, refer to the legacy compatibility sample in the Samples folder.
Next steps
Explore the Showcases and demos to see the Cinemachine Sequence showcase, or read the API reference for the full component interface.