Unity tutorial shows how to build voice-driven NPCs with memory and world context
A new Unity guide walks through building a voice character that hears the player, remembers past conversations and answers with awareness of the game world. The system rests on a local model, dialogue memory and a voice loop that combines speech recognition with voice synthesis. The architecture draws on Generative Agents and works as a base for indie prototypes, RPG scenes and more complex dialogue systems.
AI-processed from Habr AI; edited by Hamidun News
A detailed guide has appeared on building voice-driven NPCs in Unity that do more than answer from a script: they account for memory, world state and earlier conversations. The approach combines a local LLM, voice input and the Generative Agents architecture, so the character reacts to the player as it would to a real conversation partner.
How the NPC changes
The main idea of the piece is to move away from classic trigger-based lines and build a character that treats a conversation as a continuous story. If the player has already asked about the blacksmith, visited the village during the day and then returned in the evening, the NPC does not start the dialogue from scratch. It receives context, recalls past meetings and answers as if it genuinely lives inside the world, rather than existing only in a single dialogue window.
The author describes the system as a sequential build: from the first request to a local language model to a full voice interface. As a result, the NPC can hear the player's phrase, interpret it using the world's rules, perform simple inference and return an answer by voice. For indie developers this is an important shift: instead of rigid dialogue branches, there is a more flexible behavior layer that can grow without thousands of pre-written lines.
What it consists of
At the center of the architecture is not one magic prompt but several working layers that sustain the feeling of a "living" character. Judging by the description, the system is built around memory, scene context and a voice loop, and the LLM acts not merely as a text generator but as a mechanism for making local decisions within a defined world.
- A local LLM processes lines and forms the reply without necessarily sending data to the cloud
- Memory stores past conversations, facts about the character and important events
- World context tells the model the time of day, the location, NPC roles and the current situation
- The voice layer converts the player's speech to text and voices the character's final answer
The reliance on Stanford's Generative Agents matters separately. This architecture is known for splitting an agent's behavior into observation, memory, reflection and planning. In a game context the approach is useful because the NPC stops being just a "talking button." It can connect the player's current question to past events, apply local rules and answer not randomly but within its character and role.
Why developers should care
The piece offers not an abstract idea of "AI in games" but a practically applicable route for Unity development. The step-by-step format is what matters here: first a basic channel to the model is set up, then knowledge of the world is added, and after that long-term memory and voice. This order lowers the barrier to entry. A developer does not need to build the perfect system at once; they can start with one NPC, check the quality of the dialogue and then add complexity to the mechanics.
"Hi, where is the tavern here?" is an example of a query the NPC
should answer using the earlier conversation and the current context.
Another strong point is the emphasis on a local model. For prototypes and small studios this means more control over costs, less dependence on external APIs and the ability to experiment even where a constant internet connection or a cloud budget is limited.
Of course, this approach requires careful tuning: you need to watch the memory size, the quality of speech recognition and make sure the model does not drift away from the lore. But the very fact that such a system can be built in Unity in a clear sequence makes the topic much closer to real development than many general discussions of AI NPCs.
What this means
The games market is gradually moving from scripted dialogue to characters that remember, listen and react to context. Guides like this matter not because they deliver a ready-made AAA result, but because they turn the idea of "living NPCs" into a repeatable engineering task for Unity teams.
- Nov 1, 2026Local models lose to Opus and Codex: 0.21 on a MacBook versus 1.00 for Codex
- Nov 1, 2026Adobe's EditAgent judge picks a usable edit 81.3% of the time, versus 74.8% for EditScore
- Nov 1, 202616 models tested on 7 search tools: Exa averaged 10.5 out of 14, SearXNG about 3
- Nov 1, 2026Google's StreamVibe video agent beats other models by 10.7% on response timing and quality
Key Questions Answered
How the NPC changes?
The main idea of the piece is to move away from classic trigger-based lines and build a character that treats a conversation as a continuous story. If the player has already asked about the blacksmith, visited the village during the day and then returned in the evening, the NPC does not start the dialogue from scratch. It receives context, recalls past meetings and answers as if it genuinely lives inside the world, rather than existing only in a single dialogue window. The author describes the system as a sequential build: from the first request to a local language model to
What it consists of?
At the center of the architecture is not one magic prompt but several working layers that sustain the feeling of a "living" character. Judging by the description, the system is built around memory, scene context and a voice loop, and the LLM acts not merely as a text generator but as a mechanism for making local decisions within a defined world. A local LLM processes lines and forms the reply without necessarily sending data to the cloud Memory stores past conversations, facts about the character and important events World context tells the model the time of day, the locati
Why developers should care?
The piece offers not an abstract idea of "AI in games" but a practically applicable route for Unity development. The step-by-step format is what matters here: first a basic channel to the model is set up, then knowledge of the world is added, and after that long-term memory and voice. This order lowers the barrier to entry. A developer does not need to build the perfect system at once; they can start with one NPC, check the quality of the dialogue and then add complexity to the mechanics. "Hi, where is the tavern here?" is an example of a query the NPC should answer using t
Build & Ship Production AI Agents Without Boilerplate Code
Start your free 72-hour trial at Hamidun Academy (academy.hamidun.com) — interactive lessons on Claude Code & Cursor, live Tech Radar, and production agent templates.
The AI world, distilled — once a week
Seven stories that actually mattered, hand-picked. No noise, no reposts, no press releases.
Done! Check your inbox for a confirmation.