All projects

Unity Quest System

C#/Personal library
Built
2025-03-01
Stack
C# · Unity
Context
Personal library
Overview

A Unity package that keeps quest logic from tangling into the rest of a game. Objectives are data assets you define in the editor, and runtime events move through an event bus: broadcaster components emit when their conditions are met, and receivers anywhere in the scene respond by running pluggable execution strategies. Because nothing holds a direct reference to a quest manager, quests persist across scene loads without the usual singleton holding everything together.

What it does

ScriptableObject Quest Objectives

Define quest goals as data assets directly in the Unity Editor. Set a description, a maximum completion count for repeatable objectives, and an execution queue length. Content designers can build and iterate on quest content without touching code.

Broadcaster / Receiver Architecture

Attach a broadcaster component to any GameObject to emit a quest event when a condition is satisfied. Place receiver components anywhere in any scene to respond. The two halves of a quest step are entirely decoupled; they can live in separate prefabs, separate scenes, or anywhere in the hierarchy.

Three Trigger Modes

Receivers ship with three built-in behaviors: fire permanently when first satisfied, reset when the condition goes false and re-fire when it becomes true again, or execute on every single positive broadcast. Each mode covers a common quest scenario with no custom trigger logic needed.

Pluggable Condition Strategies

Define how a broadcaster evaluates its condition through a strategy interface: physics trigger overlap, countdown timer, dialogue response, inventory check, or any arbitrary game state. Swap strategies in the Inspector at design time. The framework handles lifecycle, deduplication, and broadcast logic.

Pluggable Execution Strategies

Define what a receiver does when its quest outcome fires through a strategy interface: unlock a door, spawn enemies, start a cutscene, update an HUD marker. Each receiver carries its own strategy, so a single quest step can trigger different behaviors across multiple locations simultaneously.

Cross-Scene Persistence

The quest manager persists across scene loads. Objective completion state survives transitions, so a quest started in an early zone is still accurately tracked when the player reaches the final area.

Thread-Safe Repeatable Objectives

Objective instances track conditions met and total completions as separate counters behind a lock, safely handling the case where multiple broadcasters attempt to mark the same objective complete simultaneously. Repeatable objectives clamp correctly and never double-count.

Composable with Logic Conditions

Quest objective completion state can be wrapped as a composable condition and plugged into the Logic module from Unity Extensions. Gate abilities, unlock content, or branch dialogue trees using AND, OR, and NOT operators over quest state. No special-casing required.