Search Unity

Cinemachine Custom Blend Time

Discussion in 'Cinemachine' started by Ame, May 3, 2019.

  1. Ame

    Ame

    Joined:
    Jul 10, 2012
    Posts:
    8
    Hi,

    I'm trying to add custom blends to the brain and virtual cams. In the inspector of the brain everything goes well, from ease to time .

    But when I try to change values through script at runtime, I'm able to access an element of the list , to get the curve and the time but I'm not able to "modify" them.

    With this code I access the blend settings of the first item in the list :
    Code (CSharp):
    1.  Camera.main.GetComponent<CinemachineBrain>().m_CustomBlends.m_CustomBlends[0].m_Blend;
    The time of the blend is 2 seconds , but it can change from a user choice, so I use this code to create a custom blend with user duration and my ease curve :

    Code (CSharp):
    1.  
    2. CinemachineBlendDefinition def = new CinemachineBlendDefinition(CinemachineBlendDefinition.Style.Custom,duration);
    3.         def.m_CustomCurve = Camera.main.GetComponent<CinemachineBrain>().m_CustomBlends.m_CustomBlends[0].m_Blend.m_CustomCurve;
    4.         def.m_Time = duration;
    5.         Camera.main.GetComponent<CinemachineBrain>().m_DefaultBlend = def;
    6.  
    With this code my strange curve is activated and works fine but the duration , even if set two times on m_Time or with constructor, is not used. It uses the default time of 2 seconds.


    Any help is appreciated.

    Thanks
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Is it possible that the blend is being created based on the original custom blend, and not the new default blend that you create? The blend lookup will use a custom blend if the vcam names match, and only use the default if no custom blend is found.
     
  3. Ame

    Ame

    Joined:
    Jul 10, 2012
    Posts:
    8
    Thanks for the reply.
    I think I misunderstood the custom blends list in the inspector cause I thought it was a list where you can choose the blend you created whenever you want and put it wherever you want and apparently it is different.

    I made it by creating an empty custom blend list and creating a normal animationCurve list where I pick the curve I want and it all works perfectly.

    Now I have another question about transitions : if I go from A to B but suddenly (in the middle of the transition) I start the transition to C by changing the priority , is there a possibility to cut the current transition and make the new one with the new duration and ease?

    Cause I tried this type of behavior but if the blend is linear and then cut, the cut won't be used cause the previous linear was not stopped and so the new blend is linear.
    I know that It seems very bad as mechanics that I'm trying to achieve but my game is like a "Be a Movie Director" so this is why I would like to achieve this specific behaviors.

    Thanks.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    In fact this is a bug in the current release of Cinemachine. In the upcoming release (2.2.9) the cut will correctly interrupt the blend in progress.
     
  5. Ame

    Ame

    Joined:
    Jul 10, 2012
    Posts:
    8
    Thank you very much for the info Gregoryl