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 C...
[RequireComponent(typeof(CharacterController))]
public class PlayerController3D : MonoBehaviour
{
[SerializeField] private float walkSpeed = 6f;
[SerializeField] private float sprintSpeed = 10f;
[SerializeField] private float jumpHeight = 1.5f;First Person Camera
First person mouse look camera with sensitivity, vertical clamp, and cursor lock. Plug into any F...
public class FirstPersonCamera : MonoBehaviour
{
[SerializeField] private float mouseSensitivity = 2f;
[SerializeField] private float minVerticalAngle = -90f;
[SerializeField] private float maxVerticalAngle = 90f;Weapon System
ScriptableObject-driven weapon system with melee and ranged attacks, cooldowns, ammo, and damage ...
public class WeaponSystem : MonoBehaviour
{
[SerializeField] private WeaponData currentWeapon;
public void Attack()
public void EquipWeapon(WeaponData weapon)Projectile System
Configurable projectile with speed, damage, lifetime, and optional homing. Integrates with Object...
public class Projectile : MonoBehaviour, IPoolable
{
[SerializeField] private float speed = 20f;
[SerializeField] private float damage = 10f;
[SerializeField] private float lifetime = 5f;
private void OnTriggerEnter(Collider other)Health System
Reusable health component with damage, healing, invincibility frames, and events.
public class HealthSystem : MonoBehaviour
{
[SerializeField] private float maxHealth = 100f;
public float HealthPercent => currentHealth / maxHealth;
public void TakeDamage(float damage)
public void Heal(float amount)Camera Shake
Perlin noise camera shake with magnitude, frequency, and duration. Trigger from explosions, impac...
public class CameraShake : MonoBehaviour
{
public static CameraShake Instance { get; private set; }
[SerializeField] private float defaultMagnitude = 0.15f;
[SerializeField] private float frequency = 25f;
public void Shake(float duration, float magnitude)Enemy Chase AI
Enemy AI that detects the player within radius, chases with line-of-sight, and returns to patrol ...
public class EnemyChaseAI : MonoBehaviour
{
[SerializeField] private float detectionRadius = 10f;
[SerializeField] private float fieldOfView = 120f;
[SerializeField] private float chaseSpeed = 5f;Wave Spawner
Wave-based enemy spawner with configurable wave definitions, spawn points, delays, and wave compl...
public class WaveSpawner : MonoBehaviour
{
[System.Serializable]
public class Wave
{
public string waveName = "Wave";
public EnemySpawn[] enemies;
}
private IEnumerator SpawnWave()Health Bar UI
World-space or screen-space health bar with smooth fill, color gradient, and damage flash. Attach...
public class HealthBarUI : MonoBehaviour
{
[SerializeField] private float smoothSpeed = 5f;
[SerializeField] private Gradient colorGradient;
public void SetHealth(float current, float max)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.