Course contentsShow
← Unity Game Development
Lesson 398 of 8286. Animation and CinemachineFree lesson

Applying Weighting and Radius for Balanced Target Group Compositions

You will master adjusting individual target weights and radii to prioritize specific characters within a multi-target camera frame.

In this lesson, you will learn how to fine-tune your CinemachineTargetGroup settings to create professional, intentional camera compositions when tracking multiple subjects.

The Problem of Equal Importance

When you add multiple targets to a CinemachineTargetGroup, Cinemachine defaults to treating them all as equally important. It calculates the center point and zoom level to fit everyone within the frame, which often results in a "loose" shot where the main hero is lost among secondary NPCs. To fix this, we manipulate Weight and Radius.

Mastering Weight and Radius

Think of the Weight as the "gravitational pull" a target exerts on the camera's focus, and the Radius as the "personal space" the target requires.

  • Weight: If you have a primary protagonist and a secondary companion, setting the hero's weight to 2 and the companion's to 1 forces the camera to prioritize the hero’s position. The camera’s center will shift significantly toward the character with the higher weight.
  • Radius: This defines the target’s footprint. Increasing the radius tells the camera, "This target needs more screen space." This is useful for large objects, vehicles, or characters that shouldn't be framed too tightly, preventing them from clipping the edges of the screen during fast movement.

Applying Settings via Scripting

While you can adjust these in the Inspector, you can also manipulate them dynamically during gameplay to emphasize specific narrative beats:

public CinemachineTargetGroup targetGroup;

public void PrioritizeHero(int index) {
    // Increase importance of the hero at index 0
    targetGroup.m_Targets[0].weight = 2.0f;
    targetGroup.m_Targets[0].radius = 5.0f;
    
    // De-prioritize the background character at index 1
    targetGroup.m_Targets[1].weight = 0.5f;
}

By tweaking these two properties, you stop the camera from being a "passive observer" and turn it into a tool for visual storytelling, ensuring the most important action always dictates the frame.

Key Takeaway: Use Weight to dictate the camera’s focal priority and Radius to manage the physical framing space allocated to each individual target.