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

Question Creating a "biased" Target Group

Discussion in 'Cinemachine' started by RobO_HB, Feb 1, 2023.

  1. RobO_HB

    RobO_HB

    Joined:
    Sep 16, 2013
    Posts:
    16
    Hello,

    I'm attempting to create a specific behaviour with Cinemachine, and I'm trying to figure out if it can be accomplished with built-in components or if I will need to write a custom composer and/or custom implementation of ICinemachineTargetGroup.

    Here's an example setup.
    StartingPoint.png

    I have four objects (cubes in this case) which I want to frame. This is the result if I put them all into a target group with weights of 1 and radii of 1. What I want to do is to bias the aim target (i.e. the centre of the camera shot) towards the cube on the left. My initial thought was to set the weight of that cube to, say, 2, while leaving the others as weight 1. However, this is the result:
    Adjusted_Weight.png

    The aim target is now roughly where I want it, but cubes on the right are now out of frame. This seems to be due to the fact that changing the weights also changes the bounding frustum for the group so that the cubes of a lower weight are no longer guaranteed to be inside of the bounding frustum. I can readjust this by manually adjusting the Group Framing Size:
    AdjustedGroupFramingSize.png
    But since this will ultimately be used for dynamic objects, manually adjusting the Group Framing Size by eye is not valid. It's also not conceptually doing what I'm looking for, even if the visual outcome is quite similar.

    To put it another way, I'm looking to bias the aim target of a target group unevenly, while ensuring that the calculated bounding frustum still encapsulates all of the targets in the group - understanding, of course, that this means the bounding frustum may wind up "too large" on the side of the target that the shot is biased towards. Therefore, this changes the effective group framing size, since the frustum now contains some empty space. But I'm less concerned about maintaining the exact size of the group on screen than I am with biasing the aim while still keeping all group members in-frame (when possible, since of course it may not be possible given the min and max FOV and the positioning of the camera).

    I have started to look at implementing a custom composer and ICinemachineTargetGroup to meet this goal. Before I head too far down that path, though, I wanted to ask if there's a way to accomplish this with the composer settings that are already included with Cinemachine that I just haven't figured out on my own. Does anyone know of a way to do this that doesn't involve writing a custom composer/target group implementation?
     
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,234
    You can do it by cheating the radius in the TargetGroup: set the radius of the object you wish to favor to be larger than it actually is.
     
    Last edited: Feb 1, 2023
  3. RobO_HB

    RobO_HB

    Joined:
    Sep 16, 2013
    Posts:
    16
    Ah, that's an interesting approach that I hadn't thought of. Thanks, I'll give that a shot!
     
    Gregoryl likes this.