Using Target Group with Trigger Action

I have a game with two controllable characters and am using Cinemachine with a Target Group to track them both, which works well.

I now want to use a Cinemachine Trigger Action, with the Target Group itself as the trigger (i.e. any part of the total Target Group enters, it gets triggered, the whole Target Group has to leave to be un-triggered).

I’m guessing this isn’t supported, as I can’t get it to work. I added a RigidBody and BoxCollider to my Target Group object, but nothing. Any ideas?

(When selecting the Virtual Camera that uses the Target Group in the Scene View, it shows a bounding box around the Target Group, which is the bounding box I want to use as the trigger activator.)

This is not supported directly, but you could have a script on your Target Group. This script would create a BoxCollider and would dynamically set the bounds of the BoxCollider to match the bounds of the yellow box, which you see in the scene view.

To get the bounds of the yellow box, do the following for example:

public CinemachineTargetGroup targetGroup; // set in the editor

void Update()
{
        myBoxCollider.size = targetGroup.BoundingBox.size;
}

I created a small project and I could make it work this way. Hope it helps. :slight_smile:

2 Likes

Ah, that’s great. Thank you!