Stop blending between virtualcameras

Hi,

I’ve got virtualcameras on dollycart. One is set to look at dollytrack, others to look at GameObjects. I need to pause dollycart and cameras movement on mouse button click. Problem is, when I’m in the middle of blending between dollytrack camera and camera looking at some gameobject, I can’t pause the movement.

I don’t want to use Time.timeScale = 0; because I dont want to pause the game, just camera movement.

I tried enabling and disabling cameras but when I enable the camera the first movement is jerky.

Any ideas?

In the very latest CM 2.4.0 (available in preview) there is CinemachineCore.UniformDeltaTimeOverride. Set it to 0 to pause the CM Brain, set it to -1 to resume.

1 Like

Hi,

thank you for your fast reply !

I upgrade my Cinemachine to 2.4.0 preview 9 but now I have compiler errors :

Assembly has reference to non-existent assembly ‘Unity.Timeline’ (Packages/com.unity.cinemachine/Runtime/com.unity.cinemachine.asmdef)
Assembly has reference to non-existent assembly ‘Unity.Timeline’ (Packages/com.unity.cinemachine/Editor/com.unity.cinemachine.Editor.asmdef)

But from what I saw, I already have Timeline installed by default…

Im using Unity 2018.3.14f1, I hope I won’t have to upgrade :frowning:

Ah yes, CM 2.4 is only compatible with the most recent 2018.4 and up. I would strongly recommend upgrading.

Hello,

There is an other way to stop or modify the current blend? Because the modification of CinemachineCore.UniformDeltaTimeOverride will impact the damping on the virtual cam (and possibly some other stuff)?

(I search a way to be able to change the duration of the blend when it’s already started. To accelerate the blend if the play want pass a cinematic for example)

Thank you

In fact, we have added a method in CinemachineBrain to set the current active blend, but that has not been released yet.

See this thread for a workaround: How to make Cinemachine complete current blending immediately?

Thanks for your answer, I will look for the workaround.

Do you know approximately when you will release the new version of Cinemachine with this method?

We don’t have a precise date, but my estimate is that the delay can be measured in weeks, not months.

Thank you for your answer!

I find a way to do what I want with the information you send me and reflexion.

public void UpdateTransitionDuration(float _value)
{
    // Use reflexion to get current cinemachine blend
    Type cinemachineBrainType = typeof(Cinemachine.CinemachineBrain);
    FieldInfo cinemachineBrainMFrameStack = cinemachineBrainType.GetField("mFrameStack", BindingFlags.NonPublic |
                 BindingFlags.Instance);
    IList mFrameStack = cinemachineBrainMFrameStack.GetValue(CameraManager.Instance.CinemachineBrain) as IList;
    FieldInfo brainFrameBlendFieldType = mFrameStack[0].GetType().GetField("blend");
    CinemachineBlend cinemachineBlend = brainFrameBlendFieldType.GetValue(mFrameStack[0]) as CinemachineBlend;

    if (cinemachineBlend.IsComplete)
        return;

    // Calculate progression percentage and set new variables
    float percent = cinemachineBlend.TimeInBlend / cinemachineBlend.Duration;
    cinemachineBlend.TimeInBlend = percent * _value;
    cinemachineBlend.Duration = _value;
    brainFrameBlendFieldType.SetValue(mFrameStack[0], cinemachineBlend);
}