PROJECT NIGHTFALL

Modular architecture for a 2-4 player co-op zombie survival horror game with advanced AI, survival mechanics, and dynamic environments

Unity/C# Unreal Engine 5 2-4 Players Co-op

Game Overview

Core Concept

A survival horror experience where players must work together to scavenge resources, fortify positions, and survive against increasingly dangerous zombie hordes in a dynamically changing environment.

  • Procedural world generation with hand-crafted points of interest
  • Real-time cooperative gameplay with shared objectives
  • Dynamic difficulty scaling based on player count and performance

Technical Targets

Engine

Unity 2022+ or UE5

Networking

Mirror/Netcode or UE Net

Platforms

Windows (PC)

Performance

60fps @ 1080p (Mid-range)

Mod Support

Custom maps Weapon skins Zombie types Game modes

Core Systems Architecture

1

Advanced AI Zombie System

Intelligent zombie behaviors with different types and dynamic horde mechanics

Zombie Types

Standard

Slow, numerous, basic detection

Runner

Fast, fragile, aggressive

Mutated

Tanky, special attacks

Stealth

Avoids light, ambushes

Detection Systems

  • Vision cones with distance and light level modifiers
  • Sound propagation system based on material and volume
  • Blood scent tracking for injured players

Code Structure

// Base Zombie AI Controller (Abstract) public abstract class ZombieAI : MonoBehaviour { // Core properties public ZombieType type; public float health; public float moveSpeed; public float detectionRange; // State machine protected enum AIState { Idle, Patrol, Chase, Attack, Dead } protected AIState currentState; // Navigation protected NavMeshAgent navAgent; protected Vector3 lastKnownPlayerPosition; // Detection public virtual void CheckForPlayers() { // Base detection logic using sphere casts } // Movement public abstract void CalculateMovement(); // Attack public abstract void PerformAttack(); // Damage public virtual void TakeDamage(float amount) { health -= amount; if(health <= 0) Die(); } protected abstract void Die(); } // Runner Zombie Implementation public class RunnerZombie : ZombieAI { [Header("Runner Specific")] public float sprintSpeed; public float sprintDuration; public float sprintCooldown; private bool canSprint = true; public override void CalculateMovement() { // Special sprint behavior implementation } public override void PerformAttack() { // Fast swipe attacks } protected override void Die() { // Runner-specific death animation/effects } }
2

Survival Mechanics

Systems for inventory, crafting, and player status management

Inventory System

  • Grid-based with weight/slot limits
  • Drag-and-drop functionality
  • Quick-access hotbar
  • Equipment slots (weapons, armor)

Crafting System

  • Recipe discovery system
  • Workstation requirements
  • Skill-based success chance
  • Multiplayer cooperative crafting

Player Status

  • Health with limb-specific damage
  • Stamina for running/melee
  • Infection progression system
  • Needs (hunger, thirst, sleep)

Code Structure

// Inventory System Core public class InventorySystem : NetworkBehaviour { [SyncVar] public int maxSlots = 20; [SyncVar] public float maxWeight = 50f; public SyncList items = new SyncList(); public Item[] equippedItems; [Command] public void CmdMoveItem(int fromIndex, int toIndex) { // Validate and move item } public bool CanAddItem(Item item) { // Check weight and slot availability } [ClientRpc] public void RpcUpdateInventory() { // Refresh UI for all clients } } // Crafting Recipe Definition [CreateAssetMenu(fileName = "NewRecipe", menuName = "Survival/Recipe")] public class CraftingRecipe : ScriptableObject { public string recipeName; public Item result; public int resultAmount = 1; public List requirements; public float craftTime = 3f; public bool requiresWorkbench; [System.Serializable] public class ItemRequirement { public Item item; public int amount; } } // Player Status Manager public class PlayerStatus : NetworkBehaviour { [SyncVar] public float health = 100f; [SyncVar] public float maxHealth = 100f; [SyncVar] public float stamina = 100f; [SyncVar] public float infectionLevel = 0f; public Dictionary limbHealth = new Dictionary(); public void TakeDamage(float amount, LimbType limb, bool isBite = false) { // Handle damage with limb effects if(isBite) infectionLevel += 10f; } [Command] public void CmdUseItem(Item item) { // Apply item effects to status } }
3

Environment & Game World

Dynamic world systems that affect gameplay and atmosphere

World Generation

  • Procedural City Layout

    Roads, districts, and key landmarks placed algorithmically

  • Handcrafted Buildings

    Pre-designed interiors with randomization elements

  • Resource Distribution

    Logical item placement based on location type

