Search Unity

Target Group auto zoom out

Discussion in 'Cinemachine' started by electro_unity, Jun 10, 2019.

  1. electro_unity

    electro_unity

    Joined:
    Nov 29, 2015
    Posts:
    64
    Hi, I've set my virtual camera as shown here.

    a1.PNG

    And a target group (it grows dynamically)

    a2.PNG

    It actually works almost as intended, camera is following player without rotating. And it also gets adapted when a new target enters the group. The problem comes when the group members get very distant, I'd like the camera to zoom out. Is there any option to achieve this? Thanks.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    Try using a FramingTransposer instead. It's made exactly for this situation.
     
    electro_unity likes this.
  3. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    @Gregoryl What if you are using a target group with a free look cam?

    The result I'm looking for is to let the user manage the camera rotation and a certain zoom range but that range should automatically be remapped up and down within limits as a kind of autozoom to keep all targets in view.

    When the max auto zoom level is reached targets can fall out of view and are removed from the target group. If it gets in view again it gets added back into the group.

    I've tried several things but I'm stuck with 2 problems:
    1. How can I combine a transporter (for auto zoom) with user input for the rotation and zoom?
    2. How do I set a target group to allow targets to fall of the edge of the screen?
     
    Last edited: May 27, 2020
  4. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    Ok I finally figured out we just had to change the aim to "Group Composer" on the Freelook cam.

    Still, not sure about point 2 though.
     
  5. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,728
    In the group composer, you can set limits to how much the camera will zoom/dolly. If you then want to remove group members that are more than a certain distance from the group center, maybe you can write a custom script to lerp the group member weights to 0 as a function of distance from group center (don't suddenly add or remove members with nonzero weight, because that will change the group boundaries and make the camera jump). Attach that script to the group.

    Not knowing anything about the specifics of your camera setup and usecase, I wonder whether FreeLook is the best camera choice. Have you considered FramingTransposer + POV? See the 3rdPersonWithAimMode sample scene for an example of that. FramingTransposer has built-in group composing logic when the target is a group.
     
  6. tcz8

    tcz8

    Joined:
    Aug 20, 2015
    Posts:
    504
    I will go try all that.

    Once again, thank you for your help!