---
title: "Start menu and Game Manager"
content_type: tutorial
url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile/tutorial/start-menu-and-game-manager?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.3"
standalone_markdown_url: "https://learn.unity.com/tutorial/start-menu-and-game-manager.md?language=en&version=6.3"
previous_title: "Audio mixing"
previous_url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile/tutorial/audio-mixing-1?language=en&version=6.3"
previous_markdown_url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile/tutorial/audio-mixing-1.md?language=en&version=6.3"
next_title: "Bonus features"
next_url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile/tutorial/bonus-features?language=en&version=6.3"
next_markdown_url: "https://learn.unity.com/course/tanks-make-a-battle-game-for-web-and-mobile/tutorial/bonus-features.md?language=en&version=6.3"
difficulty: beginner
duration_minutes: 60
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/start-menu-and-game-manager.md?language=en&version=6.0"
  - name: "6.1"
    url: "https://learn.unity.com/tutorial/start-menu-and-game-manager.md?language=en&version=6.1"
  - name: "6.2"
    url: "https://learn.unity.com/tutorial/start-menu-and-game-manager.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/start-menu-and-game-manager.md?language=en&version=6.3"
last_updated: "2026-08-04T14:24:38.000Z"
---

# Start menu and Game Manager

Build a simple game flow by creating a title screen, configuring a Game Manager, and adding player selection.

Create a Title screen, set up a Game Manager, and add a Player Selection screen.

## 1. Overview

In this tutorial, you'll create a Title screen for your game, set up a Game Manager to handle game logic, and add a Player Selection screen where players can choose their tanks before starting a match. You’ll be able to set the spawn points for the tanks, select which tanks appear in the Player Selection screen, and how many rounds are required to win the game.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/c7862a38-9bf8-4f27-b745-c1b79f9015eb_8.0_-_Overview.mp4)

## 2. Add a Title Canvas

The Title screen serves as the game's main menu, providing a clear starting point for players. In this step, you'll create a Canvas to display the title. A **Canvas** is a type of GameObject that serves as a container for UI elements in the scene.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/710319c8-746f-4f0e-ae51-e6d6af8f34c8_8.1_-_Add_a_Title_Canvas.mp4)

**1.  Create a new UI Canvas**

- Right-click in the **Hierarchy** window and select **UI** > **Canvas**.
- Rename the new GameObject “TitleCanvas”.

**2.  Frame the TitleCanvas GameObject in 2D mode for easier UI editing**

- In the **Scene** view, select the **2D** toggle in the **Scene** view toolbar.

**Note**: If you don’t see the **2D** toggle, you might need to expand the **Scene** view or enable the **View Options** overlay (open the **Scene** view’s **More** (**⋮**) menu, select **Overlay Menu**, and enable **View Options**).

- Select the **TitleCanvas** GameObject in the **Hierarchy** window, then hover over the **Scene** view and press **F** to frame it in view.

Alternatively, you can double-click the **TitleCanvas** GameObject in the **Hierarchy** window.

This will zoom you way out to reveal a giant rectangle in the scene — this is the **Canvas** area.

**3.  Add a text element for the title**

- In the **Hierarchy** window, right-click the **TitleCanvas** GameObject and select **UI** > **Text - TextMeshPro**, then rename it “TitleText”.
  - TextMeshPro is a Unity text rendering system that provides tools for typography and offers excellent clarity across devices.
- You should see **New Text** appear at the center of the **Game** view.

At this stage, you have a **TitleCanvas** GameObject set up with a basic text element, ready for styling in the next step.

## 3. Customize the title text

Now that you have a **TitleText** GameObject, you can edit it to look like an appropriate title. This includes setting the font, size, alignment, and color.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/c52a8477-2da4-4a67-9849-198631581909_8.2_-_Customize_the_title_text.mp4)

**1.  Set the title text content**

