---
title: "Camera and lighting"
content_type: tutorial
url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile/tutorial/camera-and-lighting?language=en"
language: en
container_type: course
container_title: " Tanks: Make a battle game for web and mobile"
container_url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile.md?language=en&version=6.0"
standalone_markdown_url: "https://learn.unity.com/tutorial/camera-and-lighting.md?language=en&version=6.0"
previous_title: "Tank control"
previous_url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile/tutorial/tank-control?language=en&version=6.0"
previous_markdown_url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile/tutorial/tank-control.md?language=en&version=6.0"
next_title: "Firing shells"
next_url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile/tutorial/firing-shells?language=en&version=6.0"
next_markdown_url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile/tutorial/firing-shells.md?language=en&version=6.0"
difficulty: beginner
duration_minutes: 20
unity_version:
  - "6.0"
  - "6.1"
  - "6.2"
  - "6.3"
supported_unity_versions:
  - name: "6.0"
    url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile/tutorial/camera-and-lighting.md?language=en&version=6.0"
  - name: "6.1"
    url: "https://learn.unity.com/tutorial/camera-and-lighting.md?language=en&version=6.1"
  - name: "6.2"
    url: "https://learn.unity.com/tutorial/camera-and-lighting.md?language=en&version=6.2"
  - name: "6.3"
    url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile/tutorial/camera-and-lighting.md?language=en&version=6.3"
last_updated: "2026-08-04T14:24:42.000Z"
---

# Camera and lighting

Configure a dynamic Camera setup and lighting tweaks to strengthen your game’s visuals.

Setting up a dynamic camera system and refining lighting to enhance the game's visuals.

## 1. Overview

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/3dbefc8e-f437-4ee9-b877-5732daaca67c_3.0_-_Overview.mp4)

In this tutorial, you’ll configure a camera system that dynamically follows both tanks, ensuring optimal visibility during gameplay. You'll start by creating a **CameraRig** to control movement and zoom, then add a **CameraControl** script to automate tracking. After testing and refining your camera settings, you'll move on to **lighting adjustments**: modifying ambient and directional light to achieve the desired atmosphere. By the end, your game will feature a responsive camera and polished lighting, creating a more immersive experience.

## 2. Make a second tank

To test the camera system, you need two tanks in the scene. You’ll duplicate the existing tank and assign different controls to each player.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/568da98b-ec5f-4342-9da4-e651702fce70_3.1_-_Make_a_second_tank.mp4)

**1.  Duplicate the tank**

- Select the **Tank** GameObject in the **Hierarchy** window.
- Press **Ctrl**+**D** (macOS: **Cmd**+**D**) to duplicate it.
  - The new tank will be placed directly on top of the original.

**2.  Move the new tank**

- Select the **Move** tool.
- Drag the new tank to a different position in the scene.

**3.  Rotate the new tank**

- Select the **Rotate** tool and drag the **green** handle.

**Tip:** Drag in a straight line for smoother rotation.

**4.  Rename the tanks**

- Select the **Tank** GameObject and rename it “Tank 1”.
- Select the **Tank (1)** GameObject and rename it “Tank 2”.

**5.  Assign controls to Tank 2**

- Select the **Tank 2** GameObject and locate the **TankMovement** **(Script)** component in the **Inspector** window.
- Set the **Player Number** property to **2**.

This assigns the arrow keys as the input instead of the **WASD** keys.

**6.  Press Play to test**

- Select the **Play** button to enter Play mode.
- If both tanks move together, ensure the **Tank 2** GameObject has its **Player Number** property set to **2**.

Your scene now has two tanks with separate controls that are ready for camera tracking.

## 3. Create and configure the CameraRig

We are going to create an empty container called **CameraRig** for our camera. The **CameraRig** will act as a parent to the **Main Camera**, allowing scripts to control both camera movement and zoom dynamically.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/4f5e37cc-41d6-46d9-a39a-4c8f425231f2_3.2_-_Create_and_Configure_the_CameraRig.mp4)

**1.  Create the CameraRig**

- Right-click in the **Hierarchy** window and select **Create Empty**.
- Rename the empty GameObject “CameraRig”.

**2.  Reset its position**

- Select the **CameraRig** GameObject in the **Hierarchy** window.
- In the **Inspector** window, open the **Transform** component’s **More** (**⋮**) menu and select **Reset** (or manually set the **Position** property values to **X** = **0**, **Y** = **0**, and **X** = **0**.

**3.  Test the setup**

- In the **Hierarchy** window, click and drag the **Main Camera** GameObject onto the **CameraRig** GameObject to make it a child GameObject.
- Move the **CameraRig** GameObject in the **Scene** view and verify that the camera moves along with it in the **Game** view.
- The **CameraRig** GameObject will also adjust the camera’s **Size** property, affecting how much of the scene is visible.

The **CameraRig** GameObject is now set up to control both movement and zoom, preparing it for scripting in the next step.

## 4. Add and configure the Camera Control script

Now that the **CameraRig** is set up, you’ll add a script to dynamically control the camera’s movement and zoom.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/a40a0593-f708-4c76-9491-75ecb61c9013_3.3_-_Add_and_configure_the_Camera_Control_script.mp4)

**1.  Add the Camera Control component**

