A simple and reusable 4-wheel car controller for Unity written in C#. This script allows any car with separate wheel meshes and WheelColliders to move, steer, and brake using keyboard input.
The controller is designed to be lightweight, easy to understand, and easy to integrate into any Unity car project.
- Simple 4-wheel vehicle controller
- Uses Unity WheelColliders
- Works with separate tire meshes
- Smooth steering and acceleration
- Brake system using Space key
- Automatic wheel mesh synchronization with colliders
- Easy to attach to any car model
| Key | Action |
|---|---|
| ↑ Arrow | Move Forward |
| ↓ Arrow | Move Backward |
| ← Arrow | Steer Left |
| → Arrow | Steer Right |
| Space | Brake |
- Unity 3D
- A car model with 4 separate wheel meshes
- WheelCollider for each wheel
-
Import your car model into Unity.
-
Create 4 WheelColliders:
- Front Left
- Front Right
- Rear Left
- Rear Right
-
Ensure each wheel has a separate mesh object.
-
Attach the
CarController.csscript to the main car GameObject. -
Assign the following in the Inspector:
- WheelColliders
- Wheel mesh transforms
-
Adjust settings like:
Motor PowerBraking PowerMax Steering Angle
The controller handles:
- User Input
- Motor Torque
- Steering
- Braking
- Wheel Mesh Updates
It synchronizes WheelCollider physics with the visual wheel meshes to keep them aligned during movement.
The script performs these main tasks every physics frame:
- Reads player input (arrow keys + brake)
- Applies motor torque to the front wheels
- Applies steering angle
- Applies brake torque
- Updates the wheel mesh position and rotation
You can easily modify:
- Top speed (via motorPower)
- Turning sensitivity (via maxSteeringAngle)
- Brake strength (via brakingPower)
Free to use for learning and personal projects.
Created by RehmanLn1