Search Unity

[Solved] Global extensions

Discussion in 'Cinemachine' started by alkaitagi, Nov 18, 2019.

  1. alkaitagi

    alkaitagi

    Joined:
    Dec 8, 2016
    Posts:
    87
    Hi,

    How can I make a Cinemachine extension to be applied for every virtual camera in scene? Currently I have 2d confiner on my main virtual camera, and once the control is passed to secondary virtual camera I need that 2d confier to still have effect. Trivially adding an extension to every virtual camera does not seem to scale well as the number of cameras can raise.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    It's possible with a little creative work.

    "Manager-style" vcams, such as StateDrivenCamera, MixingCamera, and BlendListCamera, allow you to place an extension on them, which will apply to all their managed vcam children. You could either use one of those manager classes, or make a new kind of manager camera that does nothing but group the vcams and provide a place to hang global extensions on.
     
  3. alkaitagi

    alkaitagi

    Joined:
    Dec 8, 2016
    Posts:
    87
    While that definitely makes sense, it is not very applicable to my particular design. I will explain in more details. I have one "main" camera that follows player. And then I have other cameras per each checkpoint. So when player dies, I disable main camera and enable camera on that particular checkpoint player is going to respawn at, to provide smooth camera movement.
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Are the "checkpoint" cameras static, or can they move around? Do you then re-activate the "main" follow camera after the player has spawned?
     
  5. alkaitagi

    alkaitagi

    Joined:
    Dec 8, 2016
    Posts:
    87
    Ah well, I guess I can just have one global "checkpoint" camera that every checkpoint can warp on its position and then activate.
     
  6. alkaitagi

    alkaitagi

    Joined:
    Dec 8, 2016
    Posts:
    87
    They are static, and each checkpoint has virtual camera component on it. Right, I reactive main camera after respawn.
     
  7. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Then why do you need the confiners on the checkpoint cameras?
     
  8. alkaitagi

    alkaitagi

    Joined:
    Dec 8, 2016
    Posts:
    87
    A checkpoint can be located right on the edge of the map, so when camera moves on it and subsequently centers on it, the viewport gets to see outside of the map. And its looks even weirder when main camera takes action back and confines it again.
     
  9. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    ah, ok. I like your idea of using a single checkpoint camera and warping it as needed. Nice and simple.
     
  10. alkaitagi

    alkaitagi

    Joined:
    Dec 8, 2016
    Posts:
    87
    Sure, thank you for the quick responses!
     
    Gregoryl likes this.
  11. alkaitagi

    alkaitagi

    Joined:
    Dec 8, 2016
    Posts:
    87
    Making custom extensions-only manager camera sounds like it could be the most convenient way. Where should I look at to see how to pass down extensions?