This tutorial shows you how to set up a third-person camera using Cinemachine's Free Look camera that follows your player, allows mouse-controlled rotation, and automatically avoids obstacles.
1 Install Cinemachine
First, make sure Cinemachine is installed in your project:
- Go to Window → Package Manager
- Select Unity Registry from the dropdown
- Search for Cinemachine
- Click Install
2 Add a Free Look Camera
- In the Hierarchy, go to Cinemachine → Free Look Camera
- A new CM FreeLook object will be created
3 Configure Follow Target
- Select the CM FreeLook camera
- In the Inspector, find the Follow field
- Drag your Player object into the Follow field
The camera will now follow your player's position.
4 Set Up Look At Target
By default, looking at the player centers on their feet. To fix this:
- Create an empty GameObject as a child of your player
- Name it "LookAt"
- Position it at the center of your character (e.g., Y = 2)
- Drag this LookAt object into the camera's Look At field
Using a dedicated LookAt object gives you precise control over where the camera focuses, without being tied to the player's pivot point.
5 Configure the Orbits
The Free Look camera has three orbital rigs: Top, Middle, and Bottom. Configure each one:
| Rig | Height | Radius |
|---|---|---|
| Top Rig | 7 | (adjust to taste) |
| Middle Rig | 5 | (adjust to taste) |
| Bottom Rig | 4 | (adjust to taste) |
As you move the mouse up/down, the camera transitions between these rigs.
6 Adjust Input Settings
Invert Y-Axis (Optional)
If your vertical camera control feels backwards:
- Find the Y Axis settings in the Inspector
- Check the Invert checkbox
Binding Mode
To prevent the camera from rotating with your player:
- Find Binding Mode in the Orbits section
- Change it from "Simple Follow With World Up" to World Space
7 Add Obstacle Avoidance
To prevent objects from blocking the camera view:
- Select the CM FreeLook camera
- Scroll down to Extensions
- Click Add Extension
- Select Cinemachine Collider
Collider Settings
| Setting | Value | Description |
|---|---|---|
| Minimum Distance From Target | 1 | Prevents camera from going past the character |
| Strategy | Pull Camera Forward | Zooms in when obstacles are detected |
Pull Camera Forward zooms the camera closer when obstacles block the view. Other strategies include ray-casting techniques for different behaviors.
8 Smooth Camera Movement (Optional)
For smoother obstacle avoidance (less snappy transitions):
- In the Cinemachine Collider extension
- Adjust Damping (e.g., 0.5)
- Adjust Damping When Occluded (e.g., 0.5)
Higher damping values create smoother camera movement but may cause brief clipping through objects. Find a balance that works for your game.
Final Result
Your camera now:
- Follows the player smoothly
- Rotates with mouse input
- Automatically avoids obstacles
- Zooms in when near walls or objects