Quest Trigger

QuestTrigger.cs

Overview

QuestTrigger is a universal quest state management component. It can start, complete, fail, abandon, or manipulate the objectives of any quest registered with the QuestManager. It supports multiple activation methods, conditional logic, visual state indicators, audio/visual feedback, and full save system integration.

A single QuestTrigger performs one defined action on one defined quest — for example, starting a quest when the player enters a zone, or completing an objective when the player clicks an object.

Inspector Properties

Quest Selection

Property
Description

Selected Quest

The Quest ScriptableObject this trigger will act upon. Drag a Quest asset here. The Quest ID field is auto-populated.

Quest ID

Read-only. Auto-populated from the Selected Quest asset.

Trigger Name

A friendly label for this trigger, used for organisation and gizmo display only.

Quest Action

The action to perform when the trigger fires. See Quest Actions below.

Select Objective

Visible when action is CompleteObjective. Dropdown list populated from the selected quest's objectives.

Force Complete

When using CompleteObjective, marks the objective complete even if its requirements haven't been met.

Activation Method

Property
Description

Activation Method

How this trigger is activated. See Activation Methods below.

Activator Tag

The Unity tag that can activate this trigger (default: Player).

Use Malbers Tag

Use Malbers' Tags system instead of Unity's built-in tag system.

Malbers Tag

The Malbers Tag (ID) required for activation. Requires an IDs component on the activator.

Action Delay

Time in seconds to wait after activation before executing the quest action. Useful for syncing with animations.

Conditions

Property
Description

Check Prerequisites

Verifies all prerequisite quests defined on the Quest ScriptableObject are completed before allowing action.

Validate Quest State

