Best way to find out if a virtual camera has fully transitioned?

Hiya! I was wondering what the best way to find out if a virtual camera has fully transitioned to another one is?
I’m planning to set my camera active and then do something like this in a coroutine:

while (cinemachineBrain.IsBlending)
{
    yield return null;
}

I don’t know if there’s any pitfalls in doing it this way or if there’s a better way, so I’d appreciate anyone’s advice on this.

Thanks!

Edit: My plan didn’t seem to work…

1 Like

It should work. IsBlending will return false when the blend is finished.

Hi! It didn’t seem to kick in until after a couple of frames. I had to use this code to get it to work:

IEnumerator ChangeCameraAfterBlendCoroutine()
    {
        cameraScript.ActivateCamera(10);
        yield return null; yield return null;
        while (cameraScript.cinemachine.IsBlending) { yield return null; }
        cameraScript.ActivateCamera(8);
    }

(The ActivateCamera function is just setting the virtual camera object active and deactivating the others in the list)

Is this still the best/ only way to wait for a blend to be finished or is there some other way? I checked the documentation but this was all I could find.

Thanks!

1 Like

That’s pretty much the way

1 Like

Great thanks!

Thanks, super helpful.

another way

private IEnumerator ChangeCameraAndDoSomething() {
        ChangeCamera();

        // cause IsBlending has little bit delay so it's need to wait
        yield return new WaitUntil(() => mainCamBrain.IsBlending);

        // wait until blending is finished
        yield return new WaitUntil(() => !mainCamBrain.IsBlending);

        WhatToDoAfterFinished();
    }

mainCamBrain is your cinemachine brain usually on main camera,
it’s may not a best way but it’s work