Overview
Camera control—following players, looking at targets, dramatic cutscene transitions—is crucial for game immersion and feel. Traditionally, these movements were hand-coded scripts adjusting transform.position in LateUpdate, requiring extensive tuning for smooth, natural motion.
Cinemachine modularizes complex camera control, enabling even non-programmers to intuitively build highly sophisticated camera work. For both 2D and 3D, it offers everything from simple follow cameras to automatic composition with multiple targets, camera shake effects, and smooth blending between cameras—all the tools for cinematic camera work.
This article covers Cinemachine's basic concepts and the most common use case: Follow Cameras.
Cinemachine Architecture
To start, install the Cinemachine package from Package Manager (Window > Package Manager).
Cinemachine consists of two main elements:
-
Cinemachine Brain: Component attached to the main camera. The "brain" that determines which
Virtual Camerais active and applies its state to Unity's main camera. Automatically added when placing aVirtual Camerain the scene. -
Virtual Camera: Cinemachine's star. A
Virtual Cameradoesn't render anything itself—it defines "how to position and move the camera." Place multipleVirtual Camerasin scenes and change their Priority to switch active cameras. The highest-priorityVirtual Camerais selected byCinemachine Brainand its settings are applied to the main camera.
Creating 2D/3D Follow Cameras
Follow cameras tracking player characters are the most common camera setup. Cinemachine enables high-quality follow cameras in just a few clicks.
Step 1: Create Virtual Camera
Select GameObject > Cinemachine > Virtual Camera from the menu. A new Virtual Camera is created, and Cinemachine Brain is automatically attached to the main camera.
Step 2: Set Target
Select the created Virtual Camera. In Inspector, drag and drop the Transform of the object to follow (player character, etc.) into these two key properties:
- Follow: Camera position follows this target, maintaining relative position.
- Look At: Camera always faces this target. Use in 3D games to keep characters centered on screen.
Step 3: Adjust Behavior
Virtual Camera Inspector has many properties for fine-tuning camera behavior:
-
Body Section: Defines camera "position" behavior relative to
Followtarget.Framing Transposer: Powerful mode for both 2D and 3D. Maintains target's screen position (Screen X,Screen Y). SettingDead Zonekeeps camera stationary while target stays within that area, reducing unnecessary camera shake.Damping: Sets follow "smoothness." Higher values make camera follow more slowly and smoothly.0follows instantly with no delay.
-
Aim Section: Defines camera "orientation" behavior relative to
Look Attarget. LikeFollow, setDampingto smooth turning. -
Noise Section: Adds pseudo camera shake using
Perlin Noise. Effective for cutscenes or tense moments.
Switching and Blending Multiple Cameras
Cinemachine's true power shows when handling multiple Virtual Cameras.
-
Priority-Based Switching: Place multiple
Virtual Cameraswith different behaviors (normal camera, zoom camera, fixed camera). From script or events, set the desiredVirtual Camera'sPriorityhigher than others—Cinemachine Brainautomatically switches cameras. -
Smooth Blending: When cameras switch,
Cinemachine Brainsmoothly transitions (blends) from previous to next camera based onDefault Blendsettings. Instead of abrupt cuts, cameras move and rotate smoothly like in films.
Summary
Cinemachine is essentially the de facto standard for camera control in modern Unity development.
- No more hand-coded follow scripts—Cinemachine enables higher-quality camera work easily.
- Main camera gets
Cinemachine Brain;Virtual Camerasdefine behavior. - Set
FollowandLook Attargets onVirtual Camera, adjust following inBodyandAimsections. - Switch cameras easily by changing
Virtual CameraPriorityvalues.
Camera work significantly affects game quality. Introducing Cinemachine frees developers from complex camera logic, letting them focus on creative cinematography.