- Select the **TitleText** GameObject in the **Hierarchy** window.
- In the **Inspector** window, use the foldout (triangle) to expand the **TextmeshPro - Text (UI)** component. In the **Text Input** box, replace the default “New Text” with **"**TANKS!" or another title of your choosing.

**Note**: If you make a longer title, it may get split onto two lines. Don’t worry, you’ll fix that soon.

**2.  Choose a font and adjust the size**

- Select the **Font Asset** picker (**⊙**) and select one of the available fonts.
- Set the **Font Size** property to something around **60**.

**Note**: If you choose a large font, the title may get split onto two lines. Don’t worry, you’ll fix that next.

**3.  Adjust text layout**

- Open the **Text Wrapping Mode** property dropdown and select **No Wrap** to prevent the text from splitting into multiple lines.
- Set the **Alignment** property to **Center (Horizontal)** and **Middle (Vertical)** to center the text on the UI element.

**4.  Optional: Change the text color**

- The default white text looks good, but if you want to change the color, use the **Vertex Color** property and choose a different color.

Your game now has a properly formatted title.

## 4. Add a Player Select button with proper scaling

Next you need a button that allows players to move to the Player Selection screen. In this step, you'll create and style a new **Player** **Select** button under the title.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/5405ee99-e9e8-45d1-afbd-7908a5b81a8f_8.3_-_Add_a_Player_Select_button_with_proper_scaling.mp4)

**1.  Create the button**

- Right-click the **TitleCanvas** GameObject in the **Hierarchy** window, then select **UI** > **Button - TextMeshPro**.
- Rename the new GameObject “PlayerSelect_Button”.

The button will appear directly on top of the title — don’t worry, you’ll fix that soon.

**2.  Update the button text**

- Use the foldout to expand the **PlayerSelect_Button** GameObject in the **Hierarchy** window and select its **Text (TMP)** child GameObject.
- In the **Inspector** window, in the **Text Input** box, replace the default “Button” with "Player Select".
- Select the **Font Asset** picker (**⊙**) and select one of the available fonts (ideally matching the title font).
- Adjust the **Font Size** property and **Vertex** **Color** property to your preference.

**Note**: The text may not fit nicely on the button — you’ll fix that next.

**3.  Adjust the button size, style, and position**

- Select the **PlayerSelect_Button** GameObject in the **Hierarchy** window.
- In the **Inspector** window, increase the **Width** and **Height** properties of the **Rect Transform** component to fit the text.

**Tip**: You can click and drag the property name to the right or left to increase or decrease the value.

- Decrease the **Pos Y** property value to position the button appropriately below the title.
- If you want, choose a new color for the button background with the **Color** property of the **Image** component.
- You can also change the text color with the **Vertex Color** property in the **Text (TMP)** child GameObject.

Your Title screen now has a **Player Select** button, but it doesn’t work yet. You’ll add that functionality a bit later.

## 5. Adjust canvas scaling mode

Your Title screen may look perfect in your **Game** view right now, but if someone is using a large or high resolution screen, the text may appear very small. In this step, you’ll set the canvas to scale with the screen size so that the text keeps its proportions relative to the screen, rather than maintaining a constant pixel size.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/054f9909-0487-4a9b-aaff-fe3b4575e13a_8.4_-_Adjust_canvas_scaling_mode.mp4)

**1.  Preview your game at different resolutions**

- In the **Game** view, open the **Aspect Ratio** dropdown, which is probably set to **Free Aspect**. It could also be set to another resolution (for example, **Full HD**), or another aspect ratio (for example, **16:9**)
- Test different screen resolutions and aspect ratios in the **Game** view and notice how the text gets very small at higher resolutions.
- When you’re done testing, select **Free Aspect**, which allows you to freely resize the **Game** view window to any dimensions.

**2.  Set the Canvas to scale with screen size**

- In the **Hierarchy** window, select the **TitleCanvas** GameObject**.**
- Use the foldout to expand the **Canvas** **Scaler** component and set the **UI Scale Mode** property to **Scale With Screen Size**.
- If the text suddenly becomes too large, you can increase the **Reference Resolution** property  **X** and **Y** values to reduce the relative text size to your liking.