Dynamic Systems

  • Day/Night Cycle

    24-minute real-time cycle with gameplay effects

  • Weather System

    Rain, fog, storms that affect visibility and sound

  • Zombie Migration

    Hordes move based on noise and player activity

Code Structure

// World Generator public class WorldGenerator : MonoBehaviour { public GameObject[] districtPrefabs; public GameObject[] landmarkPrefabs; public int worldSize = 10; // in km private void GenerateWorld() { // Create road network GenerateRoadSystem(); // Divide into districts for(int i = 0; i < districtCount; i++) { GameObject district = Instantiate(districtPrefabs[Random.Range(0, districtPrefabs.Length)]); district.transform.position = CalculateDistrictPosition(i); // Populate with buildings PopulateDistrict(district); } // Place landmarks PlaceLandmarks(); } private void PopulateDistrict(GameObject district) { // Procedurally fill with buildings, loot, etc. } } // Day/Night Cycle Controller public class TimeOfDay : NetworkBehaviour { [SyncVar] public float currentTime; // 0-1 representing 24 hours public float timeScale = 60f; // 1 real minute = 1 game hour public Light sun; public Light moon; private void Update() { if(isServer) { currentTime += Time.deltaTime / (24f * 60f / timeScale); if(currentTime >= 1f) currentTime = 0f; } UpdateLighting(); } private void UpdateLighting() { // Adjust sun/moon positions and intensities } public bool IsNightTime() { return currentTime > 0.75f || currentTime < 0.25f; } } // Dynamic Zombie Spawner public class ZombieSpawnManager : NetworkBehaviour { public GameObject[] zombiePrefabs; public int maxZombies = 100; public float spawnCheckInterval = 5f; private List activeSpawnPoints = new List(); [ServerCallback] private void Start() { InvokeRepeating(nameof(CheckSpawns), spawnCheckInterval, spawnCheckInterval); } private void CheckSpawns() { // Get all players var players = FindObjectsOfType(); foreach(var player in players) { // Find nearby spawn points var nearbyPoints = GetSpawnPointsInRadius(player.transform.position, 50f); // Spawn zombies based on time, weather, and player count int zombiesToSpawn = CalculateZombiesToSpawn(player.transform.position); for(int i = 0; i < zombiesToSpawn; i++) { SpawnZombie(nearbyPoints[Random.Range(0, nearbyPoints.Count)]); } } } private void SpawnZombie(Transform spawnPoint) { // Network instantiation with type variation } }
4

Multiplayer Co-op Logic

Systems enabling cooperative gameplay and communication

Network Architecture

  • Dedicated server or listen server
  • State synchronization
  • Lag compensation
  • Bandwidth optimization

Co-op Features

  • Shared objectives
  • Revive/healing system
  • Resource sharing
  • Base building collaboration

Communication

  • Proximity voice chat
  • Text chat system
  • Ping/waypoint system
  • Emote/gesture system

Code Structure

// Network Manager Extended public class CustomNetworkManager : NetworkManager { public override void OnServerAddPlayer(NetworkConnection conn) { base.OnServerAddPlayer(conn); // Initialize player data var player = conn.identity.GetComponent(); player.SetDisplayName($"Player {numPlayers}"); // Sync world state to new player WorldState.Instance.TargetSyncWorldState(conn); } public override void OnServerDisconnect(NetworkConnection conn) { // Handle player disconnect (save, cleanup, etc.) base.OnServerDisconnect(conn); } } // Player Controller with Co-op Features public class PlayerController : NetworkBehaviour { [SyncVar] public string displayName; [SyncVar] public Color playerColor; public PlayerStatus status; public InventorySystem inventory; [Command] public void CmdRevivePlayer(NetworkIdentity targetPlayer) { if(Vector3.Distance(transform.position, targetPlayer.transform.position) > 3f) return; var targetStatus = targetPlayer.GetComponent(); if(targetStatus.health <= 0) { targetStatus.health = targetStatus.maxHealth * 0.3f; targetStatus.RpcRevived(); } } [Command] public void CmdDropItem(int slotIndex) { // Validate and drop item from inventory } [Command] public void CmdSendChatMessage(string message) { RpcReceiveChatMessage(displayName, message); } [ClientRpc] public void RpcReceiveChatMessage(string sender, string message) { ChatUI.Instance.AddMessage(sender, message); } } // Voice Chat System public class VoiceChatSystem : NetworkBehaviour { public float maxHearDistance = 15f; public AudioSource voiceSource; private void Update() { if(!isLocalPlayer) return; if(Input.GetKey(KeyCode.V)) { CmdStartVoiceTransmission(); } else { CmdStopVoiceTransmission(); } } [Command] private void CmdStartVoiceTransmission() { RpcStartVoiceTransmission(); } [ClientRpc] private void RpcStartVoiceTransmission() { if(Vector3.Distance(transform.position, PlayerManager.LocalPlayer.transform.position) <= maxHearDistance) { voiceSource.gameObject.SetActive(true); } } // Similar for stop transmission }
5

