Camera Blending Issue

Hey guys, I have been having this issue with the blending between the Freelook Camera and a Virtual Camera. When I set the priority of the Virtual Camera to be higher than the Freelook Camera, the blending between the Freelook Camera going to Virtual Camera overshoots relative to the angle I am looking away from the object I am trying to look at.

I have attached all the information I believe to be necessary in the zip. If you need information please let me know.

Things I have tested: Testing the different permutations of the inherit and blending settings. Messing with different Camera blends using a camera blend asset. I have also looked into checking where and how I change my priority for the cameras.

I am using Unity 2019.4 and Cinemachine 2.7.1

6754393–779269–Cinemachine Blending.zip (385 KB)

cluelessclevergalapagosdove

A small gif of what is happening.

You’re having problems, I think, with the nature of the blend interpolation. Nothing in the BlendAssets will affect that. The problem likely is an artifact of the specific placement in worldspace of the targets and cameras, and the fact that you’re changing LookAt targets form one camera to the other. The BlendHints will have the most impact over how the blend is done.

It’s difficult from the images you sent to get a clear picture of what’s going on. Can you put together a small project that reproduces this setup and send me that?

Hang on… why do you have the camera in the target group? That feels weird and wrong. What exactly are you trying to do with the target group?

Hey Gregory, thanks for the response, I got a small sample scene in place. Please load the sample scene provided in Assets/Scenes/SampleScene.unity. The keys to move are WASD, and G to “Target” the small cubes that are tagged as targetable.

6754840–779332–CinemachineTest.zip (97.7 KB)

Right, so the reason the camera is in the target group is because I am trying to solve the issue of the camera pushing forward through objects to look at a target when there is something in between the follow and the target.

I have tested without the camera from the target group and that does fix the blending, but the resultant behavior is that when there is an object between the follow object and the target, the camera is pushed infront of the object in between.

This is what the resultant behavior looks like. I didn’t know the blending would be effected by the camera being in the target group. That is very interesting.
fearfulchubbygrasshopper

Thanks for uploading the scene, it makes it easier to understand.

The problem you describe is due to the CinemachineCollider on CMTargeting camera. Its job is to keep the LookAt target visible by pulling the camera in front of any occluding objects. That’s what its doing - it doesn’t care about the Follow target. If you remove the CinemachineCollider then the camera no longer pops in front of objects.

What I think you need is to make CinemachineCollider consider the FollowTarget instead of the LookAt target. Unfortunately, Cinemachine doesn’t come with this option out of the box.

Fortunately, it’s very easy to make a custom CM extension. Here is one that forces the collider to consider the Follow target instead of the LookAt target. Drop it into your project and add it to your CMTargeting vcam via the Extensions dropdown in the inspector.

using UnityEngine;
using Cinemachine;

/// <summary>
/// An add-on module for Cinemachine Virtual Camera that uses the Follow target as look at
/// </summary>
[SaveDuringPlay] [AddComponentMenu("")] // Hide in menu
public class LookAtFollow : CinemachineExtension
{
    [Tooltip("Where in the Cinemachine Pipeline to apply this change")]
    public CinemachineCore.Stage ApplyAfter;

    private void Reset()
    {
        ApplyAfter = CinemachineCore.Stage.Aim;
    }

    protected override void PostPipelineStageCallback(
        CinemachineVirtualCameraBase vcam,
        CinemachineCore.Stage stage, ref CameraState state, float deltaTime)
    {
        if (stage == ApplyAfter)
        {
            var follow = vcam.Follow;
            if (follow != null)
                state.ReferenceLookAt = follow.position;
        }
    }
}

Thank you Gregory for the help!

1 Like

you may see the unity tutorial