**3.  Retest your Title screen at different resolutions**

- In the **Game** view, open the **Aspect Ratio** dropdown to test different screen resolutions.

Notice how the text stays the same relative size even at higher resolutions.

- When you’re done testing, select **Free Aspect**.

The **TitleCanvas** GameObject is now set to scale relative to the size of the screen the game is played on, ensuring that the text and button will increase in size as the screen does.

## 6. Create a spawn point

To determine where the tanks appear at the start of a game and which direction they’ll face, you need to define spawn points in the scene. In this step, you’ll add your first spawn point.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/74ab263c-d3d8-4d5b-9ed7-9e1f501a1dd2_8.5_-_Create_a_spawn_point.mp4)

**1.  Exit 2D mode and frame the level**

- In the **Scene** view, select the **2D** toggle to return to 3D mode.
- In the **Hierarchy** window, double-click the **Level\[Theme\]** GameObject to frame it in view.
- On the **Scene** gizmo, select the green **Y-axis** handle to get into a top-down view

**Tip**: Select the cube at the center of the **Scene** gizmo to get into **orthographic mode**, which removes perspective and makes it easier to move things around on the ground.

**2.  Deactivate existing tanks**

- In the **Hierarchy** window, locate all tank GameObjects and deactivate them by disabling the checkbox at the top of the **Inspector** window. You don’t need them in the scene anymore.

**3.  Create the first spawn point**

- Right-click the **Hierarchy** window and select **Create Empty**.
- Rename the new GameObject “SpawnPoint1”.
- In the **Inspector** window, open the **Transform** component’s **More** (**⋮**) menu select **Reset** to set its position to **X** = **0**, **Y** = **0**, and **Z** = 0.

**4.  Position and rotate the spawn point**

- From the **Tool** overlay in the **Scene** view, select the **Transform** tool.

This tool combines the **Move**, **Rotate**, and **Scale** tools, allowing you to visualize the object’s rotation as you move it.

- **Toggle Tool Handle Rotation** dropdown located at the top of the **Scene** view and select **Local** — this will allow you to visualize which direction the spawn point is facing.
- Use the **Move** handles to place the **SpawnPoint1** GameObject in a good starting location.

**Tip**: The best position for a tank is in the corner of the scene, giving players a bit of space at the start of each battle.

- Use the **Rotate** handles to ensure the **SpawnPoint1** GameObject faces inward toward the center of the battlefield.

**Tip**: The blue handle of the **Transform** tool in the **Scene** view indicates the forward-facing direction when you’re using **Local** coordinates.

Your first spawn point out of four is now set up in the scene.

## 7. Create the remaining three spawn points

To support up to four players, you need to create four spawn points where tanks will appear at the start of the game.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/efae0225-c9ac-4e99-8b61-d14f7061b119_8.6_-_Create_the_remaining_three_spawn_points.mp4)

**1.  Duplicate the first spawn point**

- In the **Hierarchy** window, select the **SpawnPoint1** GameObject, then press **Ctrl**+**D** (macOS: **Cmd**+**D**) three times to create three duplicates.
- Rename the duplicates “SpawnPoint2”, “SpawnPoint3”, and “SpawnPoint4”.

**2.  Position and rotate the spawn points**

- Move each spawn point along the X-Z plane to spread them out across each corner of the battlefield.
- Rotate each spawn point so they face inward toward the center of the arena.

**3.  Organize the spawn points under a parent GameObject**

- Multi-select all four spawn point GameObjects (hold **Shift** or **Ctrl** (macOS: **Cmd**) and select each spawn point GameObject in the **Hierarchy** window).
- In the **Hierarchy** window, right-click the selected spawn point GameObjects and select **Create Empty Parent.**
- Rename the new parent GameObject “Spawn Points”.

**4.  Adjust the scene view for better visibility**

