Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Soft Remove target from TargetGroup

Discussion in 'Cinemachine' started by CDF, Jul 3, 2017.

  1. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    Bit of a difficult problem to solve here.

    I have a target group that adds/removes targets dynamically whenever certain situations occur in gameplay. Like an enemy becoming visible.

    The issue I'm having is when I remove an object from the array, the group composer snaps the bounds to the remaining targets in the list creating a hard cut to the new composition. As an example, player kills an enemy, enemy is removed from group, camera re-composes shot for remaining enemies.

    Wondering how I can get rid of this hard cut? Maybe if there was some smoothing to the boundary calculation?
    I might have to get into the Target Group code and play around, but was just checking if there's a solution out there?

    If I don't remove anything from the array, everything is nice and smooth, but the group is trying to frame dead enemies that have been despawned :( so the shots can get pretty wide.
     
  2. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    Ok I've solved this for now:

    When objects are added, create dummy objects for them
    Move the dummy objects to the target on every update
    When the object is removed, flag the dummy object as disabled
    When the dummy object is disabled, lerp it to the center of the group bounds
    When all dummy objects are disabled, disable the virtual camera with group composer
    When that camera has finished blending, clear the array

    Phew

    Hoping for a integrated solution...
     
  3. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    194
    Have this exact same snapping problem, nice solution though! I'm hoping they add more options on the grouping component to make this easier down the road
     
  4. LaneMax

    LaneMax

    Joined:
    Aug 12, 2013
    Posts:
    194
    I ended up finding another pretty easy solution. I just use two virtual camers with two target groups and blend between them, one target group that has the old items, and the other with the new items. Then I blend them by changing the Priority number. One thing nice about this is you have control of how you want the blend to look doing it this way.
     
    Gregoryl likes this.
  5. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,306
    Hi LaneMax, I'm still struggling with target groups as well, my blends are very shaky and sometimes the cameras just end up going crazy. Could you elaborate on the 2 camera setup?