Search Unity

Blend between a list of cameras

Discussion in 'Cinemachine' started by compyler, May 7, 2022.

  1. compyler

    compyler

    Joined:
    Mar 30, 2020
    Posts:
    102
    Hello!

    I have 3 virtual cameras (cam1, cam2, cam3) and want to smoothly blend from cam1 to cam2 and from cam2 to cam 3 via code. In the CinemachineBrain I set "Default Blend" to "Custom" and in the table I have:
    FROM: cam1 TO: cam2 Style: Ease In Out TIME:1.8
    FROM: cam2 TO cam3 Style: Ease In Out TIME: 2s
    In my code when a certain event happens I set the priority of cam2 to 1 (to switch to cam2) and after a delay of 1.8s I set the priority of cam2 to 1 (and priority of cam1 to 0).

    This all works but the problem is the blend from cam2 to cam3 is not smooth at all. Cinemachine blends between cam1 and cam2 (very smooth), then the blending is done and after that the blending to cam3 starts (this is very noticable).

    Is there any way to make smooth to a camera after a blend has just been performed?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Why do you do this? It is unnecessary. The default blend is used only if there is no specific blend defined in the CustomBlends assets for the cameras currently blending. It is a fallback.

    Can you show a video? I suspect it has to do with the specific positions of the camera involved. When one blend happens immediately after another, CM does not attempt to consider all 3 cameras as a single blend, so there is no reason to expect it to look like one. There is likely a better way to get the effect you're trying to achieve.
     
  3. compyler

    compyler

    Joined:
    Mar 30, 2020
    Posts:
    102
    Thanks for your reply!

    I don't understand what you mean. Without the "Default Blend" set to "Custom" (and Custom Blends set to an asset) I thought I only have ONE global blend settings for ALL blends. I use a custom blend setting cause I want the blend from cam1 to cam2 (2s) faster than from cam2 to cam3 (like 1s)

    Currently I can't make a video:( The behavior is like this: Cam1 blends smoothly to cam2. Then there is a tiny pause (like 0.1s) and then cam2 gets blended into cam3. At least it feels as if there is a tiny pause (like 2 curves that touch but with different tangents at the touch point).

    Maybe its because I don't start the blend from cam2 to cam3 at the EXACT moment when blend from cam1 to cam2 finishes? (I set the blend time to 2s and use a LeanTween.delayCall() with 2s)

    Is the blend from cam2 to cam3 (RIGHT after a blend from cam1 to cam2 has been performed) supposed to be continuous (aka super smooth)?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    The default blend will be used only for those blends that are not specifically covered by the custom blend asset. It means: "use this blend for everything else". So you should set it to something reasonable.

    Yes, exactly. There is no reason to suppose that the tangents will line up. It won't necessarily feel smooth.

    Instead of that, try starting the second blend before the first one finishes. The blends stack in Cinemachine, so during the overlap of the 2 blends you will have ((A -> B) -> C) which is a 3-way blend. You might have to reposition B because the camera will never go there exactly, but the result will probably be smooth.
     
  5. compyler

    compyler

    Joined:
    Mar 30, 2020
    Posts:
    102
    I actually tried that. The blend from A to B is 2s and after 1.8s delay I set the priority of C as the highest to go from B to C. But again the movement is very choppy. It seems to me that Cinemachine immediately stops the blendf rom A to B once I set the priority of C as the highest.
    How would your suggested 3-way-blend look in code? (as far as I understand the API at any point in time there can only be ONE blend between two cameras)
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    If you interrupt a blend with another blend, the first blend will continue as the source of the second blend, as in ((A -> B) -> C). Setting the priority of C to highest will work. Try increasing the overlapping time. It's hard for me to suggest anything more without a visual of the problem and an image of your blend settings.