AI NPC
This guide shows how to create AI-driven NPCs using the NAREON system. We'll set up a personality profile, manage states, and generate dialogue.
1. Extending NAREONAgent
NAREONAgentCreate a script, for example MyPersonalityNPC.cs:
using UnityEngine;
using NAREON;
using System.Collections.Generic;
public class MyPersonalityNPC : NAREONAgent
{
void Start()
{
var profile = new PersonalityProfile
{
Name = "Aria the Bard",
CoreTraits = new[] { "Cheerful", "Brave", "Curious" },
MoodThresholds = new Dictionary<Mood, float>
{
{ Mood.Happy, 0.8f },
{ Mood.Anxious, 0.2f }
},
Ideals = new[] { "Protect the weak", "Seek adventure" },
Flaws = new[] { "Impulsive", "Over-trusting" }
};
SetupPersonality(profile);
// Optional: LoadBehaviorTree("Assets/BehaviorTrees/BardBehavior.asset");
RunAI();
}
public string RespondToPlayer(string playerPrompt)
{
// This calls NAREONAI.SendConversationPrompt internally,
// which uses the configured AI model (OpenAI/Claude/Llama).
return GenerateDialogue(playerPrompt);
}
}SetupPersonality(...)sets custom traits, ideals, or moods.GenerateDialogue(...)requests an AI-generated response (assuming you calledNAREONAI.ConfigureOpenAI(...)or similar earlier).
2. Dialogue Example
A simple interaction script:
csharpCopyusing UnityEngine;
public class NPCDialogueTrigger : MonoBehaviour
{
public MyPersonalityNPC npc;
public void PlayerTalks()
{
string playerText = "Hello Aria, any stories to share?";
string npcReply = npc.RespondToPlayer(playerText);
Debug.Log($"[NPC]: {npcReply}");
}
}Attach NPCDialogueTrigger to an in-game object, reference the MyPersonalityNPC component in the Inspector, and call PlayerTalks() via a button or event.
3. Combining with Behavior Trees
If you have a custom Behavior Tree solution, you can:
Load the asset in
Start()withLoadBehaviorTree(path).The NPC might adapt its state or dialogue based on mood, trait checks, or triggers.
4. Next Steps
Once you have AI-driven dialogue, check Web3 Tokens to see how to reward your player with tokens or NFTs after certain dialogues or events.
Last updated

