Import the package
Import NPC Memory & Relationship System and wait for Unity to compile.
A modular social brain for Unity NPCs: decaying memories, multi-axis relationships, factions, gossip, complete saving and plug-and-play components with no code required.
GETTING STARTED
Import NPC Memory & Relationship System and wait for Unity to compile.
Go to Tools → NPC Memory System → Setup Wizard and select Create Complete Demo Scene.
Move with WASD, approach an NPC and press E. Try actions and watch dialogue and relationships evolve.
ARCHITECTURE
Add the core components to any GameObject to turn it into an NPC with a social brain.
Add Component → NPC Memory System → NPC Identity
Add Component → NPC Memory System → NPC Brain
Automatic singleton
AIVA.NPCMemorySystem.NPCMemoryAPI
MEMORY
NPCs store tagged memories with a source, strength and timestamp. Important recent memories carry more weight; decay removes memories once they become insignificant.
PLAYER_HELPED_ME → Trust +15, Friendship +10.// Add a memory to an NPC
NPCMemoryAPI.AddMemory("Guard_A", "PLAYER_HELPED_ME", "Player");
// Check whether the NPC remembers it
bool remembers = NPCMemoryAPI.GetNPC("Guard_A")
.MemoryStore.HasMemory("PLAYER_HELPED_ME");
PLAYER_HELPED_MERaises Trust and Friendship.PLAYER_THREATENED_MERaises Fear and lowers Trust.PLAYER_STOLE_FROM_MELowers Trust and Friendship.PLAYER_GIFTED_MERaises Friendship.PLAYER_ATTACKED_MERaises Fear and lowers other axes.PLAYER_SAVED_MEStrong Trust and Respect increase.RELATIONSHIPS
Friendship, Trust, Respect, Fear and Romance evolve independently. Their combination determines the overall state: Hostile, Unfriendly, Neutral, Friendly or Trusted.
string state = NPCMemoryAPI.GetRelationshipState("Guard_A", "Player");
float trust = NPCMemoryAPI.GetRelationshipValue("Guard_A", "Player", "Trust");
FACTIONS
Assign NPCs to factions and propagate the consequences of player actions across entire groups.
OnFactionReputationChanged.float rep = FactionManager.Instance.GetReputation("Player", "Guards");
FactionManager.Instance.ModifyReputation("Player", "Guards", -20f);
SOCIAL
NPCs share memories as rumors. Range, interval, maximum hops and distortion are configurable, allowing information to spread naturally through a social network.
NPC A observes an event and creates a memory.
NPC A meets NPC B and passes the rumor.
NPC B receives it and changes their relationship.
INTERACTION
A plug-and-play bridge between relationship state and gameplay. Configure dialogue for every state and player actions directly in the Inspector.
Unique text for Hostile, Unfriendly, Neutral, Friendly and Trusted states.
Each action has a label, memory tag and cooldown. Trigger quests, prices, doors and game logic through UnityEvents.
VISUAL
Floating name, relationship bar and state label.
Material tint, particle burst and scale punch on state changes.
Enter/loop audio and Animator triggers or booleans per state.
Create memories from colliders, code or Inspector events.
MOVEMENT
Waypoint movement with Loop, PingPong and Random modes. Configure speed, turn rate, arrival distance and wait time; patrol can pause automatically during interaction.
PERSISTENCE
Save and restore all NPC memories, relationship axes, faction reputation and current states.
NPCSaveSystem.Instance.SaveToFile();
NPCSaveSystem.Instance.LoadFromFile();Uses JSON in Application.persistentDataPath.
Implement ISaveProvider for cloud saves, encryption or your existing save framework.
DEVELOPMENT
Use global static events for decoupled systems and per-NPC UnityEvents for Inspector-driven integration.
AddMemory(npcId, tag, source)Add a memory to an NPC.GetRelationshipState(npcId, targetId)Return Hostile, Unfriendly, Neutral, Friendly or Trusted.GetRelationshipValue(npcId, targetId, axis)Return one relationship-axis value.GetNPC(npcId)Return the registered NPCBrain.NPCEvents.OnMemoryAdded += args => Debug.Log(args.Memory.Tag);
NPCEvents.OnRelationshipStateChanged += args => Debug.Log(args.NewState);
NPCEvents.OnRumorReceived += args => Debug.Log(args.ReceiverId);
NPCEvents.OnFactionReputationChanged += args => Debug.Log(args.NewValue);
EDITOR
Inspect and author the system visually with dedicated windows and custom Inspectors.
Live view of memory tags, sources, strength and remaining lifetime.
Node visualization of NPC connections, axes and states.
Create the demo, default ScriptableObjects and wiring in one click.
ARCHITECTURE
SUPPORT
Ensure MemoryImpactDatabase.cs is a standalone file whose name matches the ScriptableObject class.
Use the Setup Wizard. It creates editable scene objects before Play Mode.
Assign the DemoCamera target or tag the player GameObject as “Player”.
Verify NPCBrain configs, Reactor dialogue for each state and matching rules in MemoryImpactDatabase.
NPCStateFeedback needs a Renderer with an assignable material.