A plug-and-play, 100% on-device AI NPC system for Unity. Bring Non-Player Characters to life with real-time voice-to-voice interaction — powered locally by Large Language Models (LLM), Speech-to-Text (STT), and Neural Text-to-Speech (TTS).
🔒 100% Local & Private: Zero cloud APIs, no monthly subscriptions, zero network latency, and complete privacy — nothing ever leaves the player's computer.
AISystemManager, VoiceInputService, VoiceOutputService, NPCAgent) that auto-bind at runtime.You can add this entire framework to any new or existing Unity project in seconds:
https://github.com/oguzhan00yildiz/Unity-Local-AI-Driven-NPCs.git?path=AIPackageInstaller
[AI Package Installer] Initializing…
[AI Package Installer] manifest.json patched (NPM ONNX registry added).
[AI Package Installer] Installing: LLMUnity, Piper TTS, Whisper STT…
[AI Package Installer] ✅ All AI packages installed successfully!
⚠️ Important: Keep the Unity Editor open and in focus during package installation and model setup. Switching to other applications can cause Unity to throttle background execution, which can interrupt LLM native server configuration and model downloads.
Once packages are resolved, the AI System Setup Window automatically downloads and configures the required local models:
| Component | Model / Asset | Size | Purpose |
|---|---|---|---|
| STT | Whisper/ggml-tiny.bin | 74 MB | Fast speech-to-text recognition |
| TTS Core | PiperTTS/model.onnx + dicts | 70 MB | Phonemizer & tokenizer |
| Voices | Amy (Female) & Ibrahim (Male) | ~122 MB | High-quality neural voice models |
| LLM | Qwen3.5-0.8B-Q4_K_M.gguf | 500 MB | Fast & smart on-device language model |
(All models are saved to Assets/StreamingAssets/ and auto-assigned to prefabs).
Default LLM Model:
Qwen3.5-0.8B-Q4_K_M.gguf(~500 MB) is preconfigured out of the box. It offers high-speed on-device generation with minimal resource usage.
AISystem prefab and select the LLM GameObject.LLM component..gguf file stored on your PC or inside Assets/StreamingAssets/.Assets/Samples/AI Driven NPCs System/2.4.2/Scenes/AIOScene.unity.The system uses a decoupled, event-driven service architecture:
graph TD
Player[Player Character] -->|Proximity Trigger / Press E| NPCAgent[NPCAgent Component]
NPCAgent -->|OpenChat| Manager[AISystemManager Singleton]
Manager -->|Starts Listening| VoiceIn[VoiceInputService - Whisper STT]
VoiceIn -->|OnTranscription| Manager
Manager -->|Stream Prompt| LLM[LLMAgent / LLMUnity]
LLM -->|Stream Text Chunks| UI[ChatUIController]
LLM -->|OnResponseComplete| VoiceOut[VoiceOutputService - Piper TTS]
VoiceOut -->|Sentence Queue Speech| Audio[AudioSource Output]
| Component | Role | Description |
|---|---|---|
AISystemManager.cs | Coordinator | Central singleton. Manages chat lifecycle, cursor locking, character movement toggling, and event dispatch. |
NPCAgent.cs | NPC Brain | Attached to NPC GameObject. Handles proximity triggers, 3D prompt cues, and personality preset bindings. |
VoiceInputService.cs | Speech-to-Text | Microphone audio capture, voice activity detection (VAD), silence filtering, and Whisper transcription. |
VoiceOutputService.cs | Text-to-Speech | Splits incoming LLM text into sentence batches and synthesizes speech seamlessly via Piper TTS. |
ChatUIController.cs | UI Display | Pure UI controller. Renders streaming tokens, chat history, input field, and loading overlays. |
ModelBootstrapper.cs | Warmup | Asynchronously warms up all LLM and Whisper models on startup in parallel. |
You can create distinct NPC characters in seconds using Personality Presets:
Captain ValerieYou are Captain Valerie, a battle-hardened sky pirate.
Speak with confidence and a pirate flair. Keep your answers under 2 sentences.
en_US-amy-low or en_US-reza_ibrahim-medium.NPCAgent inspector.If you want to build custom UI, trigger dialogues from quests, or execute LLM/TTS logic directly in your own scripts:
using AISystem;
using UnityEngine;
public class QuestDialogueTrigger : MonoBehaviour
{
public NPCAgent targetNPC;
public void OnQuestTargetReached()
{
if (AISystemManager.Instance != null && targetNPC != null)
{
// Opens UI, locks player controls, starts STT listening
AISystemManager.Instance.OpenChat(targetNPC);
}
}
}
using LLMUnity;
using UnityEngine;
public class CustomAIQuery : MonoBehaviour
{
public LLMAgent llmAgent;
public async void AskQuestion(string prompt)
{
await llmAgent.Chat(
prompt,
onChunkReceived: (token) => Debug.Log($"Streamed: {token}"),
onComplete: () => Debug.Log("Response completed!")
);
}
}
using AISystem;
using UnityEngine;
public class AnnouncerSystem : MonoBehaviour
{
public VoiceOutputService voiceOutput;
public void Announce(string message)
{
// Automatically chunks sentences and plays via Piper TTS
voiceOutput.Speak(message);
}
}
The package includes built-in tools under the Tools → AI Packages menu:
2021.3 LTS, 2022.3 LTS, or Unity 6+ (URP, HDRP, or Built-in RP).This project is licensed under the MIT License.
A plug-and-play, 100% on-device AI NPC system for Unity. Bring Non-Player Characters to life with real-time voice-to-voice interaction — powered locally by Large Language Models (LLM), Speech-to-Text (STT), and Neural Text-to-Speech (TTS).
🔒 100% Local & Private: Zero cloud APIs, no monthly subscriptions, zero network latency, and complete privacy — nothing ever leaves the player's computer.
AISystemManager, VoiceInputService, VoiceOutputService, NPCAgent) that auto-bind at runtime.You can add this entire framework to any new or existing Unity project in seconds:
https://github.com/oguzhan00yildiz/Unity-Local-AI-Driven-NPCs.git?path=AIPackageInstaller
[AI Package Installer] Initializing…
[AI Package Installer] manifest.json patched (NPM ONNX registry added).
[AI Package Installer] Installing: LLMUnity, Piper TTS, Whisper STT…
[AI Package Installer] ✅ All AI packages installed successfully!
⚠️ Important: Keep the Unity Editor open and in focus during package installation and model setup. Switching to other applications can cause Unity to throttle background execution, which can interrupt LLM native server configuration and model downloads.
Once packages are resolved, the AI System Setup Window automatically downloads and configures the required local models:
| Component | Model / Asset | Size | Purpose |
|---|---|---|---|
| STT | Whisper/ggml-tiny.bin | 74 MB | Fast speech-to-text recognition |
| TTS Core | PiperTTS/model.onnx + dicts | 70 MB | Phonemizer & tokenizer |
| Voices | Amy (Female) & Ibrahim (Male) | ~122 MB | High-quality neural voice models |
| LLM | Qwen3.5-0.8B-Q4_K_M.gguf | 500 MB | Fast & smart on-device language model |
(All models are saved to Assets/StreamingAssets/ and auto-assigned to prefabs).
Default LLM Model:
Qwen3.5-0.8B-Q4_K_M.gguf(~500 MB) is preconfigured out of the box. It offers high-speed on-device generation with minimal resource usage.
AISystem prefab and select the LLM GameObject.LLM component..gguf file stored on your PC or inside Assets/StreamingAssets/.Assets/Samples/AI Driven NPCs System/2.4.2/Scenes/AIOScene.unity.The system uses a decoupled, event-driven service architecture:
graph TD
Player[Player Character] -->|Proximity Trigger / Press E| NPCAgent[NPCAgent Component]
NPCAgent -->|OpenChat| Manager[AISystemManager Singleton]
Manager -->|Starts Listening| VoiceIn[VoiceInputService - Whisper STT]
VoiceIn -->|OnTranscription| Manager
Manager -->|Stream Prompt| LLM[LLMAgent / LLMUnity]
LLM -->|Stream Text Chunks| UI[ChatUIController]
LLM -->|OnResponseComplete| VoiceOut[VoiceOutputService - Piper TTS]
VoiceOut -->|Sentence Queue Speech| Audio[AudioSource Output]
| Component | Role | Description |
|---|---|---|
AISystemManager.cs | Coordinator | Central singleton. Manages chat lifecycle, cursor locking, character movement toggling, and event dispatch. |
NPCAgent.cs | NPC Brain | Attached to NPC GameObject. Handles proximity triggers, 3D prompt cues, and personality preset bindings. |
VoiceInputService.cs | Speech-to-Text | Microphone audio capture, voice activity detection (VAD), silence filtering, and Whisper transcription. |
VoiceOutputService.cs | Text-to-Speech | Splits incoming LLM text into sentence batches and synthesizes speech seamlessly via Piper TTS. |
ChatUIController.cs | UI Display | Pure UI controller. Renders streaming tokens, chat history, input field, and loading overlays. |
ModelBootstrapper.cs | Warmup | Asynchronously warms up all LLM and Whisper models on startup in parallel. |
You can create distinct NPC characters in seconds using Personality Presets:
Captain ValerieYou are Captain Valerie, a battle-hardened sky pirate.
Speak with confidence and a pirate flair. Keep your answers under 2 sentences.
en_US-amy-low or en_US-reza_ibrahim-medium.NPCAgent inspector.If you want to build custom UI, trigger dialogues from quests, or execute LLM/TTS logic directly in your own scripts:
using AISystem;
using UnityEngine;
public class QuestDialogueTrigger : MonoBehaviour
{
public NPCAgent targetNPC;
public void OnQuestTargetReached()
{
if (AISystemManager.Instance != null && targetNPC != null)
{
// Opens UI, locks player controls, starts STT listening
AISystemManager.Instance.OpenChat(targetNPC);
}
}
}
using LLMUnity;
using UnityEngine;
public class CustomAIQuery : MonoBehaviour
{
public LLMAgent llmAgent;
public async void AskQuestion(string prompt)
{
await llmAgent.Chat(
prompt,
onChunkReceived: (token) => Debug.Log($"Streamed: {token}"),
onComplete: () => Debug.Log("Response completed!")
);
}
}
using AISystem;
using UnityEngine;
public class AnnouncerSystem : MonoBehaviour
{
public VoiceOutputService voiceOutput;
public void Announce(string message)
{
// Automatically chunks sentences and plays via Piper TTS
voiceOutput.Speak(message);
}
}
The package includes built-in tools under the Tools → AI Packages menu:
2021.3 LTS, 2022.3 LTS, or Unity 6+ (URP, HDRP, or Built-in RP).This project is licensed under the MIT License.