Search Unity

Question Tracked Object Offset doing nothing at all?

Discussion in 'Cinemachine' started by lemmons, Oct 18, 2022.

  1. lemmons

    lemmons

    Joined:
    Jun 20, 2016
    Posts:
    68
    Surely I've done something wrong here, but I feel like previously when I change the Tracked Object Offset of a Body -> Framing Composer it moves the camera but right now it's doing nothing at all and I can't figure out why. Any guidance would be greatly appreciated.

    Here's a short clip of what I'm seeing.

    The Virtual Camera I'm using is pretty much all default settings except Aim is set to Do Nothing because I don't want any rotation and the Look At is set to a Target Group. This particular target group only has one member but the same thing happens for my other cams that have multiple objects in their target group too.
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Probably the group framing functionality is overriding the offset.
    What happens when you change Framing Mode to None?

    upload_2022-10-18_8-2-12.png
     
  3. lemmons

    lemmons

    Joined:
    Jun 20, 2016
    Posts:
    68
    You're right! That gives control back to Tracked Object Offset but then it doesn't track the group if there are multiple members (obviously, haha). I can use the CameraOffset extension to cheat this a bit but it feels like a hack or like I'm doing something wrong that this isn't working like it appears it should. Additionally, I would expect camera zooming with CameraDistance to work the same way with Group Framing turned on or off but it doesn't appear to work that way.

    Just for context, my end goals are:
    • For the camera to track objects in the group as best it can.TargetGroups are doing this really well so no qualm there.
    • To be able to zoom the camera in/out while tracking a TargetGroup. Now, I'm able to write something custom to do this via the CameraOffset extension, but I would assume there's got to be a baked in way to do this. Modifying CameraDistance starts to add a weird rotation at a certain point.
    Here's another vid if you want to see what I'm seeing.
     
  4. Flaul1998

    Flaul1998

    Joined:
    Oct 19, 2022
    Posts:
    1
    hello,
    You need to get access to your framing transposer object like:

    yourCamera.GetComponentInChildren<CinemachineFramingTransposer>()

    and then you have access to any variable that your framing transposer has.




    mybkexperience
     
    Last edited: Oct 20, 2022
  5. lemmons

    lemmons

    Joined:
    Jun 20, 2016
    Posts:
    68
    @Flaul1998 Thanks! That was actually a little tricky to figure out at first but I'm already in there tweaking values in the code. Now that I know what was stopping Tracked Object Offset from working thanks to @Gregoryl it would be nice to know how to implement manual zooming since CameraDistance doesn't work the way I thought it would when tracking a TargetGroup using GroupFraming.
     
  6. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,730
    Without GroupFraming, the FramingTransposer will position the camera as directed relative to the follow target's position + tracked object offset. That is, it will place the camera at the specified distance, then shift the camera laterally to deliver the desired screen position.

    When Group Framing is enabled, the camera first does the above, then modifies the camera position and/or lens in order to deliver the requested group framing. When framing the group, the group's position is unimportant - only the bounding box is relevant. That's why the tracked object offset in this case is ignored. Unfortunately the group framer will always center the group's bounding box in the frame, there's no way in the Framing Transposer to alter that. Doing it separately with the CameraOffset extension is fine.

    Whatever the camera distance is, the group framer's job is to make the entire group appear on screen. That's why, when you change the distance, the framer adjusts the FOV to keep the group visible (what you called "weird rotation").

    If you want the user to be able to control how much of the group is visible on-screen, then you need to be tweaking the Group Framing Size field. A framing size of 1 means "make the group's bounding shape exactly fill the screen", 0.5 means "make it occupy half the screen", 2 means "make it occupy twice the screen", and so on.

    The size adjustment can be accomplished either by dollying in or out (which overrides the Camera Distance setting) or by leaving the camera where it is and zooming the lens, or by some combination of both. That is controlled by the Adjustment Mode:

    upload_2022-10-19_11-39-37.png

    You can set limits for how much the camera can move and/or zoom before giving up on the requested framing.

    Does this make sense? Let me know if you have any more questions.
     
    tsukimi and lemmons like this.
  7. lemmons

    lemmons

    Joined:
    Jun 20, 2016
    Posts:
    68
    That does make sense and I think I understand way more about groups and framing now. Thank you!
     
    Gregoryl likes this.