How can I tell when I've reached my active virtual cam / blend has completed?

Hello!

I notice there are some events I can hook up to in my Cinemachine Brain - namely “Camera Cut” and “Camera Activated” but I need to do something when the current blend to the active virtual cam has completed (we have matched the active cam).

What is the best way to do this?

At the moment I have a virtual camera which has a script which takes care of reading user input and allows them to look and fly around. I then also have some static virtual cameras arranged at key positions / rotations.

I’ve been using Cinemachine perhaps incorrectly as I am currently using it to smoothly move the main camera from this flying virtual cam to some static shots. What I want to do is once I have reached these static shots is to teleport my flying virtual cam to match the static shots and return control to the user. I’ve got this working with a key press but I’d like to get it to happen automatically once the blend is complete.

Am I going about this the wrong way? Also how complete are the online API docs and where are they?

Cheers!

@JRW_WSP You can find the API doc in the Cinemachine install directory within your project. It’s .chm file. It’s preliminary and minimal and there aren’t examples yet, but it should serve to get you going.

There is no event that marks the completion of a blend. You could poll the brain and check the IsBlending property. When that returns false, the blend is finished (unless another blend has started in the meantime).

1 Like

You could also poll CinemachineCore.Instance.IsLive(vcam) with your player cam. When that returns false, you know that vcam is no longer participating in a blend and can safely be teleported.

6 Likes

Ok thanks for the info - I think I need to rethink how I’m doing this because that isn’t working for me unfortunately!

Edit: oh I’ll try your second method and see if that will work for me - cheers

CinemachineCore.Instance.IsLive(vcam) did the job! Many thanks… never would have worked that out myself.

I hate to necro an old post, but it’s worth noting that CinemachineCore.Instance.IsLive is not 100% reliable.

public async Task SwitchToCamera(CinemachineVirtualCamera cameraToSwitchTo)
{
    currentCamera.Priority = 0;

    await FadeOut();

    cameraToSwitchTo.Priority = 1;

    do
    {
        await Task.Yield();
    }
    while (CinemachineCore.Instance.IsLive(currentCamera));

    currentCamera = cameraToSwitchTo;
    Debug.Break();
    await FadeIn();
}

In the code above the Debug.Break() is reached before “currentCamera” and “cameraToSwitchTo” can even start their blend.

1 Like