Search Unity

Making sure all group fits in smaller offset from center frame

Discussion in 'Cinemachine' started by ouva, Jan 10, 2020.

  1. ouva

    ouva

    Joined:
    Dec 28, 2015
    Posts:
    7
    Is there a way to, using cinemachine, make sure that all the targets in Cinemachine Target Group fit into a small square on screen? I can use the framing size to reduce the size, but since the viewport is 16:9, it keeps that ratio, and I'm wondering if there is a tighter control I can apply in screen space.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Maybe this in combination with the ScreenX/Y and Framing Size settings will do the trick

    upload_2020-1-10_8-49-37.png
     
  3. ouva

    ouva

    Joined:
    Dec 28, 2015
    Posts:
    7
    Hmm, I was using horizontal and vertical. When I switched to vertical or horizontal, it worked only for the targets that are laid out horizontally or vertically (otherwise it would zoom in/out too much). What is the mechanism behind vertical/horizontal only framing mode?
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Horizontal Only will ignore the vertical dimension, and Vertical Only will ignore the horizontal. Unfortunately there is no finer control in the Framing Transposer, and so the aspect ratio will be preserved by default.

    One way you might do what you need is to use an intermediate group as a target. Put a single member in it and add a custom script that references the real group, which sets the member's position to the real group's center and and sets the radius to be the real group's bounding radius (there's an API call in CinemachineTargetGroup to get that). Then you can frame that sphere in a small box on the screen, using VerticalOnly.

    Does that make sense?
     
  5. ouva

    ouva

    Joined:
    Dec 28, 2015
    Posts:
    7
    I had to come back to this and actually resolve it. Gregoryl, how can I frame the sphere in a box afterwards? That's the part I'm not sure I understand.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,711
    Use the standard Group Framing "vertical" option to frame the intermediate target. The size you set will define the onscreen size of the box into which the targets will be fit.
     
  7. ouva

    ouva

    Joined:
    Dec 28, 2015
    Posts:
    7
    Got it. I had to use both vertical and horizontal together, otherwise it didn't work for vertical viewports. I didn't understand why framer didn't already do this without the intermediate sphere, though.