Build a First-Person Shooter
Movement, camera, weapons, projectiles, enemy AI, and screen effects for an FPS prototype.
Learning Path
Follow these steps in order to build your First-Person Shooter.
Included Scripts
3D Player Controller
First/third person character controller with smooth movement, jumping, and slope handling using CharacterController.
- Camera-relative movement so the player moves where the camera faces
- Sprint toggle with Left Shift and separate walk/sprint speeds
- Smooth rotation via LerpAngle for natural turning
First Person Camera
First person mouse look camera with sensitivity, vertical clamp, and cursor lock. Plug into any FPS or exploration game.
- Smooth mouse look with SmoothDamp for configurable input smoothing
- Vertical angle clamping to prevent over-rotation
- Automatic cursor lock on start with Escape toggle
Weapon System
ScriptableObject-driven weapon system with melee and ranged attacks, cooldowns, ammo, and damage calculation.
- ScriptableObject weapon definitions created via Assets menu
- Supports both melee (range + angle cone) and ranged (projectile) attack types
- Attack rate cooldown and ammo management with reload
Projectile System
Configurable projectile with speed, damage, lifetime, and optional homing. Integrates with Object Pool for zero-alloc shooting.
- Configurable speed, damage, and lifetime per projectile
- Optional homing behavior with adjustable strength and range
- LayerMask-based hit filtering for selective collision
Health System
Reusable health component with damage, healing, invincibility frames, and events.
- Damage and healing with clamped health values
- Invincibility frames with configurable duration after taking damage
- UnityEvent callbacks for health changed, damaged, healed, and death
Camera Shake
Perlin noise camera shake with magnitude, frequency, and duration. Trigger from explosions, impacts, or any event.
- Perlin noise-based shake for smooth, organic camera movement
- Configurable duration, magnitude, and frequency parameters
- Automatic linear decay so shake fades out naturally
Enemy Chase AI
Enemy AI that detects the player within radius, chases with line-of-sight, and returns to patrol when player escapes.
- Detection radius with configurable field of view angle
- Line-of-sight check using raycasts against obstacle layers
- Chase behavior with smooth rotation towards the player
Wave Spawner
Wave-based enemy spawner with configurable wave definitions, spawn points, delays, and wave completion callbacks.
- Configurable wave definitions with multiple enemy types per wave
- Multiple spawn points with automatic round-robin distribution
- Adjustable delay between spawns and between waves
Health Bar UI
World-space or screen-space health bar with smooth fill, color gradient, and damage flash. Attach to enemies or use as HUD.
- Smooth fill animation with Lerp for satisfying health changes
- Color gradient that shifts from green to yellow to red automatically
- Damage flash effect on the background image when health decreases
Related Systems
FPS Foundation Kit
First-person shooter foundation with movement, camera, weapons, projectiles, health, and screen shake.
Enemy AI Kit
Complete enemy AI pipeline: state machine, patrol, chase, health, and wave spawning with debug visualization.