Transition back to previous active vcam when stopping Cinemachine in Timeline

So, I’m having a base CinemachineFreeLook cam as the character camera, and playing a timeline on awake, I can get it transitioned nicely to the Cinemachine clip in the timeline from the base cam, but if I wanted to stop the timeline from playing depending on the current situation in-game, it will jump-cut back to the base cam instead of a transition.

Here’s a gif for better visualization

In the gif, I’m pressing “a” to stop the timeline around the cam blends in the timeline

public class Test : MonoBehaviour
{
    public PlayableDirector d;

    void Update()
    {
        if (Input.GetKey("a"))
        {
            d.Stop();
        }
    }
}

Is there any way of dealing with this kind of situation. If possible, doing manual transition in code when stopping the timeline.

I looked up the forum and saw that CM used SetCameraOverride for overriding the default behavior of CM for Timeline, so is it that ReleaseCameraOverride will ignore the transition somehow?

Thanks in advance!

[Edit] was intended to post in CM forum, since its more CM related, but accidentally posted here.

While the timeline is active and overriding the current virtual camera, the priority system is still active under the hood. Maybe you can try something like this: when you want to stop the timeline, get the current active camera from the brain (it will be the current timeline override vcam) and boost its priority so that it’s higher than the normal vcam. Then stop the timeline. Next frame, lower the priority of that vcam again, and it will blend back to the normal vcam.

Thanks for the suggestion, just tried to raise the priority of active vcam upon key press but seems it still jump back to the default camera upon stopping the director,

so I tried a bit hacky way by trigging RaiseCameraPriority below via signal before the transition in timeline happens, and it kinda works…

// This is the result of stopping during blends
https://gyazo.com/2ba9bc0ac7cfc99caa38de858186c329

// This is the result of stopping after vcam fully transited
https://gyazo.com/2ba9bc0ac7cfc99caa38de858186c329

    private ICinemachineCamera timelineVCam;
    private int timelineVCamPriorityCache;

    void Update()
    {
        if (Input.GetKeyDown("a"))
        {
            d.Stop();
            //restore the previous priority
            timelineVCam.Priority = timelineVCamPriorityCache;
        }
    }

    public void RaiseCameraPriority()
    {
        timelineVCam = brain.ActiveVirtualCamera;
        //cache the previous priority
        timelineVCamPriorityCache = timelineVCam.Priority;
        timelineVCam.Priority += 40;
    }

Yes, that idea won’t work if the timeline stops during a transition.

Here is another idea:
Make a second timeline, this one with only a single CM track with a clip for the default vcam blending in:

6194959--679552--upload_2020-8-12_6-23-39.png

When you want to stop your timeline, start this one, wait for the duration of the blend, then stop both of them.

1 Like