Checks the quest is in a valid state for the chosen action (e.g. prevents completing a quest that hasn't started).

Custom Conditions

A list of additional conditions that must all be true. Supports QuestCompleted, QuestActive, QuestNotStarted, ObjectiveComplete, HasItem, and Custom condition types. Each condition can be inverted.

Behaviour

Property
Description

Is Repeatable

Allows the trigger to be activated multiple times. When disabled, it fires only once.

Cooldown

Minimum time in seconds between activations when Is Repeatable is enabled.

Deactivate After Use

Disables the GameObject after the trigger fires. The object remains in the scene but becomes inactive.

Destroy After Use

Removes the GameObject from the scene entirely after firing. Takes precedence over Deactivate After Use.

Save System Integration

Property
Description

Auto Generate Trigger ID

Generates a unique ID from scene name, object name, and world position. Recommended for all placed triggers.

Custom Trigger ID

Manually specify a unique ID. Required for runtime-spawned triggers.

Save Trigger State

Saves whether this trigger has fired so it does not re-activate on scene reload.

Visual Feedback

Property
Description

Quest Indicator

Generic indicator GameObject shown when the quest can be interacted with.

Available Indicator

Shown when a new quest is available to start (e.g. a yellow ! icon).

Completable Indicator

Shown when the quest is ready to be turned in (e.g. a yellow ? icon).

Completed Indicator

Shown when the quest has already been completed (e.g. a grey checkmark).

Show Interaction Prompt

Displays a UI element when the player is in range and can interact.

Prompt Text

The text to display in the interaction prompt.

Prompt UI

The UI GameObject to show/hide for the prompt.

Audio/Visual Effects

Property
Description

Activation Sound

Audio clip played when the trigger fires.

Sound Volume

Volume of the activation sound (0–1).

Activation Effect

A particle effect or prefab instantiated at the trigger's position on activation. Auto-destroyed after the specified duration.

Effect Duration

How long in seconds before the spawned effect is destroyed.

Events

Event
Type
Description

On Quest Started

StringEvent

Fired when a quest is successfully started. Passes the quest ID.

On Quest Completed

StringEvent

Fired when a quest is successfully completed. Passes the quest ID.

On Quest Failed

StringEvent

Fired when a quest is marked as failed. Passes the quest ID.

On Quest Abandoned

StringEvent

Fired when a quest is abandoned. Passes the quest ID.

On Action Executed

MEvent

Generic event fired on any successful quest action.

On Action Failed

MEvent

Fired when the action could not be executed (invalid state, prerequisites not met, etc.).

Quest Manager

Property
Description

Use Direct Reference

When enabled, references a specific QuestManager instead of using the singleton.

Quest Manager

The QuestManager component to use when Use Direct Reference is enabled.


Quest Actions

Action
Description

StartQuest

Starts the selected quest if it has not already been started and prerequisites are met.

CompleteQuest

Marks the quest as completed if it is currently active.

FailQuest

Marks the quest as failed if it is currently active.

AbandonQuest

Abandons the quest if it is currently active.

CompleteObjective

Completes a specific objective by index within the active quest.

CompleteAllObjectives

Marks all objectives in the quest as complete. If this satisfies completion criteria, the quest completes automatically.

ResetQuest

Resets a completed or repeatable quest (logic placeholder — extend as needed).

CheckProgress

Logs the current completion percentage of the quest. Can be extended to fire events with progress data.

ToggleTracking

Toggles the tracked state of the quest on the HUD.


Activation Methods

Method
Description

OnTriggerEnter

Fires when a valid activator enters the attached Collider trigger zone. Requires a Collider with Is Trigger enabled.

OnTriggerStay

Fires continuously while a valid activator remains inside the trigger zone.

OnInteract

Fires when a valid activator is in range and presses the E key.

OnClick

Fires when the object is clicked with the mouse (OnMouseDown).

Manual

Does not fire automatically. Call Activate() from code or a Unity Event.

OnStart

Fires immediately during Start(). Useful for auto-starting quests on scene load.

OnQuestComplete

Intended for quest chain logic. Call Activate() when a preceding quest completes.

Chain

Used as part of a sequential quest chain. Call Activate() to proceed.

Public API

Method
Description

Activate()

Manually activates this trigger from code or a Unity Event.

ResetTrigger()

Resets the trigger so it can be activated again (even if Is Repeatable is disabled).

SetQuest(Quest quest)

Changes the target quest at runtime.

SetAction(QuestAction action)

Changes the quest action at runtime.

GetTriggerID()

Returns the current unique trigger ID used by the save system.

SetCustomTriggerID(string id)

Sets a custom trigger ID at runtime (useful for procedurally spawned triggers).

RecheckSavedState()

Re-evaluates save data after a save file is loaded. Called automatically by QuestForgeRuntimeSetup.

Custom Conditions

The Custom Conditions list allows complex prerequisite logic to be defined without code. Each entry has the following fields:

Field
Description

Type

The condition category: QuestCompleted, QuestActive, QuestNotStarted, ObjectiveComplete, HasItem, or Custom.

Required Quest

The Quest ScriptableObject to evaluate (used by most condition types).

Required Quest ID

String ID alternative to the quest reference. Takes priority if set.

Objective Index

The objective index to check (used by ObjectiveComplete).

Custom Flag

A string flag for Custom type conditions (integration point for your own flag system).

Invert Condition

Inverts the result — the condition passes when it would normally fail.

How Reporting Works

Unlike QuestCollectable and QuestInteractable, QuestTrigger does not route through QuestEventReporter. Instead, it calls QuestManager methods directly when it fires.

The execution flow is:

  1. Activation condition is met (trigger entered, key pressed, Activate() called, etc.)

  2. CanActivate() is evaluated — checks repeat state, cooldown, quest manager availability, quest state validity, prerequisites, and any custom conditions

  3. If all conditions pass, the configured Quest Action is executed against QuestManager (e.g. questManager.StartQuest(questId), questManager.CompleteQuest(questId))

  4. On success, the corresponding event fires (OnQuestStarted, OnQuestCompleted, etc.) followed by OnActionExecuted

  5. On failure, OnActionFailed fires

  6. Post-execution behaviour runs — save state is written, sound/effects play, and the GameObject is deactivated or destroyed if configured

The QuestManager is resolved via QuestManager.Instance unless Use Direct Reference is enabled, in which case the assigned reference is used.

Other Notes

  • When using OnTriggerEnter or OnTriggerStay activation, the GameObject must have a Collider with Is Trigger enabled. The Inspector will display a warning if this is not configured.

  • The QuestTrigger resolves the QuestManager via singleton (QuestManager.Instance) unless Use Direct Reference is enabled.

  • The custom editor provides a live Status panel in Play Mode, showing quest state, a progress bar, and a Test Trigger button.

  • The Quick Quest Selection panel appears in Edit Mode when no quest is assigned, allowing you to click any registered quest for rapid assignment.

Last updated