Search Unity

How to blend between two virtual cams by code

Discussion in 'Cinemachine' started by DiegoR, Dec 7, 2017.

  1. DiegoR

    DiegoR

    Joined:
    Oct 31, 2012
    Posts:
    33
    I am trying to figure out how to blend between two virtual cameras by code.

    I have tried in the documentation and tutorials but the major part of them are focused on describe the properties of the components or how to use Cinemachine with Timeline.

    First I tried adding a Custom blend to the CinemachineBrain but I don't know how to "execute" that blend.

    Then I tried adding a CinemachineBlendListCamera and it seems that it requires to have virtual camera childs so I am forced to duplicate many of my current virtual cam definitions to create different type of possible blends.

    Is there any part of the documentation that mention how to deal with this using C#?
     
  2. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    The easiest way is just changing vCam priority to the highest one from all of them.

    @Gregoryl @Adam_Myhill Is there any better way?

    You can find documentation in the About section in Unity - Cinemachine->About->Documentation.
     
    Last edited: Dec 7, 2017
  3. DiegoR

    DiegoR

    Joined:
    Oct 31, 2012
    Posts:
    33
    I can use the CinemachineBlendListCamera for that but it requires to have child vcams. I have 7 vcams in the scene and I want to blend from anyone to anyone. Should I need to create 42 CinemachineBlendListCamera gameobjects and duplicate many times each vcam?

    I saw that there is a "CreateBlend" method in CinemachineBlendListCamera but it's private (yes, I know that I can change it but I will need - in that case - to change it everytime I make an update of Cinemachine and cause it's not part of the interface it could change anytime).

    Yes, I checked it first but the documentation (pdf document) describes the different type of objects and the properties of the components. Then you have the "code" documentation that describes the properties and methods of each class but I couldn't find anything regarding the execution of a blend from C#.

    Cheers.
     
  4. JakubSmaga

    JakubSmaga

    Joined:
    Aug 5, 2015
    Posts:
    417
    If it works for you and there is no other way then yeah.

    You also could just disable every vCam that you are not using and just enable the one that you need (It will lerp and also save you performance).

    It's up to you which technique you will use.
     
  5. DiegoR

    DiegoR

    Joined:
    Oct 31, 2012
    Posts:
    33
    Oh! Using MoveToTopOfPrioritySubqueue it will look for the definition of the blend in the custom blends of CinemachineBrain and use that information for the blend.

    Thanks! :)
     
  6. Adam_Myhill

    Adam_Myhill

    Joined:
    Dec 22, 2016
    Posts:
    342
    JakubSmaga likes this.