Search Unity

Cancel active blend

Discussion in 'Cinemachine' started by wlad_s, Dec 3, 2019.

  1. wlad_s

    wlad_s

    Joined:
    Feb 18, 2011
    Posts:
    148
    Hello, this might have been answered already but I haven't found anything by googling.

    In my game, there is a reset function that resets the level to the beginning. But if I reset during active blend from CamA and CamB, I actually want to just cut to CamB on level reset, I can't find a way to stop that active blend and just cut to CamB.

    I've tried deactivating CamA and setting cineBrain.m_DefaultBlend to Cut but it doesn't work.

    I've also tried changing ActiveBlend.TimeInBlend and ActiveBlend.Duration values.

    Is there a way to cancel the currently active blend and start over?

    Thanks for any help.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Have you tried disabling then enabling the Brain?
     
    wlad_s likes this.
  3. wlad_s

    wlad_s

    Joined:
    Feb 18, 2011
    Posts:
    148
    I haven't tried that before. It works great now, thank you a lot!

    I've checked some of my older code, there's something bugging me. I'll try to explain.

    So, when character enters the room, we show him with Door-Enter_Camera, which slowly blends to the Room_Camera as character walks through the room. But then the character enters a portal in a wall and reappears at the door again, so we have to show him again with a Door-Enter_Camera and blend to the Room_Camera.

    The only way I found to do this is by making a coroutine which, when character enters the portal, sets the default blend to Cut, deactivates the currently active Room_Camera, activates Door-Enter_Camera and sets it to the top of priority queue.

    Then we "yield return null" in that coroutine, which waits for one frame, thus waiting for the cut from Room_Camera to Door-Enter_Camera to happen. Then, after yield, we set the default blend to ease and activate the Room_Camera, which starts the blend from Room_Camera to Door-Enter_Camera.

    It works great but I really don't like this approach with a coroutine and frame-waiting. Is it possible to just somehow override the active blend and abruptly set it to a new custom blend when needed?

    For example, in this situation, I would just set the active blend manually: set CamA to Door-Enter_Camera, CamB to Room_Camera, set blend to ease, blend duration to desired value and blend time to 0 in order to start it from the beginning (this would make that cut to CamA instantly).


    What would be the correct way to do this? Maybe I should think of something that involves disabling then enabling the Brain like in the solution to the previous problem.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    I think the disable/enable approach would work in this case, eliminating the need for a coroutine or for changing the default blend.