Search Unity

Issue with 2D virtual cameras and switching between rooms

Discussion in 'Cinemachine' started by oddgibbon, Aug 15, 2019.

  1. oddgibbon

    oddgibbon

    Joined:
    Nov 9, 2018
    Posts:
    2
    Hello,

    I'm having an issue with the virtual camera switching. I'm making a tilemap based game with room transitions (like classic Zelda), and when I go through a door I'm disabling the current room's virtual camera and then enabling the next room's one.

    The issue (which can be seen in the gif linked below) is that when I go up into the next room, the camera overshoots the room by a full room height and ends up directly above the room.

    I believe I have everything setup correctly but I could be wrong.

    Any ideas what might be causing it? Let me know if more info is needed.

    Virtual camera inspector (runtime, room 1): https://imgur.com/0ESdHxS
    Object hierarchy: https://imgur.com/8psgEoO
    Gif of the issue: https://imgur.com/B0Hgz2R
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Is the bounding shape bigger than the orthographic size, in both dimensions?
     
  3. oddgibbon

    oddgibbon

    Joined:
    Nov 9, 2018
    Posts:
    2
    So, your question prompted me to look into the room collider, and it turns out I somehow overlooked that the collider itself was sitting above the room's position :/

    I'm setting the points of the collider at runtime based on the room size (so that I don't have to manually set them for every room) but I guess something is wrong with my logic.

    Just to confirm, I manually set the room collider to the proper position and the camera transition worked as expected.

    Thank you!
     
    Gregoryl likes this.