Scary Atmosphere Design

Systems to create tension and horror elements

Audio Systems

  • Dynamic Music

    Layers adjust based on threat level

  • 3D Sound Propagation

    Realistic occlusion and materials

  • Ambient Sounds

    Randomized environmental noises

  • Zombie Vocalizations

    Unique sounds per zombie type

Visual Systems

  • Dynamic Lighting

    Flickering lights, flashlight effects

  • Post-processing

    Vignette, color grading, film grain

  • Particle Effects

    Dust, fog, blood splatters

  • Camera Effects

    Shake, breathing, injury effects

Code Structure

// Horror Event System public class HorrorEventManager : MonoBehaviour { public static HorrorEventManager Instance; public HorrorEvent[] events; public float minEventDelay = 120f; public float maxEventDelay = 300f; private float nextEventTime; private void Awake() { Instance = this; CalculateNextEventTime(); } private void Update() { if(Time.time > nextEventTime) { TriggerRandomEvent(); CalculateNextEventTime(); } } private void TriggerRandomEvent() { // Filter events by current game state var possibleEvents = events.Where(e => e.CanTrigger()).ToArray(); if(possibleEvents.Length == 0) return; var selectedEvent = possibleEvents[Random.Range(0, possibleEvents.Length)]; selectedEvent.Trigger(); } private void CalculateNextEventTime() { nextEventTime = Time.time + Random.Range(minEventDelay, maxEventDelay); } } // Flashlight Controller public class FlashlightController : MonoBehaviour { public Light flashlight; public AudioSource toggleSound; public float batteryLife = 300f; public float currentBattery; private bool isOn; private void Start() { currentBattery = batteryLife; } private void Update() { if(Input.GetButtonDown("Flashlight")) { ToggleFlashlight(); } if(isOn) { currentBattery -= Time.deltaTime; if(currentBattery <= 0f) { currentBattery = 0f; SetFlashlight(false); } // Random flicker when battery is low if(currentBattery < batteryLife * 0.2f && Random.value < 0.01f) { StartCoroutine(Flicker()); } } } private void ToggleFlashlight() { SetFlashlight(!isOn); } private void SetFlashlight(bool state) { isOn = state; flashlight.enabled = state; if(state) toggleSound.Play(); } private IEnumerator Flicker() { flashlight.enabled = false; yield return new WaitForSeconds(Random.Range(0.05f, 0.2f)); if(isOn) flashlight.enabled = true; } } // Jump Scare Trigger public class JumpScareTrigger : MonoBehaviour { public GameObject jumpScarePrefab; public AudioClip scareSound; public float cooldown = 60f; private bool triggered; private float lastTriggerTime; private void OnTriggerEnter(Collider other) { if(!triggered && Time.time > lastTriggerTime + cooldown && other.CompareTag("Player")) { TriggerJumpScare(other.transform); } } private void TriggerJumpScare(Transform player) { triggered = true; lastTriggerTime = Time.time; // Instantiate scare effect in front of player var scare = Instantiate(jumpScarePrefab, player.position + player.forward * 2f, Quaternion.LookRotation(player.forward)); // Play sound AudioSource.PlayClipAtPoint(scareSound, player.position); // Destroy after effect Destroy(scare, 2f); // Reset after cooldown Invoke(nameof(ResetTrigger), cooldown); } private void ResetTrigger() { triggered = false; } }
6

UI/UX and Controls

Player interface and input systems

User Interface

  • Minimalist HUD

    Only essential info to maintain immersion

  • Context-Sensitive UI

    Only shows when needed

  • Diegetic Elements

    In-world UI where possible

  • Accessibility Options

    Colorblind modes, subtitles

Control Systems

  • Input Rebinding

    Full keyboard/controller customization

  • Dual Input Support

    Seamless keyboard/mouse + controller

  • Contextual Actions

    Single button for multiple interactions

  • Camera Options

    FOV adjustment, first/third person toggle

Code Structure