- Hold **Shift** and select the **center cube** of the **Scene** gizmo to switch to an angled perspective.

**5.  Add visual tags for better identification**

- Select all four spawn points in the **Hierarchy** window.
- In the **Inspector** window, open the **Select** **Icon** dropdown (the small hollow cube icon next to the GameObject’s name)  and change the icon to a colored name tag.

**Note**: Visual tags are only visible in the **Scene** view and might not appear unless your view is zoomed in. Double-click any spawn point GameObject in the **Hierarchy** window to quickly zoom in on it and see its tag.


Now your game has four nicely placed spawn points that are organized in the **Hierarchy** window and easily visible in the **Scene** view with visual tags.

## 8. Configure the Game Manager

Typically, a **Game Manager** controls a game’s overall flow. In this game, the Game Manager will control camera behavior, tank spawning, and round progression. In this step, you'll create the Game Manager and configure it with the appropriate variable references.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/5cd69e3a-5327-4327-b74b-a7d54aa2afd3_8.7_-_Configure_the_Game_Manager.mp4)

**1.  Create the Game Manager**

- In the **Hierarchy** window, right-click and select **Create Empty**, then rename it “GameManager”.
- In the **Inspector** window, open the **Transform** component’s **More** (**⋮**) menu and select **Reset**

**Note**: The exact position of the **GameManager** GameObject doesn’t affect gameplay, but resetting GameObjects like this to **X** = **0**, **Y** = **0**, and **Z** = **0** keeps the **Hierarchy** window organized and consistent.

**2.  Attach the Game Manager script**

- Select the **GameManager** GameObject in the **Hierarchy** window.
- In the **Inspector** window, select **Add Component**, search for “Game Manager” and select it.

**3.  Assign the CameraRig to the Game Manager**

- Drag the **CameraRig** GameObject from the **Hierarchy** window onto the **Game Manager (Script)** component’s **Camera Control** property box in the **Inspector** window.

**Note**: The **GameManager** script will use this reference to adjust the camera’s position and zoom at the beginning of each round.

**4.  Assign tank prefabs to the Game Manager**

- In the **Tank Prefabs** section of the **Game** **Manager** **(Script)** component, drag and drop each of your tank prefab variants from the **Project** window (**\_Tanks** > **Prefabs** > **Tanks**) into the **Tanks Prefabs** property boxes.

**Note**: You can repeat tank prefabs if needed. If you only have two tank variants, you can repeat them (for example, Tank 1, Tank 1, Tank 2, Tank 2), but if you have four tank variants, assign one to each slot.

**5.  Assign spawn points to the Game Manager**

- In the **Spawn Points** section of the **Game** **Manager** **(Script)** component, select the **Add** (**+**) button four times to create four **Spawn** **Point** properties, then drag and drop each of the four spawn points GameObjects you created in the previous step into the **Spawn** **Point** property boxes.

The **Game Manager** GameObject is now set up to control the game flow, camera behavior, and player spawning.

## 9. Set up the Player Selection screen

The Player Selection screen will allow players to choose their tanks, assign control to player one, two, or computer, and initiate the game. In this step, you'll add the **Menus** prefab and connect it to the **Game** **Manager** GameObject.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/0f030336-09f9-488f-825b-d16cb3ffcd64_8.8_-_Set_up_the_Player_Select_screen.mp4)

**1.  Add the Menus prefab**

- In the **Project** window, open the **\_Tanks** > **Prefabs** > **UI** folders, then click and drag the **Menus** prefab into the **Hierarchy** window.
- In the **Inspector** window, set the **Transform** component’s **Position Y** property to **50** or above so that it’s above and out of the way of your level.

**2.  Understand the Menus prefab’s UI structure**

- Switch back to **2D mode** in the **Scene** view (use the **2D toggle**) and double-click on the **Menus** GameObject in the **Hierarchy** window to frame it in view.
- Use the foldout (triangle) to expand the **Menus** GameObject in the **Hierarchy** window and explore its child GameObject structure.

