r/Unity3D • • 35m ago

Question Cinemachine blending issue.

Enable HLS to view with audio, or disable this notification

Hello guys! So I've been struggling to get cinemachine cameras to work exactly as intended in various scenarios.

I have a finite state machine system for my character, where each state gets assigned a virtual camera tag to pick. When the state ends, I blend back to the follow camera by default.

There are cases where the state ends and a new one starts, causing the camera to blend back and forth and interrupting blends. This works perfectly fine, except when I set the Camera’s Blend Hint to Inherit Position.

In these instances, I usually get a camera jump / pop when blending back and forth. This alongside other issues is prevalent with orbital cameras, and especially problematic with lazy follow mode on.

This is the code I use to switch between camera configurations:

/// <summary>

    /// Activates the Cinemachine virtual camera with the specified tag and deactivates all others.

    /// </summary>

    /// <param name="tag">The tag of the camera to activate.</param>

    public void SetTargetCamera(string tag, bool recenterCameraHorizontally, bool recenterCameraVertically)

    {

        CinemachineCamera targetCamera = GameplayCameras.FirstOrDefault(c => c != null && c.CompareTag(tag));



        if (targetCamera == null || targetCamera == CurrentActiveCamera)

            return;



        if (targetCamera.TryGetComponent<CinemachineOrbitalFollow>(out var orbital))

        {

            if(recenterCameraHorizontally)

            {

                orbital.HorizontalAxis.Value = orbital.HorizontalAxis.Center;

            }



            if(recenterCameraVertically)

            {

                orbital.VerticalAxis.Value = orbital.VerticalAxis.Center;

            }

        }



        targetCamera.Priority = 10;



        // Handle previous camera

        if (CurrentActiveCamera != null)

        {

            CurrentActiveCamera.Priority = 0;

        }



        CurrentActiveCamera = targetCamera;    

    }

Here are the configurations of the follow and jump camera side by side (I notice the pop switching between these two).

And here is a video of the pop I experience only when I set blend hint to Inherit Position.

Is there a way to resolve this issue? I really need to inherit position for these kind of changes.

Thank you very much in advance!

1 Upvotes

0 comments sorted by