How to animate Cinemachine depth of field properties - focal length and aperture

Ok … I have a Cinemachine Spline Dolly camera set up so that I can use mouse scrolling to zoom in and out whilst following a curved path and looking at the player character. This is achieved by tweening the position param on the Spline Dolly component.

I’ve added a Cinemachine Volume Settings component and have this focusing on the player (target). My understanding is that this will change the ‘Focus Distance’ to match target distance … but nothing else.

Setting this up so the DOF looks good zoomed in means the effect is completely lost when zoomed out. I’d like there to be a consistent DOF ‘area’ around the player character so that, for example, 20 units from the character things start to blur.

Animating the focal length doesn’t do anything … the values change in the inspector but aren’t applied to the camera.

I’ve found a couple of hacky ways to get this to work:

  • Animating the DOF parameters and then dis/re-enabling the Cinemachine Volume Settings component every time I change focal length in code forces it to update.
  • Setting up a Global Volume at the right focal length and DOF settings then animating the weight of the volume settings component so that it blends to that set of defaults.

Would be nice not to have to resort to these - is there an easier way?

The global volume method is the way to go.

Alternatively you could experiment with creating dynamic volume settings in memory. You can tweak those at runtime without worrying about profile assets. That’s what CinemachineVolumeSettings does under the hood. You can take a look at the code there - just expand it for settings other than focus distance.

Thanks for the reply … I understand that these approaches can work … but they feel pretty hacky / non intuitive / fragile / aren’t documented (afaik!). Some cleaner solution that’s supported out of the box would be much appreciated!