---
title: "Lab 3 - Player Control"
content_type: tutorial
url: "https://learn.unity.com/tutorial/lab-3-player-control?language=en"
language: en
difficulty: beginner
duration_minutes: 60
unity_version:
  - "6.0"
  - "6.3"
supported_unity_versions:
  - name: "6.0"
    url: "https://learn.unity.com/tutorial/lab-3-player-control.md?language=en&version=6.0"
  - name: "6.3"
    url: "https://learn.unity.com/tutorial/lab-3-player-control.md?language=en&version=6.3"
  - name: "2022.3"
    url: "https://learn.unity.com/tutorial/lab-3-player-control.md?language=en&version=2022.3"
  - name: "2021.3"
    url: "https://learn.unity.com/tutorial/lab-3-player-control.md?language=en&version=2021.3"
last_updated: "2026-08-04T14:21:48.000Z"
---

# Lab 3 - Player Control

Program basic player movement with constraints by researching, testing, and refining your own C# solution.


**Overview:**

In this lesson, you program the player’s basic movement, including the code that limits that movement. Since there are a lot of different ways a player can move, depending on the type of project you’re working on, you will not be given step-by-step instructions on how to do it. In order to do this, you will need to do research, reference other code, and problem-solve when things go wrong.

**Project Outcome:**

The player will be able to move around based on user input, but _not_ be able to move where they shouldn’t.

## Configure project settings for the Input System

The code you’ll add in the following steps uses the **Input System** to handle player controls. To ensure the code works correctly, verify that your project is configured to allow both input systems to run side by side.

Follow the video and instructions below.

[Video](https://connect-mediagw.unity.com/h1/20250903/videos/89a8fcf6-41e6-4a5c-aae5-49a3825881cf_ChangeInputSystem.mp4)

**Instructions**

**1.** Open the **Player Settings**:

- From the main menu, select **Edit** > **Project Settings,** then select the **Player** category from the leftmost menu.

**2.** Enable support for both input systems:

- Find the **Configuration** section.
- From the **Active Input Handling** dropdown, select **Both**.
- Select the **Apply** button to confirm the change.

The Unity Editor will automatically restart to apply this setting. After restarting, your project will be correctly configured to handle input from both the original Input Manager and the newer Input System.

## Create PlayerController and plan your code

Regardless of what type of movement your player has, it’ll definitely need a PlayerController script

[Video](https://connect-mediagw.unity.com/h1/20241210/videos/d4920bfc-0d8b-4cee-8d97-dc362647f530_CWC_Lab3.S1_U6.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/221ad21d-a180-4c24-9af4-f2e2146dab3a/versions%5B_key==%22hZGUzJc5TfSRjIpWBB87Rh%22%5D.sections%5B_key==%226mPVEs2A9KDZvKF7TiJJbc%22%5D.body%5B_key==%226mPVEs2A9KDZvKF7TiJJfm%22%5D.subtitles/CWC_Lab3.S1_U6.mp4_20260505_044805.srt))

1. Select your Player and add a **Rigidbody** component (with or without gravity enabled)
2. In your Assets folder, create a new “Scripts” folder
3. Inside the new “Scripts” folder, create a new “PlayerController” script
4. **Attach** it to the player, then **open** it
5. Determine what type of programming will be required for your Player

By the end of this step, you should have a new Script open and a solid plan for what will go in it.

## Basic movement from user input

The first thing we’ll program is the player’s very basic movement based on user input

[Video](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/221ad21d-a180-4c24-9af4-f2e2146dab3a/versions%5B_key==%22hZGUzJc5TfSRjIpWBB87Rh%22%5D.sections%5B_key==%226mPVEs2A9KDZvKF7TiJKF9%22%5D.body%5B_key==%226mPVEs2A9KDZvKF7TiJKJJ%22%5D.overviewVideo/Unit%203%20-%20Lab%203%20-%20Step%202%20-%20Basic%20movement%20from%20user%20input%20-%20FINAL%20RENDER_20260603_152048.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/221ad21d-a180-4c24-9af4-f2e2146dab3a/versions%5B_key==%22hZGUzJc5TfSRjIpWBB87Rh%22%5D.sections%5B_key==%226mPVEs2A9KDZvKF7TiJKF9%22%5D.body%5B_key==%226mPVEs2A9KDZvKF7TiJKJJ%22%5D.subtitles/Unit%203%20-%20Lab%203%20-%20Step%202%20-%20Basic%20movement%20from%20user%20input%20-%20FINAL%20RENDER_20260603_152048_20260623_013826.vtt))

1. Declare a new **_private float speed_** variable
2. If using physics, declare a new **_Rigidbody playerRb variable_** for it and initialize it in Start()
3. If using arrow keys, declare new **_verticalInput_** and/or **_horizontalInput_** variables
4. If basing your movement off a key press, create the **if-statement** to test for the **input action**
5. Use either the **_Translate_** method or **_AddForce_** method (if using physics) to move your character

By the end of this step, the player should be able to move the way that you want based on user input.

## Constrain the Player’s movement

No matter what kind of movement your player has, it needs to be limited for gameplay.

[Video](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/221ad21d-a180-4c24-9af4-f2e2146dab3a/versions%5B_key==%22hZGUzJc5TfSRjIpWBB87Rh%22%5D.sections%5B_key==%226mPVEs2A9KDZvKF7TiJL5A%22%5D.body%5B_key==%226mPVEs2A9KDZvKF7TiJL9K%22%5D.overviewVideo/Unit%203%20-%20Lab%203%20-%20Step%204%20-%20Code%20Cleanup%20and%20Export%20Backup%20-%20FINAL%20NEW%20%28NO%20VO%29_20260625_192952.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/221ad21d-a180-4c24-9af4-f2e2146dab3a/versions%5B_key==%22hZGUzJc5TfSRjIpWBB87Rh%22%5D.sections%5B_key==%226mPVEs2A9KDZvKF7TiJL5A%22%5D.body%5B_key==%226mPVEs2A9KDZvKF7TiJL9K%22%5D.subtitles/Unit%203%20-%20Lab%203%20-%20Step%203%20-%20Constain%20the%20players%20movement%20%28NO%20VO%29%20-%20FINAL%20RENDER_20260603_152234_20260623_013835.vtt))