Unlike the **TitleCanvas**, the **Menus** prefab has its own camera, which will overlay on top of the existing main camera.

**3.  Configure the Game UI Handler**

- In the **Hierarchy** window, select the **GameUICanvas** GameObject.
- In the **Inspector** window, select the **Game UI Handler** **(Script)** component’s  **Game Manager** property picker (**⊙**) and select the **GameManager** GameObject.

**Note**: The **GameUIHandler** script controls the player setup menu, allowing players to add tanks, choose controls, and start the game. It also communicates with the **Game Manager** GameObject to pass player selections.

**4.  Test the setup**

- Select the **Play** button and verify that tanks appear in four different colors and can be assigned to **P1** (player 1), **P2** (player 2), **Computer**, or **Off** by selecting them.
- Try playing the game to see how it works!

**Note**: The Title screen and Player Selection screen currently both appear on top of each other — you’ll fix that in the next step.

Your Player Selection screen is now functional, allowing players to choose their tanks and configure settings before starting the game.

## 10. Make the Player Select button work properly

The final step is to add functionality so that selecting the **Player** **Select** button hides the Title screen and activates the Player Selection screen.

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/623f4cd8-5c99-42c2-bf21-054fdcd397b0_8.9_-_Make_the_Player_Select_button_work_properly.mp4)

**1.  Set the Menus GameObject to be inactive by default**

- In the **Hierarchy** window, select the **Menus** GameObject, then in the **Inspector** window, disable the **Is** **Active** checkbox to disable it.

This ensures the Player Selection screen doesn’t appear when the game starts.

**2.  Locate the OnClick() function for the Player Select button**

- In the **Hierarchy** window, use the foldout to expand the **TitleCanvas** GameObject, then select the **PlayerSelect_Button** GameObject.
- In the **Inspector** window, use the foldout (triangle) to expand the **Button** component and locate the **On Click ()** section, where you'll define what happens when the button is selected.

**3.  Set the Menus GameObject to activate when selected**

- Under the **On Click ()** section, select the **Add to the list** (**+**) button.
- Click and drag the **Menus** GameObject from the **Hierarchy** window into the **On Click ()** property box.
- Open the **No Function** dropdown and select **GameObject** > **SetActive (bool)** and enable the checkbox.

Selecting the button should now activate the Player Selection screen.

**4.  Disable the TitleCanvas when the button is selected**

- Select the **Add** **New** **Event** (**+**) button.
- Click and drag **TitleCanvas** GameObject from the **Hierarchy** window into the **On Click ()** property box.

Open the **No Function** dropdown and select **GameObject** > **SetActive** and disable the checkbox.

Selecting the button should now deactivate the Title screen.

**5.  Test the setup**

- Enter Play mode and verify that selecting the **Player** **Select** button hides the Title screen and displays the Player Selection screen.

Your **PlayerSelect_Button** GameObject is now fully functional, allowing players to transition from the Title screen to the Player Selection screen.

## 11. Test the game loop

With all the core elements in place, it's time to test the game loop, from selecting tanks to playing rounds.

