How to manage the blend between cameras manually in the script?

I’m working on a 2D game. I have multiple cameras with confinder2Ds in the scene. When the player crosses a trigger I change the priority to the right camera. My problem is the blend seems like a jump (even when using EaseInEaseOut). I want to change to the new camera but not blending all the way to the new camera.

Assume something like the picture below. We have two cameras here. Camera A is confined to not show the right of the middle room and Camera B is confined to not show the bottom of the platform. Because cameras don’t have overlapping bounding areas, we will have a jumpy feeling. When the player crosses the trigger it feels like the camera suddenly gets free.

My idea to solve the problem is to blend cameras not by time but by player movement. Meaning when the player crosses the trigger, I start lerping between two cameras and as the player moves I lerp more toward the target camera. It will smooth the blend and if the player stops moving, blend stops too which have better feelings.

Can this be achieved by script? I saw the IBlend interface but couldn’t figure out how to use it and if it is possible with it or not.

With CM2 it’s not possible to override the blend algorithm itself (you can do that with CM3).

However, I think for your specific case you can implement what you want by using CinemachineMixingCamera. This is a manager-style camera that does a continuous blend of its child cameras, based on the child weights that you can drive from a script.

Thanks for your reply
I’m using CM3. Is there any example of how to override the blend algorithm?

I considered using CinemachineMixingCamera. I have a multi scene setup which loads scenes additively. All my cameras are not in the same scene. Is it possible to add cameras from other scenes to MixingCamera in the runtime? Or do they have to be children of the mixing camera?

Oh! You should say so (and I should notice the blue icons in your image).

Yes, have a look at Custom Blends sample scene

They have to be children, but you can reparent them dynamically. You can also create a variant of MixingCamera that does not depend on the inputs being children (but you would have to take care not to create infinite loops).