Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Cinemachine blend issues between two Virtual Cameras

Discussion in 'Cinemachine' started by lasher1225, Jan 7, 2020.

  1. lasher1225

    lasher1225

    Joined:
    Dec 27, 2019
    Posts:
    12
    I'm working on a 2D project using virtual cameras in each "room". The rooms are different sizes and are larger than the screen, so as the character moves, the camera will follow them around. I'm working on transitioning my character from one room to the next, similar to in 2D Zelda or Mega Man - a 1-2 second scroll from "room1" to "room2". The problem I have is when I use the blending options from the Main Camera menu to work with the virtual cameras, I get an issue where once I hit the box collider 2D that separates the rooms, the transition starts at a different location in my "room1" before catching up to the character's location in "room2". How do I get it to blend from where my character was in the first virtual camera to where my character is after hitting the collider at his new position in room2? Also as a side note, how do I "freeze" my character and all enemies in room2 until the 1-2 second blend is completed?

    I appreciate any help or guidance. I had looked around for the past few days and couldn't find anything previously that would help me. Thank you.
     
    Plantae likes this.
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Sounds like user error. Vcam blending should blend from the current vcam position to the new one. There should be no pop at the start of the blend. Can you show some images of your setup? Also what version of Unity and CM?
     
  3. lasher1225

    lasher1225

    Joined:
    Dec 27, 2019
    Posts:
    12
    I'm sure it is user error on my end. Just started trying to learn here doing some online tutorials and am just in the process of playing around and seeing what I can create.

    Here is my Main Camera Settings
     

    Attached Files:

  4. lasher1225

    lasher1225

    Joined:
    Dec 27, 2019
    Posts:
    12
    Room 1 (actually titled "Town1")
     

    Attached Files:

  5. lasher1225

    lasher1225

    Joined:
    Dec 27, 2019
    Posts:
    12
    Room2 (titled "Lighthouse") and my collider options that triggers the blend
     

    Attached Files:

  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    What's this "CameraMovement" script? That's probably the source of the problem.
    Can you show the project hierarchy? I need to see the brain, the player, and the vcams.
    Also what version of Unity and CM please.
     
  7. lasher1225

    lasher1225

    Joined:
    Dec 27, 2019
    Posts:
    12
    I disabled the CameraMovement script in the project, that was the script I was using prior to using Cinemachine. I am using Unity 2018.4.14f1 Personal and Cinemachine 2.2.9
     

    Attached Files:

  8. lasher1225

    lasher1225

    Joined:
    Dec 27, 2019
    Posts:
    12
    Player info
     

    Attached Files:

  9. lasher1225

    lasher1225

    Joined:
    Dec 27, 2019
    Posts:
    12
    virtual cam for lighthouse
     

    Attached Files:

  10. lasher1225

    lasher1225

    Joined:
    Dec 27, 2019
    Posts:
    12
    virtual cam for town
     

    Attached Files:

  11. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    ok, thanks for all that info.
    Your hierarchy looks good.

    Let's try simplifying a few things to eliminate variables:

    1. Delete your custom blends
    2. Change the brain's default blend to ease in/out 2 seconds
    3. In both vcams, set the Blend Hint to None, and uncheck "Inherit Position"

    Now, when you activate the second vcam, do you get a smooth transition?
     
  12. lasher1225

    lasher1225

    Joined:
    Dec 27, 2019
    Posts:
    12
    I tried those settings (had them before I messed around with various changes) and still the same problem.
     
  13. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    If you'd like to PM me your project I could have a look.
     
  14. lasher1225

    lasher1225

    Joined:
    Dec 27, 2019
    Posts:
    12
    I'll do that. At work now, but will do it when I get home. How do I send over the project?
     
  15. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    The best way would be to export a unitypackage, but if it's small enough you can zip it up. Then attach it to your message, or post it to some other place and send me a link.
     
  16. lasher1225

    lasher1225

    Joined:
    Dec 27, 2019
    Posts:
    12
    Here, exported it. Wasn't sure how to send it through the Conversation option privately, as there was no Upload File option.
     

    Attached Files:

  17. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,658
    Thanks for that. The problem is that you're deactivating the outgoing collider before the blend is finished. You have to keep it active. When I change your FrameSwitch.cs to not deactivate the outgoing frame, the blend is nice.

    Note that you should keep all the vcams at the same priority, and let Room.cs handle the vcam activation. If you overlap the room colliders a little, then you could eliminate the need for FrameSwitch logic altogether, and get rid of the Edge collider objects.
     
  18. lasher1225

    lasher1225

    Joined:
    Dec 27, 2019
    Posts:
    12
    Thanks! That did the trick. I just got rid of the Edge Collider objects and my player is moving flawlessly between the two areas.

    I only bumped up the priority for my town vcam which is where my player starts. If I had moved it down to the other priorities, I find my camera starts in the forest area while my player is still in the town.
     
    Gregoryl likes this.