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

Implementing Camera Follow and Look At Targets

Learners will configure the body and aim components to make a virtual camera dynamically track and rotate toward a moving game object.

In this lesson, you will learn how to configure the Body and Aim components of a Cinemachine Virtual Camera to dynamically track and rotate toward a moving target.

While the Cinemachine Brain handles the hand-off between cameras, the real magic happens within the Virtual Camera’s inspector. To make a camera follow and focus on an object, you must assign a Follow target and a Look At target.

Configuring the Body

The Body component controls how the camera tracks the Follow target's position. By selecting an algorithm like Framing Transposer or Third Person Follow, you tell Cinemachine exactly how to maintain a relative distance from your player. For example, by adjusting the Dead Zone and Soft Zone, you define an area where the player can move freely without the camera shifting, creating a professional, smooth feeling rather than a jittery, locked-on view.

Configuring the Aim

While the Body follows the position, the Aim component handles the rotation. By assigning a target to the Look At slot, the camera will automatically rotate to keep that object within a specific part of the screen. You can use the Composer or Group Composer to offset the target within the frame, ensuring your character isn't always stuck dead-center, which is essential for proper cinematic composition.

You can update these targets dynamically via script if your player changes or if you need to focus on an enemy during combat:

using Cinemachine;

public class CameraController : MonoBehaviour
{
    public CinemachineVirtualCamera vcam;
    public Transform player;

    void Start()
    {
        // Dynamically assign targets at runtime
        vcam.Follow = player;
        vcam.LookAt = player;
    }
}

By decoupling the movement logic (Body) from the rotational logic (Aim), you gain precise control over how your camera "feels" as it traverses your game world. Adjusting these settings allows you to transition from a tight, claustrophobic third-person view to a wide, sweeping perspective without writing complex math from scratch.

Key Takeaway: The Body component manages position tracking via the Follow target, while the Aim component manages rotational focus via the Look At target, allowing for sophisticated, automatic camera movement.