Search Unity

Control blend via script

Discussion in 'Cinemachine' started by ellenblomw, Jan 28, 2019.

  1. ellenblomw

    ellenblomw

    Joined:
    Mar 4, 2018
    Posts:
    153
    Hello,

    I want to switch between three cameras with a rough cut between the first ones and a blend between second ones. But I can't get it working. When running the code the blend happens all the way from oldcam directly to newsinglecam. However: If I comment out the last three lines I get the rough cut from oldcam to singlecam, but of course then I don't get the blend switch to my last cam. Why does the rough cut dissappear when adding the three last lines?

    Code (CSharp):
    1.  
    2.             brain = FindObjectOfType<CinemachineBrain>(); //Get our camera brain
    3.             brain.m_DefaultBlend.m_Time = 0; // 0 Time equals a cut between coming two cams
    4.             oldCam.m_Priority = 2; // Cut from this cam...
    5.             singleCam.m_Priority = 99; // ... to this cam
    6.             brain.m_DefaultBlend.m_Time = 2; // Time equals a blend between coming two cams
    7.             singleCam.m_Priority = 2; // Slide from this cam
    8.             newSingleCam.m_Priority = 99; //... to this cam
    9.  
    Respectfully, Ellen
     
    Last edited: Jan 28, 2019
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Hi Ellen,

    You need need to make the cut happen on one frame (i.e. without the last 3 lines), allow that to be processed, and then execute the last three lines on the next frame.

    Normally, instead of playing around with the default blend, one would set it to something reasonable, then leave it alone. To get specific blends for specific vcams, you can set up the Custom Blends asset on the brain.

    upload_2019-1-28_9-15-18.png