// Input Manager public class InputManager : MonoBehaviour { public static InputManager Instance; public InputActionAsset inputActions; private InputActionMap gameplayActionMap; public event Action OnInteract; public event Action OnCameraToggle; private void Awake() { Instance = this; gameplayActionMap = inputActions.FindActionMap("Gameplay"); // Setup callbacks gameplayActionMap["Interact"].performed += ctx => OnInteract?.Invoke(ctx); gameplayActionMap["ToggleCamera"].started += ctx => OnCameraToggle?.Invoke(ctx.ReadValue()); } public void EnableGameplayInput(bool enable) { if(enable) gameplayActionMap.Enable(); else gameplayActionMap.Disable(); } public void RebindAction(string actionName, InputBinding newBinding, int bindingIndex = 0) { var action = inputActions.FindAction(actionName); if(action != null) { action.ApplyBindingOverride(bindingIndex, newBinding); SaveBindings(); } } private void SaveBindings() { PlayerPrefs.SetString("InputBindings", inputActions.SaveBindingOverridesAsJson()); } } // Player HUD Controller public class PlayerHUD : MonoBehaviour { public Slider healthSlider; public Slider staminaSlider; public Slider infectionSlider; public TextMeshProUGUI ammoText; public GameObject crosshair; public GameObject teammatePanel; private PlayerStatus playerStatus; private WeaponController weapon; private void Start() { playerStatus = PlayerManager.LocalPlayer.GetComponent(); weapon = PlayerManager.LocalPlayer.GetComponentInChildren(); // Subscribe to events playerStatus.OnHealthChanged += UpdateHealth; playerStatus.OnStaminaChanged += UpdateStamina; playerStatus.OnInfectionChanged += UpdateInfection; if(weapon != null) weapon.OnAmmoChanged += UpdateAmmo; } private void UpdateHealth(float current, float max) { healthSlider.value = current / max; } private void UpdateStamina(float current, float max) { staminaSlider.value = current / max; } private void UpdateInfection(float current, float max) { infectionSlider.value = current / max; } private void UpdateAmmo(int current, int max) { ammoText.text = $"{current}/{max}"; } public void ToggleCrosshair(bool show) { crosshair.SetActive(show); } public void UpdateTeammateStatus(PlayerController teammate, float health, float infection) { // Find or create teammate UI element // Update with current status } } // Camera Controller public class PlayerCamera : MonoBehaviour { public Transform firstPersonTarget; public Transform thirdPersonTarget; public float fov = 60f; public float mouseSensitivity = 2f; private Camera cam; private bool isFirstPerson = true; private float xRotation = 0f; private void Awake() { cam = GetComponent(); Cursor.lockState = CursorLockMode.Locked; // Subscribe to camera toggle event InputManager.Instance.OnCameraToggle += ToggleCamera; } private void Update() { // Mouse look float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity; float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity; xRotation -= mouseY; xRotation = Mathf.Clamp(xRotation, -90f, 90f); transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f); transform.parent.Rotate(Vector3.up * mouseX); } private void ToggleCamera(float value) { if(value > 0.5f) { isFirstPerson = !isFirstPerson; UpdateCameraPosition(); } } private void UpdateCameraPosition() { if(isFirstPerson) { transform.position = firstPersonTarget.position; cam.fieldOfView = fov; } else { transform.position = thirdPersonTarget.position; cam.fieldOfView = fov * 0.8f; // Slightly zoomed out in third person } } }

Project Structure & Optimization

Folder Structure

Project_Nightfall/ ├── Assets/ │ ├── Animations/ │ ├── Audio/ │ ├── Materials/ │ ├── Models/ │ ├── Prefabs/ │ ├── Scenes/ │ ├── Scripts/ │ │ ├── AI/ │ │ ├── Gameplay/ │ │ ├── Network/ │ │ ├── UI/ │ │ └── Utility/ │ ├── Shaders/ │ ├── Textures/ │ └── UI/ ├── Docs/ ├── ThirdParty/ └── ProjectSettings/

Optimization Techniques

  • Object pooling for zombies and projectiles
  • LOD groups for complex models
  • Occlusion culling for interiors
  • Network traffic optimization (delta compression)
  • Asynchronous asset loading
  • AI processing budget (time-sliced updates)

Implementation Roadmap

This modular architecture provides a solid foundation for your zombie survival co-op game. The systems are designed to work independently while integrating seamlessly, allowing for iterative development and testing of individual features.

Phase 1

  • Core movement/controls
  • Basic zombie AI
  • Single-player prototype

Phase 2

  • Networking foundation
  • Inventory/crafting
  • Co-op mechanics

Phase 3

  • World systems
  • Horror elements
  • Polish/optimization
Download Technical Design Document

Made with DeepSite LogoDeepSite - 🧬 Remix