Course contentsShow
← Unity Game Development
Lesson 406 of 8286. Animation and CinemachineFree lesson

Implementing FOV Adjustments for Dramatic Depth of Field

You will manipulate field of view and focus distance settings to create cinematic depth-of-field effects during scripted sequences.

In this lesson, you will learn how to manipulate Field of View (FOV) and lens settings to create cinematic depth-of-field effects that draw the player’s eye exactly where you want it.

The Mechanics of Dramatic Focus

In cinematography, "depth of field" refers to how much of your scene is in sharp focus versus a blurred background. When we combine a narrow Field of View with specific lens settings, we can isolate subjects effectively. By scripting these values during cutscenes or high-tension gameplay moments, we simulate the sophisticated optics of a professional camera.

In Cinemachine, the Lens settings of your CinemachineVirtualCamera act as the bridge to these effects. To achieve a "dramatic" look, you typically decrease your FOV (zooming in) while simultaneously adjusting the Focus Distance and Aperture settings found within the camera's Cinemachine Post Processing extension (or the built-in Lens settings if using the Physical Camera mode).

Scripting the Adjustment

Instead of manually tweaking values, you can use a script to transition these properties smoothly. When you "rack focus" (shift focus from one object to another), you are essentially updating the focus distance parameter over time.

using UnityEngine;
using Cinemachine;

public class CinematicFocus : MonoBehaviour
{
    public CinemachineVirtualCamera vcam;
    public float targetFOV = 30f;
    public float transitionSpeed = 2f;

    void Update()
    {
        // Smoothly adjust FOV for a "long lens" compression effect
        vcam.m_Lens.FieldOfView = Mathf.Lerp(vcam.m_Lens.FieldOfView, targetFOV, Time.deltaTime * transitionSpeed);
    }
}

By lowering the FieldOfView during a dramatic sequence, you compress the perspective, making the background appear closer and more blurred—especially when the Aperture (F-stop) is set to a low value. This creates a soft, bokeh-rich background that makes your primary subject pop against the environment. Remember to keep your Cinemachine Brain settings in mind, as the transition quality depends heavily on the Default Blend settings configured earlier in your project.

Key Takeaway: By programmatically lowering the FOV and adjusting focal depth during scripted sequences, you leverage optical compression to guide player attention and heighten the emotional impact of your cinematic moments.