Search Unity

How to force jump to virtual camera (skip blend) with code

Discussion in 'Cinemachine' started by Creta_Park, Jun 25, 2019.

  1. Creta_Park

    Creta_Park

    Joined:
    Mar 11, 2016
    Posts:
    40
    Hello again, I'm keep trying and experimenting on Cinemachine.
    Here's some my stuff

    axisTracker.gif


    Anyway, my experience is getting better with Cinemachine for good shot in my game!
    But, I stucked some problem.

    without force jump.gif

    I was using a way to move a map around a scene using similar resources.
    I wanted to quickly move the Cinemachine Brain camera to the virtual camera location of the map. (force jump)

    However, if set 'basic blend' to cut, there are too many elements to care about 'custom blend' and many exceptions, so I do not know how to do this.

    Is there way to can ignore blend in script?

    + I am using the way to disable the current virtual camera and activate the virtual camera to change the camera. At that time I checked ActiveBlend and it was null.

    upload_2019-6-25_19-19-9.png

    upload_2019-6-25_19-19-24.png
     
    Last edited: Jun 25, 2019
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,605
    I'm not 100% sure I understand the problem.

    You can set the brain's default blend to something that's good for most of your transitions.

    Then, if you want to make an exception, the way to do it is to create a Custom Bend asset and add an entry that says: whenever I transition to cameraX, use this setting (which can be "cut").

    Here is an example, where the default blend is ease in/out, but there is an override to cut when transitioning to vcam1:

    upload_2019-6-25_13-8-23.png
     
  3. Creta_Park

    Creta_Park

    Joined:
    Mar 11, 2016
    Posts:
    40
    Thanks for response, But...

    blends.gif

    In my case :
    - Every area(map) has own custom blends and set to Brain's custom blend field when arrives area. (it's fine because every area are disabled except current area)
    - So, this solution makes too many cases and hard works for making levels... (and makes too many cases of scenario).
    - I want only change force to set next target virtual cam in code (ignore blends)

    * Sorry for poor english
     
  4. Creta_Park

    Creta_Park

    Joined:
    Mar 11, 2016
    Posts:
    40
    So I tried various ways.
    First, I tried to make Brain's ActiveBlend to null. But it was only a 'get' access limiter.
    The second was force the Blend to ignore the Blend's progress time or something like that before trying to start blending.
    But of course this is null in the code to switch to above because ActiveBlend is not specified right away. (refer first thread article)
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,605
    Did you try:
    1. Deactivate all vcams
    2. move the new vcam to the desired position (and its target also, if it has one)
    3. activate the new vcam
    That should do what you're looking for, if I understand correctly

    EDIT: you might have to disable the Brain in step 1, and re-enable it in step 3, to fully clear out its state
     
  6. Creta_Park

    Creta_Park

    Joined:
    Mar 11, 2016
    Posts:
    40
    Okay, problem solved! thank you for quick support!

    upload_2019-6-25_23-11-45.png

    upload_2019-6-25_23-12-6.png
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    2,605
    I'm glad it's solved, but I think you can simplify it by eliminating the coroutine and doing it all in one frame. You don't need to wait.
     
    Creta_Park likes this.
  8. Creta_Park

    Creta_Park

    Joined:
    Mar 11, 2016
    Posts:
    40


    + A reason of adding wait is for some case of exception (OnTriggerEnter like things)
     
    Gregoryl likes this.