Created and maintained by Unity King
https://unityking.com
This repository contains only the Assets/ folder with a complete AI-powered Dialogue Engine.
-
Create or open a Unity project
- Unity 2021 LTS or newer recommended
-
Copy the
Assetsfolder from this repository
Paste it into your Unity project root -
Open Unity
- Scripts will auto-import
-
Add Dialogue components to your NPCs
- Setup explained below
You are now ready to use the Dialogue Engine.
Assets/
├── Scripts/
│ ├── DialogueAI/
│ │ ├── Core/
│ │ │ ├── DialogueController.cs
│ │ │ ├── DialogueContext.cs
│ │ │ └── DialogueMemory.cs
│ │ ├── IntentSystem/
│ │ │ ├── DialogueIntent.cs
│ │ │ ├── IntentClassifier.cs
│ │ └── IntentResponse.cs
│ │ ├── Nodes/
│ │ │ ├── DialogueNode.cs
│ │ │ ├── DialogueOption.cs
│ │ │ └── DialogueGraph.cs
│ │ ├── QuestHooks/
│ │ │ ├── QuestTrigger.cs
│ │ │ └── DialogueQuestBridge.cs
│ │ └── UI/
│ │ └── DialogueUIController.cs
The Dialogue Engine is built on four core systems:
Controls dialogue flow and NPC interaction lifecycle.
Remembers:
- Player choices
- NPC relationships
- Past dialogue events
- Quest states
Understands what the player means, not just what they click:
- Greeting
- Asking for help
- Threatening
- Accepting / rejecting quests
Dialogue directly affects:
- Quest start
- Quest progression
- Quest completion
Main entry point for NPC dialogue.
Responsibilities:
- Start / end dialogue
- Route dialogue nodes
- Communicate with UI
- Update memory & quests
DialogueController controller;
controller.StartDialogue(player);Attach this to NPC GameObjects.
Stores runtime context:
- Current NPC
- Current node
- Player state
- World flags
context.currentNode
context.currentSpeakerPersistent memory system.
Stores:
- Player choices
- Flags (helpedNPC, betrayedNPC, etc.)
- Relationship values
memory.SetFlag("HelpedVillager", true);The Intent System allows natural-feeling dialogue.
Represents an intent like:
- Greet
- AskForQuest
- Threaten
- Goodbye
Maps player input or options to intents.
IntentType result = classifier.Classify(input);This allows:
- Dynamic responses
- AI-driven dialogue logic
- LLM integration later
Represents a single dialogue state.
DialogueNode
{
text: "Hello traveler",
options: [...]
}Player choices that:
- Change context
- Trigger intents
- Fire quests
option.nextNodeId
option.intentHooks dialogue to quest logic.
Examples:
- Start quest on dialogue
- Complete quest on choice
- Fail quest on threat
QuestTrigger.TriggerQuest("FindTheSword");Connects Dialogue Engine with your Quest System.
Handles:
- Showing dialogue text
- Rendering options
- Player input
Framework is UI-agnostic:
- Unity UI
- TMP
- Custom UI systems
-
Create NPC GameObject
-
Add:
- DialogueController
- DialogueUIController
-
Assign:
- DialogueGraph
- Memory reference
-
Press ▶ Play
NPC will:
- Remember player
- React to choices
- Trigger quests
You can easily add:
- Voice acting
- Relationship systems
- LLM / AI text generation
- Morality systems
- Branching storylines
- RPGs
- Adventure games
- Story-driven games
- AI NPC experiments
- LLM-powered dialogue
MIT License Free for personal & commercial use.
Unity King https://unityking.com Game AI • Systems • Tools
⭐ Star the repository if this helps your project.