Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Find currently active camera

Discussion in 'Cinemachine' started by KID0, Oct 22, 2018.

  1. KID0

    KID0

    Joined:
    Aug 24, 2018
    Posts:
    2
    I've been trying to do the camera transition(2D) when you enter new rooms like old nes style, e.g megaman and the game slows down as the camera transitions to the new room.

    I am doing it in a cheap way, I guess(?)I've set multiple cameras with borders, every time the player collides with the boarder it deactivates the current camera and enables the new one, like the usual way
    Code (CSharp):
    1. cam2.SetActive(false);
    2. cam4.SetActive(true);
    and having to hardcode each single camera.
    I haven't gone too far because this would be terrible optimization wise, since I would have to do this for any variation between cameras possible and specify them, so I was wondering, is there a way to find the currently active camera in cinemachine and disable it, so I could cut out a chunk of the code,thanks in advance.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,233
    CinemachineBrain.ActiveVirtualCamera
     
    Spankie, ttesla, dav_ege and 5 others like this.
  3. hyagogow

    hyagogow

    Joined:
    Apr 25, 2014
    Posts:
    26
    If you still need this feature, I recently developed a package which transites the Cinemachine Camera between placed areas on your level. It works fine for a perspective camera as well for a 3D side scroller game.

    As a main feature, you can create/edit regions inside the Scene view:




    Check out the package repo for more information.
     
    andreiagmu, DuckCandle, id0 and 5 others like this.
  4. Hazneliel

    Hazneliel

    Joined:
    Nov 14, 2013
    Posts:
    303
    This seems to be returning the parent of the cameras but not the actual active virtual camera
     
  5. antoinecharton

    antoinecharton

    Unity Technologies

    Joined:
    Jul 22, 2020
    Posts:
    156