A simple and beginner-friendly Player Controller for Unity using the New Input System.
This controller includes smooth movement, mouse look, jumping, gravity handling, and camera rotation using CharacterController.
Perfect for:
- FPS Games
- Third-Person Prototypes
- Horror Games
- Sandbox Projects
- Beginner Unity Projects
✔ WASD Movement
✔ Mouse Look Rotation
✔ Jumping System
✔ Gravity Handling
✔ Camera Rotation Clamp
✔ CharacterController Support
✔ Cursor Lock for Gameplay Feel
✔ Beginner-Friendly Code Structure
- Unity 2021 or newer
- Unity Input System Package
- CharacterController Component
Open:
Window → Package Manager
Search for:
Input System
Install the package.
Open:
Edit → Project Settings → Player
Under:
Active Input Handling
Select:
- Both or
- Input System Package (New)
Unity will ask to restart the editor.
Restart Unity.
Create an empty GameObject and rename it:
Player
Add the following components:
- CharacterController
- PlayerController Script
- PlayerInput
Create a Camera as a child of the Player object.
Hierarchy Example:
Player
└── Main Camera
Assign the Camera Transform to:
cameraTransforminside the PlayerController Inspector.
Unity already provides default actions for:
- Move
- Look
- Jump
through the Starter Assets or Default Input Actions setup.
You can use those instead of manually creating new actions.
In the Inspector, locate the:
Player Input
component.
Drag your existing Input Actions asset into the:
Actions
field.
Set:
Default Map = Player
Set:
Behavior = Invoke Unity Events
Open:
Events → Player
You will see the default actions:
- Move
- Look
- Jump
- Click the
+button - Drag the Player GameObject into the object field
- Select:
PlayerController → OnMove
- Click the
+button - Drag the Player GameObject into the object field
- Select:
PlayerController → OnLook
- Click the
+button - Drag the Player GameObject into the object field
- Select:
PlayerController → OnJump
✔ CharacterController attached
✔ PlayerController script attached
✔ PlayerInput component attached
✔ Input Actions asset assigned
✔ Default Action Map set to Player
✔ Camera assigned to cameraTransform
✔ Move event connected
✔ Look event connected
✔ Jump event connected
| Action | Key |
|---|---|
| Move | WASD |
| Look | Mouse |
| Jump | Space |
The script uses:
CharacterController.Move()for smooth movement based on player direction.
Jump force is calculated using the physics formula:
v = √(jumpHeight × -2 × gravity)
This creates a cleaner and more realistic jump.
- Horizontal mouse movement rotates the player
- Vertical mouse movement rotates the camera
- Camera rotation is clamped to prevent over-rotation
CharacterController.Move(move * moveSpeed * Time.deltaTime);- Sprint System
- Crouch System
- Head Bobbing
- Footstep Sounds
- Interaction System
- Stamina System
Free to use for personal and commercial projects.
Created by Stix&Kno