- Select the **CameraRig** GameObject in the **Hierarchy** window.
- In the **Inspector** window, select **Add Component**.
- Search for “Camera Control” and select it.

**2.  Assign the tanks as tracking targets**

- In the **Inspector** window, in the **Camera Control (Script)** component, use the foldout (triangle) to expand the **Targets** section, then select the **Add** (**+**) button to add a new entry.
- Click and drag the **Tank 1** GameObject from the **Hierarchy** window into the **Element 0** box.
- Select the **Add** (**+**) button again and click and drag **Tank 2** into the **Element 1** box.

**3.  Press Play to test**

- Select the **Play** button to enter Play mode. And adjust the following settings if needed:
  - **Screen Edge Buffer:** Increases space around the tanks. If the camera isn’t tracking both correctly, try increasing this value.
  - **Min Size:** Limits how zoomed-in the camera can get.

**Note:** Any changes made in Play mode won’t be saved, so adjust settings outside of Play mode if needed.

Your camera now dynamically follows both tanks, adjusting position and zoom to keep them in view.

## 5. Adjust the Camera Background Color

When the camera zooms out, areas beyond the environment may become visible. To improve the look of these empty spaces, you’ll change the **Main Camera** background color.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/38486b6e-b3dc-4316-a73a-2dd37a4b1f2e_3.4_-_Adjust_the_Camera_Background_Color.mp4)

**1.  Preview the effect**

- In the **Hierarchy** window, use the foldout (triangle) to expand the **Camera Rig** GameObject, then select the **Main Camera** GameObject.
- In the **Inspector** window, use the foldout to expand the **Camera** component, then use the foldout (triangle) to expand the **Projection** section.
- Copy the **Camera Size** value you currently have and temporarily increase it until you can see the background in the **Game** window.

**2.  Change the background type**

- In the **Camera** component, use the foldout (triangle) to expand the **Environment** section.
- Open the **Background Type** property dropdown and select **Solid Color**.

**3.  Select a background color**

- Select the **Background** dropper and select a color from the scene (grass, cliffs, or buildings).
  - Alternatively, select the **Background** box and select a color from the **Color** wheel.
- In the **Projection** section, set the **Camera Size** value to the one you had before.

**Note:** If Unity requests screen access, enable it in your system settings.

The camera now displays a custom background color instead of the default skybox when zoomed out.

## 6. Optional: More things to try _(Optional)_

Try these optional activities to challenge yourself, build your skills, and improve your project!

Each challenge is tagged as **Easy**, **Medium**, or **Expert** difficulty so that you know what to expect. You can do one of them, all of them, or none of them — it’s totally up to you!

## Easy: Adjust the Directional Light

The **Directional Light** simulates sunlight or moonlight in your scene, casting shadows and defining the overall mood. Adjusting its properties allows you to create different times of the day and atmospheric effects.

![](https://connect-mediagw.unity.com/h1/20250328/learn/images/67758e97-5eba-42c2-95ed-072cdd86d393_3.5_-_Easy_-_Adjust_the_Directional_Light.png)

Select the **Directional Light** in the **Hierarchy** window.

In the **Emissions** section, adjust the following properties as you like:

- **Color:** Warmer tones create a sunset effect, while cooler tones simulate moonlight.
- **Intensity:** Controls the brightness of the light source.

In the **Shadows** section, adjust the following properties as you like:

- **Shadow Type:**
  - **No Shadows:** Disables shadows completely.
  - **Hard Shadows:** Creates a cartoony look.
  - **Soft Shadows:** Allows for more customization, making shadows appear more natural (default for this project).
- **Strength:** Determines how dark or light the shadows appear.

**Tip:** Rotate the **Directional Light** to experiment with different shadow angles.

If you need guidance, open the **\_Tanks** > **Prefabs** > **Environment** folders. Inside each **\[Theme\]** subfolder, you’ll find a **DirectionalLight\[Theme\]** prefab, which we’ve already set up to match the specific theme’s atmosphere.

## Medium: Change the environment lighting

Lighting settings define the overall brightness, contrast, and atmosphere of the scene. You’ll customize **environment** lighting to enhance the environment’s appearance.

![](https://connect-mediagw.unity.com/h1/20250328/learn/images/610d042d-79d9-4a0a-847d-77f2cba760ea_3.10_-_Medium_-_Change_the_environment_lighting.png)

- From the main menu, select **Window** > **Rendering** > **Lighting**.
- Dock the **Lighting** window next to the **Inspector** window for easy access.
- Select the **Environment** tab in the **Lighting** window.
- Under the **Environment** section**,** set the **Environment Lighting** **Source** property to **Color**.
- Select an appropriate color for the scene.

We previously tested values for each theme and found the following **Environment Lighting Source Colors** to work well. Feel free to use them if you’d like:

- **Moon:** RGB(94, 64, 149)
- **Jungle:** RGB(50, 65, 27)
- **Desert:** RGB(136, 129, 143)

Your environment's lighting is now customized, improving clarity and visual appeal.

If you’re not interested in doing these challenges, mark this step as complete.

## 7. Next steps

Congratulations!

With these steps completed, your game now has a fully functional dynamic camera system.

In the next tutorial, you’ll implement a health system for the tanks.