1. If your player is colliding with objects they shouldn’t (including the ground), check the “**Is trigger**” box in the Collider component.
2. If your player’s position or rotation should be constrained, expand the **constraints** in the Rigidbody component and constrain certain axes.
3. If your **Player** GameObject can go **off the screen**, write an **if-statement** checking and resetting the position and velocity.
4. If the Player can double-jump or fly off-screen, create a **boolean variable** that limits the user’s ability to do so.
5. If your player should be constrained by physical barriers along the outside of the play area, create more primitive **Planes** or **Cubes** and scale them to form walls .

By the end of this step, the player’s movement should be constrained in such a way that makes your game playable.

## Code Cleanup and Export Backup

Now that we have the basic functionality working, let’s clean up our code and make a backup.

[Video](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/221ad21d-a180-4c24-9af4-f2e2146dab3a/versions%5B_key==%22hZGUzJc5TfSRjIpWBB87Rh%22%5D.sections%5B_key==%226mPVEs2A9KDZvKF7TiJLt6%22%5D.body%5B_key==%226mPVEs2A9KDZvKF7TiJLxG%22%5D.overviewVideo/Unit%203%20-%20Lab%203%20-%20Step%205%20-%20Code%20Cleanup%20and%20Export%20Backup%20-%20FINAL%20NEW%20%28NO%20VO%29_20260625_204210.mp4) ([Transcript (en)](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/221ad21d-a180-4c24-9af4-f2e2146dab3a/versions%5B_key==%22hZGUzJc5TfSRjIpWBB87Rh%22%5D.sections%5B_key==%226mPVEs2A9KDZvKF7TiJLt6%22%5D.body%5B_key==%226mPVEs2A9KDZvKF7TiJLxG%22%5D.subtitles/Unit%203%20-%20Lab%203%20-%20Step%205%20-%20Code%20Cleanup%20and%20Export%20Backup%20-%20FINAL%20NEW%20%28NO%20VO%29_20260625_204327.vtt))

1. Create new **Empty** game objects and nest objects inside them to **organize** your hierarchy
2. Clean up your Update methods by moving the blocks of code into new void functions (e.g. “MovePlayer()” or “ConstrainPlayerPosition()”)
3. Add comments to make your code more readable
4. **Test** to make sure everything still works, then **save** your scene
5. Right-click on your _Assets folder > **Export Package**_ then save a new version in your **Backups** folder

![](https://storage.googleapis.com/learn-platform-bucket-production/tutorial/221ad21d-a180-4c24-9af4-f2e2146dab3a/versions%5B_key==%22hZGUzJc5TfSRjIpWBB87Rh%22%5D.sections%5B_key==%226mPVEs2A9KDZvKF7TiJLt6%22%5D.body%5B_key==%22a5525b430929%22%5D.image/Untitled%206_20260603_152734.png)

By the end of this step, your code should be commented, organized, and backed up.

## Lesson Recap

## New progress:

- Player can move based on user input
- Player movement is constrained to suit the requirements of the game

## New concepts & skills:

- Program in C# independently
- Troubleshoot issues independently
