Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Stop blending between virtualcameras

Discussion in 'Cinemachine' started by KingaO, Dec 2, 2019.

  1. KingaO

    KingaO

    Joined:
    Apr 16, 2018
    Posts:
    19
    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?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
    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.
     
    Silent_Whisper likes this.
  3. KingaO

    KingaO

    Joined:
    Apr 16, 2018
    Posts:
    19
    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 :(
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
    Ah yes, CM 2.4 is only compatible with the most recent 2018.4 and up. I would strongly recommend upgrading.
     
  5. nicoplvubi

    nicoplvubi

    Joined:
    Oct 23, 2019
    Posts:
    3
    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
     
    Last edited: Jul 22, 2021
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
  7. nicoplvubi

    nicoplvubi

    Joined:
    Oct 23, 2019
    Posts:
    3
    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?
     
  8. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,268
    We don't have a precise date, but my estimate is that the delay can be measured in weeks, not months.
     
  9. nicoplvubi

    nicoplvubi

    Joined:
    Oct 23, 2019
    Posts:
    3
    Thank you for your answer!

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


    Code (CSharp):
    1. public void UpdateTransitionDuration(float _value)
    2. {
    3.     // Use reflexion to get current cinemachine blend
    4.     Type cinemachineBrainType = typeof(Cinemachine.CinemachineBrain);
    5.     FieldInfo cinemachineBrainMFrameStack = cinemachineBrainType.GetField("mFrameStack", BindingFlags.NonPublic |
    6.                  BindingFlags.Instance);
    7.     IList mFrameStack = cinemachineBrainMFrameStack.GetValue(CameraManager.Instance.CinemachineBrain) as IList;
    8.     FieldInfo brainFrameBlendFieldType = mFrameStack[0].GetType().GetField("blend");
    9.     CinemachineBlend cinemachineBlend = brainFrameBlendFieldType.GetValue(mFrameStack[0]) as CinemachineBlend;
    10.  
    11.     if (cinemachineBlend.IsComplete)
    12.         return;
    13.  
    14.     // Calculate progression percentage and set new variables
    15.     float percent = cinemachineBlend.TimeInBlend / cinemachineBlend.Duration;
    16.     cinemachineBlend.TimeInBlend = percent * _value;
    17.     cinemachineBlend.Duration = _value;
    18.     brainFrameBlendFieldType.SetValue(mFrameStack[0], cinemachineBlend);
    19. }
     
    Last edited: Jul 25, 2021