Your First NPC
Put a talking Mistscale NPC in your scene with one component and a few lines of code.
One component does the work: MistscaleNPC. Add it to a GameObject, give it the ID of an NPC from your project, and it connects on Play. Sending a message is one method; receiving the reply is one event.
Scene setup
- 1
Create the NPC in the dashboard if you have not already (name, role, personality, optional lore files).
- 2
Copy its NPC ID, either from the dashboard or from the Mistscale → Login window's NPC list.
- 3
In your scene, add the MistscaleNPC component to the character's GameObject. Unity will add the required voice and audio components alongside it automatically.
- 4
Paste the NPC ID into the component's NPC Identity field in the Inspector.
- 5
Press Play. The component connects in the background; watch the Console for the connected message if logging is enabled.
Talking to it from code
Wire one event for replies, call one method to speak. A minimal dialogue script looks like this:
using Mistscale.SDK;
using UnityEngine;
public class TavernKeeper : MonoBehaviour
{
[SerializeField] private MistscaleNPC mira; // drag in the Inspector
void Start()
{
mira.OnNPCResponseReceived += reply => dialogueUI.Show(reply);
}
// Hook this to your chat input field or interaction key
public void Say(string playerMessage)
{
mira.SendChat(playerMessage);
}
}That is the entire integration for text. The NPC's memory of this player, its mood, and its grounding against your lore all update automatically with every exchange; the next session picks up where this one left off.
The component surface
NPCIdIsConnectedSendChat(text)OnNPCResponseReceivedOnAudioResponseReceivedOnPlayerSpeechRecognizedSetSpatialContext(...)ToggleConversation()