What would be the best way to do conditional blending between cameras

I’m trying to switch back and forth between 2 virtual cameras that will follow agents. What I want to do is blend between them with Ease In and Out if the agents are close, or cut from one to the other if the agents are far.

Is this possible? Not sure how I would do it.

Thanks in advance!

https://docs.unity3d.com/Packages/com.unity.cinemachine@2.8/api/Cinemachine.CinemachineCore.html#Cinemachine_CinemachineCore_GetBlendOverride

Thanks for the response, but I can’t figure out how to use this or make it work to do what I want.

Would you mind elaborating on how this can be implemented?

You create a callback that matches the signature for CinemachineCore.GetBlendOverrideDelegate, something like this:

CinemachineBlendDefinition MyCustomBlendOverride(
            ICinemachineCamera fromVcam, ICinemachineCamera toVcam,
            CinemachineBlendDefinition defaultBlend,
            MonoBehaviour owner)
{
    if (fromVcam == myInterestingFromVcam && toVcam == myInterestingToVcam 
        && myInterestingConditionsAreSatisfied)
    {
        return mySpecialBlend;
    }
    return defaultBlend;
}

Install it from some monobehaviour’s Start():

void Start()
{
    CinemachineCore.GetBlendOverride = MyCustomBlendOverride;
}
1 Like

Ok thank you! I think I mostly have it working, but I have a follow up question:

When I cut between two cameras it just moves really quickly, is there a way to make a sort of instant cut?

My set up is as follows:

I have VCam1 following Target 1

Then I switch to VCam2 and make it follow Target 2

Switch to VCam1, follow Target 3

Switch to VCam2, follow Target 4

etc.

The issue is that when I cut from one cam to the other, I can still see the camera move to the target and I’m trying to make it a complete cut. Does that make sense?

If the blend time is 0, then it is an instant cut.

It’s possible that if you cut and then change the target, the cut works but the new vcam thinks that its target suddenly moved to a new place, so the damping kicks in as it tries to catch up with the target. When you change the target, also set vcam.PreviousStateIsValid=false to cancel the damping.

1 Like

Perfect, thanks a ton, this was so helpful!!!

1 Like