Search Unity

Problem with blending when using Confiner 2D

Discussion in 'Cinemachine' started by Yuriy_Sevastyanov, Feb 17, 2020.

  1. Yuriy_Sevastyanov

    Yuriy_Sevastyanov

    Joined:
    Apr 9, 2017
    Posts:
    25
    I use an orthographic main camera and Cinemachine with two virtual cameras. I want to change views smoothly by switching between two virtual cameras with a default blend mode. And it works perfectly as expected until I add Confiner with 2D mode. After that, the cameraFrom jumps under the bounding shape on start blending.
    I tried to overcome this problem but I found nothing. It really breaks my game logic.
    Any suggestions?

    2020-02-18 02-48-13.gif
     
  2. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    It's not clear for me what the problem is from the gif. Could you put together a project where I can reproduce it, then I will gladly have a look at it ;)
     
    Last edited: Feb 17, 2020
  3. Yuriy_Sevastyanov

    Yuriy_Sevastyanov

    Joined:
    Apr 9, 2017
    Posts:
    25
    I prepared a sample project. There are two scenes "What I want" and "What it does". The difference is only Confiner 2D (turned on and turned off).
    Just play the scenes and switch cameras by "w" and "s"
     

    Attached Files:

  4. Yuriy_Sevastyanov

    Yuriy_Sevastyanov

    Joined:
    Apr 9, 2017
    Posts:
    25
    Hello!
    Do you have any suggestions?
     
  5. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    Sorry for the slow reply @Yuriy_Sevastyanov
    The jump happens due to a regression (same issue as https://forum.unity.com/threads/cin...-hitch-in-the-transition.828669/#post-5498653), and will be fixed in the next release.

    However, in the meantime, you can avoid having this problem by changing the vcam priorities instead of enabling/disabling your vcams.

    For example:
    In your example scene, you have two vcams. View 1, and View 2. Both have priority 10.
    Instead of enable/disable, do the following:
    • When you want to CinemachineBrain to show View 1, then set priority of View 1 to 11, and priority of View 2 to 10.
    • When you want to CinemachineBrain to show View 2, then set priority of View 1 to 10, and priority of View 2 to 11.
    This way you will have the expected behaviour.
     
    Last edited: Feb 24, 2020
    Gregoryl likes this.
  6. Yuriy_Sevastyanov

    Yuriy_Sevastyanov

    Joined:
    Apr 9, 2017
    Posts:
    25
    Hello, @gaborkb
    I'm glad to hear from you. Thank you for the suggestion. If I'm able to get done the rest parts of my game before the release I will follow for your instruction or rollback Cinemachine version.
    Anyway, thank you for your reply. Now, I know that it is unwanted behavior and will be fixed.
     
    Gregoryl and gaborkb like this.
  7. Yuriy_Sevastyanov

    Yuriy_Sevastyanov

    Joined:
    Apr 9, 2017
    Posts:
    25
    I rebuilt the project with Cinemachine 2.6.0-preview.2. Unfortunately, the jumps are still there. Maybe I do it in the wrong way? I attached the updated project, so, you can reproduce the problem:
    1. Open CameraTestProject2.6.0-preview.2
    2. Open "What it does" scene
    3. Run
    4. Press Space
     

    Attached Files:

    gaborkb likes this.
  8. gaborkb

    gaborkb

    Unity Technologies

    Joined:
    Nov 7, 2019
    Posts:
    856
    We had a look at the project. The problem is that you are disabling the confiner bounding shape along with the vcam.
    This causes one our functions to never return true.

    In the meantime, a workaround is to not disable the confining shapes until the associated vcam is no longer live.
     
    Last edited: Mar 11, 2020
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    To explain a little further: in Unity, Colliders that are disabled effectively don't exist, and it is impossible to test them for collisions and intersections, so the confiner stops working. You need to keep the confining shapes enabled until the vcam blend is finished.
     
    Yuriy_Sevastyanov and gaborkb like this.
  10. Yuriy_Sevastyanov

    Yuriy_Sevastyanov

    Joined:
    Apr 9, 2017
    Posts:
    25
    But if I disable the vcam it still exists for blending, doesn't it?
     
  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    yes, its life is artificially prolonged for the duration of the blend. Unfortunately this can't be done for the confining shape.
     
    Yuriy_Sevastyanov likes this.