Search Unity

Stackable TargetGroups

Discussion in 'Cinemachine' started by giantdoor, Nov 17, 2019.

  1. giantdoor

    giantdoor

    Joined:
    Sep 11, 2018
    Posts:
    52
    So, I have a splitscreen in which each camera has it's own target group.
    At some point, as you can see, the splitscreen merges into a single view, and I would need the target groups to "merge".
    The easiest thing I can think about, would be adding TG2 to TG1's m_targets array, so that will make the whole thing more dynamic, and easier to split back.
    Is that possible? If not, is that even considered to be supported in the future?

    Adding TG2 to TG1's targets juast adds it's transform, while id it added all the targets, would actually make more sense.
     
    Last edited: Nov 17, 2019
  2. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    Target Groups are kinda dumb: they don't pry into their members' business. So yes, it's just a transform. You'll have to write your own code for merging the members in. If you want the merge to happen gradually, you could make a coroutine to lerp in the weights over a period of time.

    I suppose this sort of thing could be collected into some kind of TargetGroup utility behaviour, for merging members in and out, and that could have the smarts for detecting whether members are themselves groups, and for dealing appropriately with it.

    Feel free to post here any code you develop along those lines.
     
  3. giantdoor

    giantdoor

    Joined:
    Sep 11, 2018
    Posts:
    52
    The thing is that to make it project-independent, the TargetGroup code would need to be changed in the CM package.
    Basically I would run a check whenever a new target Transform is added to a TargetGroup, if that Transform has also a TargetGroup component attached, the TG members are added together with the Transform itself, that will be given a weight of 0. When removing a Transform, you run the same check and remove all connected transforms.
    Not sure if I explained clearly though ^^"
     
  4. Gregoryl

    Gregoryl

    Unity Technologies

    Joined:
    Dec 22, 2016
    Posts:
    7,724
    I think you could do it without changing the TargetGroup code. Just add a helper behaviour that manages adding/removing members. Don't add directly to the TargetGroup, instead add to the helper which will do the checks and processing you mention and manipulate the group.