![](https://connect-mediagw.unity.com/h1/20250328/learn/images/27472166-24f5-4055-a6fe-4ba6b7b90ca9_8.10_-_Test_the_Game_Loop.png)

**1.  Playtest the game**

- Select the **Play** button and run through the game loop.
- Verify that you can select players, start the game, and play a round.

**2.  Adjust GameManager properties**

- In the **Hierarchy** window, select the **GameManager** GameObject and modify the following properties in the **Game** **Manager** component to your liking:
  - **Num Rounds To Win**: Adjust how many rounds are required to win.
  - **Start Delay**: Change the countdown before a round begins.
  - **End Delay**: Modify the pause after a round ends.

**3.  Troubleshoot any issues**

- If your mountains are being cut off in the camera, you need to move the **Main** **Camera** GameObject back and away from the ground along its local Z-axis.
- If your tanks don’t seem to be updated with your latest settings, it’s possible you made edits to the tank GameObjects rather than to the prefab.
  - In the **Hierarchy** window, select the tank GameObject you want to edit, then at the top of the **Inspector** window, open the **Overrides** dropdown and select **Apply All.**
- If there are other issues, try to figure out the answer in Unity Discussions, a search engine, or AI chatbot.

Your game loop is now almost complete, allowing players to play matches with multiple rounds.

## 12. 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 complete one, all, or none of them — it’s totally up to you. If you’re not interested in doing these challenges, mark this step as complete and proceed to the next tutorial.

## Easy: Balance your gameplay

![](https://connect-mediagw.unity.com/h1/20250328/learn/images/bfbb8347-af21-4f6f-8e92-617fd9a5f496_8.12_-_Easy_-_Balance_Your_Gameplay.png)

To make the game more fun and fair, test different tank matchups and adjust the settings for balance.

- Play rounds with different tank combinations: test AI vs. AI, player vs. player, and mixed battles.
- Try a 1v1 local multiplayer match with a friend to see how well the game handles direct competition.
- Consider the following balance factors in your game design:
  - **Speed vs. Power:** Should faster tanks have weaker weapons?
  - **Health vs. Damage:** Do some tanks feel too strong or weak?
  - **Fun Factor:** Are rounds too fast or too slow? Does every match feel exciting?

Experimenting with balance helps make the game more competitive and enjoyable for all players.

## Medium: Import new font types

![](https://connect-mediagw.unity.com/h1/20250328/learn/images/328b40fa-ee1f-465f-a6e4-3822af9dde29_8.12_-_Medium_-_Import_New_Font_Types.png)

Custom fonts can give your game a unique look. Try importing a new font for use in your title, buttons, or UI elements.

- Browse free fonts at[ Google Fonts](https://fonts.google.com/) or other open-source font sites.
- Follow[ Unity’s TextMeshPro guide](https://docs.unity3d.com/Packages/com.unity.textmeshpro@4.0/manual/FontAssetsCreator.html) to create a **TMP Font Asset**.

Apply your new font to UI elements, such as the Title screen or **Player** **Select** button.

## Expert: Add tanks of different colors to your title screen

[Video](https://connect-mediagw.unity.com/h1/20250328/videos/ff1b37f9-d9ab-4eec-9187-767878c52442_8.12_-_Expert_-_Add_tanks_of_different_colors_to_your_title_screen.mp4)

Adding a couple of tanks to your title screen will give it some color, some excitement, and also convey more information to the user what the game is all about. These title screen tanks would just be there for show and not actually be interactive. However, you don’t actually want those inactive tanks to show up in the game, so you’ll need to proceed carefully and make sure they’re disabled when the player goes to the Player Selection screen.

- Drag a couple of tanks from the **\_Tanks** > **Art** > **Models** > **Tanks** folder into the scene, then position them nicely around the title text.
- Since the color of the tanks is set with code through the **GameUIHandler** and **GameManager** scripts, you’ll need to manually create and assign new materials to these show tanks.
  - If you expand the **Tank\_\[Type\]\_Model** GameObject in the **Hierarchy** window, browse through the various tank parts and look for any **Mesh** **Renderer** component that uses the **TankColor** material. This is the material you’ll need to swap out for a new material of a different color if you want.
- To make the tanks disappear when the **Player** **Select** button is selected, create a new empty parent GameObject for your tanks and use the same technique you did earlier to set that GameObject as inactive when the button is selected.

**Note**: You might need to do some experimenting with the position of the tanks, since the camera will zoom in to a new position after you enter Play mode.

## 13. Optional: Review the GameManager script  _(Optional)_

This step is entirely optional, but if you’re curious to understand how the **GameManager** script works, you can find it in the **\_Tanks** > **Scripts** > **Managers** folder and open it in an IDE or text editor. The code is thoroughly commented, which helps as you read through it.

Below are a few aspects of the script that you might find particularly interesting:

## 1\. Handling the game loop

The **GameLoop** function controls the different phases of the game: round starting, round playing, and round ending. It ensures the game continues until a player wins.

```csharp
// This is called from start and will run each phase of the game one after another.
private IEnumerator GameLoop ()
{
    // Start off by running the 'RoundStarting' coroutine but don't return until it's finished.
    yield return StartCoroutine (RoundStarting ());

    // Once the 'RoundStarting' coroutine is finished, run the 'RoundPlaying' coroutine but don't return until it's finished.
    yield return StartCoroutine (RoundPlaying());

    // Once execution has returned here, run the 'RoundEnding' coroutine, again don't return until it's finished.
    yield return StartCoroutine (RoundEnding());

    // This code is not run until 'RoundEnding' has finished.  At which point, check if a game winner has been found.
    if (m_GameWinner != null)
    {
        // If there is a game winner, restart the level.
        SceneManager.LoadScene (0);
    }
    else
    {
        // If there isn't a winner yet, restart this coroutine so the loop continues.
        // Note that this coroutine doesn't yield.  This means that the current version of the GameLoop will end.
        StartCoroutine (GameLoop ());
    }
}
```

- Runs **RoundStarting()**, then when that’s finished it runs **RoundPlaying()**, then when that’s finished, it runs **RoundEnding()**.

## 2\. Spawning and setting up tanks

The **SpawnAllTanks** function creates and configures each player’s tank, ensuring proper placement, color assignment, and control settings.

```csharp
private void SpawnAllTanks()
{
    // For all the tanks...
    for (int i = 0; i < m_PlayerCount; i++)
    {
        var playerData = m_TankData[i];
        
        // ... create them, set their player number and references needed for control.
        m_SpawnPoints[i].m_Instance =
            Instantiate(playerData.UsedPrefab, m_SpawnPoints[i].m_SpawnPoint.position, m_SpawnPoints[i].m_SpawnPoint.rotation) as GameObject;
        
        m_SpawnPoints[i].m_PlayerNumber = i + 1;
        m_SpawnPoints[i].ControlIndex = playerData.ControlIndex;
        m_SpawnPoints[i].m_PlayerColor = playerData.TankColor;
        m_SpawnPoints[i].m_ComputerControlled = playerData.IsComputer;
    }
...
}
```

- Spawns each tank at the correct location.
- Assigns colors, control settings, and player numbers.
- Ensures the AI logic is properly enabled or disabled.

## 3\. Determining round and game winners

The **GetRoundWinner** and **GetGameWinner** functions determine who wins each round and the overall game.

```csharp
// This function is to find out if there is a winner of the round.
// This function is called with the assumption that 1 or fewer tanks are currently active.
private TankManager GetRoundWinner()
{
    // Go through all the tanks...
    for (int i = 0; i < m_PlayerCount; i++)
    {
        // ... and if one of them is active, it is the winner so return it.
        if (m_SpawnPoints[i].m_Instance.activeSelf)
            return m_SpawnPoints[i];
    }

    // If none of the tanks are active it is a draw so return null.
    return null;
}


// This function is to find out if there is a winner of the game.
private TankManager GetGameWinner()
{
    // Go through all the tanks...
    for (int i = 0; i < m_PlayerCount; i++)
    {
        // ... and if one of them has enough rounds to win the game, return it.
        if (m_SpawnPoints[i].m_Wins == m_NumRoundsToWin)
            return m_SpawnPoints[i];
    }

    // If no tanks have enough rounds to win, return null.
    return null;
}
```

- **Round winner**: The last tank standing wins the round.
- **Game winner**: The first player to reach the required number of wins becomes the champion.

## 14. Next steps

You’ve created a Title screen, set up a Game Manager, and added a Player Selection screen.

In the next tutorial, you’ll get some ideas for how to further personalize and improve your project.
