Overview
Add AI-powered NPCs to your Unity game. Talk to them, and they respond with personality, knowledge, and awareness of their surroundings.
Quick Example
using Peek.LoreMind;
var npc = GetComponent<LoreMindNPC>();
var response = await npc.RespondAsync("What do you know about the dragon?");
if (response.success)
Debug.Log(response.response);
else
Debug.LogWarning($"{response.error}: {response.message}");RespondAsync never returns null and never throws for a failed request: a failure comes back as a response with success = false, an error code in error and no dialogue.
New in 1.0.9: LoreMind installs and updates through Package Manager, saved Active Knowledge Tags take effect, the new OnRequestFinished event fires once when a request ends, and Server API Keys work only in the Editor and on dedicated servers. See What's New in 1.0.9 before you upgrade.
Two Ways to Use It
Editor Testing
During development, the SDK connects directly to LoreMind using a Server API Key stored locally. This lets you prototype quickly without setting up a backend.
// Works immediately in the Editor
var response = await npc.RespondAsync("Hello!");Your Server API Key is stored in Unity's per-project user settings (the UserSettings/ folder) and is never included in builds. The Editor-only transport that uses it doesn't exist in game client builds at all.
Production
When you ship your game, NPC requests route through your game server. Your server holds the API key securely and can:
- Use your authentication system (Steam, Epic, custom)
- Provide
playerIdfor long-term memory - Add custom validation and rate limiting
flowchart LR
game["Your Game"]:::neutral --> server["Your Server"]:::neutral --> api["LoreMind API"]:::runtime
classDef runtime fill:#d96a57,stroke:#a03f37,color:#2b0e0a
classDef neutral fill:transparent,stroke-dasharray:4 3
See Backend Integration for setup instructions.
SDK Components
LoreMindNPC
The core component. Attach to any GameObject to make it conversational:
var npc = GetComponent<LoreMindNPC>();
// Set context for better responses
npc.SetLocation("Blacksmith Shop", "Hot, smell of metal");
npc.Context.timeOfDay = "evening";
// Talk to the NPC
var response = await npc.RespondAsync("What can you forge?");See LoreMindNPC Component for full documentation.
RuntimeContext
Pass situational information to improve NPC responses:
npc.Context.location = "Town Square";
npc.Context.timeOfDay = "dusk";
npc.Context.weather = "rainy";
npc.Context.npcMood = "cheerful";
npc.Context.playerAppearance = "battle-worn, carrying broken sword";
npc.Context.recentEvents = new[] { "Dragon spotted nearby" };See Context System for details.
LocationZone
Trigger-based automatic location context. Attach it to a trigger collider: NPCs entering the zone automatically know where they are.
ContextTag
Mark GameObjects as perceivable by NPCs. Attach it to characters, items, or landmarks: NPCs with AutoSenseNearby detect tagged entities.
Voice Input
Optional speech-to-text so players can talk to NPCs:
- LoreMindVoiceInput - Speech-to-text using Whisper (local, offline)
See Voice Input.
Long-Term Memory
NPCs can remember individual players across sessions:
npc.EnableMemoryRetrieval = true; // Recall what this player told the NPC beforeWhen Long-Term Memory is turned on for your project, LoreMind stores new memories for requests that carry a playerId, which your backend adds from the player's verified login. LoreMind support turns Long-Term Memory on and records the memory agreement (your project's page in the LoreMind dashboard shows the status). It isn't available for projects marked Players under 18. While it's off, NPCs still answer, but no memories are stored or recalled.
Requires: Production setup with playerId. See Long-Term Memory.
Documentation
Getting Started
- Installation - Install and configure the SDK
- Your First NPC - Build your first NPC
- Backend Setup - Prepare for production
Components
- LoreMindNPC - Main NPC component
- Context System - Situational awareness
- Voice Input - Speech-to-text integration
Editor Tools
- Lore Sync - Pull your project's lore data from the dashboard into the Unity Editor
Reference
- API Reference - Complete SDK API
- What's New in 1.0.9: breaking changes and upgrade checklist
Platform
- Server Integration - Backend patterns
- Authentication - API key setup
- Credits & Billing - How usage is billed
- Platform Overview - Dashboard and API