Relationship System

v1.1.0

Component Reference

Complete reference for all Relationship System components and their APIs.

Overview

This page documents all components in the Relationship System. Use this as your API documentation when implementing relationships.

Note: All components integrate seamlessly with Game Creator 2 visual scripting. No C# coding required for basic usage.
Core

Essential components

ScriptableObject

Data assets

Scene Component

Scene-based

Persistence

Save/load

v1.1

New in v1.1

RelationshipManager

CoreCentral singleton facade managing all relationship operations. Delegates to 11 internal subsystems (EntityRegistry, RelationshipStore, RelationshipResolver, DecayProcessor, ModifierProcessor, InheritancePropagator, HistoryTracker, CapProcessor, DiplomacyManager, RuntimeFactionRegistry, RelationshipEventBus).

Create: Add Component → Relationship System → Relationship Manager

Properties

PropertyTypeDescription
m_DebugLoggingboolEnable console debug logging
m_EnableDecayProcessingboolProcess decay for relationships with decay enabled
m_LogLevelRelationshipLogLevelControls which log messages are printed (Error/Warning/Info/Debug)
m_DefaultDefinitionRelationshipDefinitionFallback definition when no faction or override definition exists
m_PendingTimeoutfloatTimeout in seconds for pending relationships (-1 = no timeout)
m_DecayIntervalfloatSeconds between decay ticks (higher = better performance)

Methods

RegisterEntity(IRelationshipEntity entity)
UnregisterEntity(string entityId)
GetRelationship(string entityAId, string entityBId)
GetRelationship(string entityAId, string entityBId, RelationshipDefinition def)
GetRelationshipValue(string entityAId, string entityBId)
GetRelationshipLevel(string entityAId, string entityBId)
ModifyRelationship(string entityAId, string entityBId, float delta)
ModifyRelationship(string entityAId, string entityBId, float delta, RelationshipDefinition def)
ModifyRelationship(string entityAId, string entityBId, float delta, string source)
SetRelationship(string entityAId, string entityBId, float value)
SetRelationship(string entityAId, string entityBId, float value, RelationshipDefinition def)
LockRelationship(string entityAId, string entityBId)
UnlockRelationship(string entityAId, string entityBId)
CreateEntityOverride(string entityAId, string entityBId, RelationshipDefinition def)
CreateScopedEntityOverride(string entityAId, string entityBId, RelationshipDefinition def)
AddModifier(RelationshipModifier modifier)
RemoveModifier(string modifierId)
AddCap(string entityAId, string entityBId, RelationshipCap cap)
RemoveCap(string entityAId, string entityBId, string capId)
GetHistory(string entityAId, string entityBId)
GetRecentHistory(string entityAId, string entityBId, int count)
GetAllRelationships()
ClearAllRelationships()

CharacterRelationship

CoreMakes a GameObject a relationship participant. Implements IRelationshipEntity, IRelationshipTarget, and IFactionMember. Uses stable entity IDs for reliable save/load.

Create: Add Component → Relationship System → Character Relationship

Properties

PropertyTypeDescription
m_IdModeEntityIdModeID generation mode: Manual, GenerateFromName, or RuntimeAssigned
m_CharacterIdstringStable unique identifier for this entity
m_CharacterNamestringDisplay name for this character
m_CharacterIconSpriteIcon representing this character
m_FactionsList<Faction>Factions this character belongs to (first = primary)
m_AutoRegisterboolAuto-register with RelationshipManager on Start
m_AutoAssignFromTagsboolAuto-process faction tags on Start

Methods

Register()
Unregister()
SetEntityId(string entityId)
GenerateDeterministicId()
HasLegacyId()
HasValidId
AddToFaction(Faction faction)
RemoveFromFaction(Faction faction)
BelongsToFaction(Faction faction)
GetFactions()
GetRelationshipWith(IRelationshipEntity other)
ModifyRelationshipWith(IRelationshipEntity other, float delta)
SetRelationshipWith(IRelationshipEntity other, float value)

RelationshipDefinition

ScriptableObjectTemplate defining relationship behavior: value ranges, levels, symmetry mode, decay settings, history tracking, and stat modifiers.

Create: Assets → Create → Relationship System → Relationship Definition

Properties

PropertyTypeDescription
displayNamestringHuman-readable name
minValuefloatMinimum relationship value (absolute clamp)
maxValuefloatMaximum relationship value (absolute clamp)
startingValuefloatInitial value for new relationships
levelsList<RelationshipLevel>Named tiers with thresholds and actions
isSymmetricboolIf true A↔B (default). If false, A→B ≠ B→A
enableDecayboolEnable automatic value decay
decayModeDecayModeLinear, Curve, or Asymmetric decay
decayRatefloatDecay per second (Linear mode)
decayTargetfloatTarget value for decay
decayCurveAnimationCurveCustom curve for Curve mode
decayRatePositivefloatDecay rate above target (Asymmetric mode)
decayRateNegativefloatDecay rate below target (Asymmetric mode)
enableHistoryboolEnable change history tracking
maxHistoryEntriesintCircular buffer size for history
statModifiersList<StatModifier>GC2 Stats integration (optional)

Methods

GetLevelForValue(float value)
ClampValue(float value)
Validate()
GetRelationshipId()
IsDirectional (property)

Faction

ScriptableObjectDefines a group that characters can belong to. Supports hierarchical structures with parent/child relationships and configurable inheritance rates.

Create: Assets → Create → Relationship System → Faction

Properties

PropertyTypeDescription
factionNamestringDisplay name for the faction
factionIconSpriteIcon representing this faction
descriptionstringDescription text for UI
parentFactionFactionParent in hierarchy (null = root)
autoAssignTagsList<string>Auto-assign entities with these tags
inheritanceRatefloat0-1 multiplier for parent relationship inheritance
dynamicInheritanceboolResolve inheritance at runtime (vs bake at start)
propagateToChildrenPropagationModeHow changes propagate to child factions
defaultRelationshipDefinitionRelationshipDefinitionDefault definition for faction relationships

Methods

GetHierarchyDepth()
GetAncestors()
IsDescendantOf(Faction other)
EntityId (property)
EntityName (property)

RuntimeFaction

RuntimeDynamically created faction for player guilds, procedural content, or multiplayer. Created via RelationshipManager.CreateRuntimeFaction(). Fully serializable.

Create: Code: RelationshipManager.Instance.CreateRuntimeFaction(...)

Properties

PropertyTypeDescription
FactionNamestringDisplay name (set at creation)
ParentFactionFactionOptional parent for inheritance
InheritanceRatefloatInheritance multiplier from parent
EntityIdstringAuto-generated stable ID
MembersList<string>Entity IDs of current members

Methods

AddMember(string entityId)
RemoveMember(string entityId)
HasMember(string entityId)
GetMemberCount()

RelationshipInstructions

Scene ComponentDefines a set of GC2 instructions to execute when a relationship reaches a specific level. Attached to entities for level-based behaviors.

Create: Add Component → Relationship System → Relationship Instructions

Properties

PropertyTypeDescription
m_TargetEntityPropertyGetGameObjectThe other entity in the relationship
m_DefinitionRelationshipDefinitionWhich definition to monitor
m_TargetLevelRelationshipLevelLevel that triggers execution
m_InstructionsInstructionListGC2 Instructions to execute
m_ExecuteOnceboolOnly execute once per level transition
m_ExecuteOnEnterboolExecute when entering level
m_ExecuteOnExitboolExecute when exiting level

Methods

Execute(Args args)
ResetExecutionState()

RelationshipInstructionManager

CoreManages execution of RelationshipInstructions across the scene. Subscribes to level change events and dispatches to appropriate instruction components.

Create: Add Component → Relationship System → Relationship Instruction Manager

Properties

PropertyTypeDescription
m_AutoDiscoverboolAuto-find RelationshipInstructions in scene
m_DebugLoggingboolLog instruction executions

Methods

RegisterInstructions(RelationshipInstructions instructions)
UnregisterInstructions(RelationshipInstructions instructions)
RefreshInstructions()

RelationshipEventListener

Scene ComponentBridges RelationshipManager events to Unity Events. Filter by entity, faction, or definition. Use for UI updates, audio, VFX triggers.

Create: Add Component → Relationship System → Event Listener

Properties

PropertyTypeDescription
m_EnableValueChangedboolListen for value change events
m_EnableLevelChangedboolListen for level change events
m_ListenToAllboolListen to all relationships (vs filtered)
m_FilterEntityAPropertyGetGameObjectFilter by Entity A
m_FilterEntityBPropertyGetGameObjectFilter by Entity B
m_FilterDefinitionRelationshipDefinitionFilter by definition
m_OnValueChangedUnityEventUnityEvent<float,float>Invoked with (oldValue, newValue)
m_OnLevelChangedUnityEventUnityEvent<string,string>Invoked with (oldLevel, newLevel)

AutoHostility

Scene ComponentAutomatically triggers combat when relationship falls below threshold. Requires GC2 Characters module. Checks at configurable intervals.

Create: Add Component → Relationship System → Auto Hostility

Properties

PropertyTypeDescription
m_HostilityThresholdfloatRelationship value below which entity becomes hostile
m_CheckIntervalfloatSeconds between hostility checks
m_TargetTagstringOnly check entities with this tag (empty = all)
m_AttackRangefloatMaximum distance to trigger attack
m_DebugLoggingboolLog hostility triggers

Methods

ForceCheck()
SetEnabled(bool enabled)

RelationshipRemember

PersistenceIntegrates with GC2 Remember system for save/load. Serializes all relationships, modifiers, caps, faction memberships, and runtime factions.

Create: Add Component → Relationship System → Relationship Remember

Properties

PropertyTypeDescription
m_SaveRelationshipsboolInclude relationships in save data
m_SaveModifiersboolInclude active modifiers in save data
m_SaveCapsboolInclude caps in save data
m_SaveFactionMembershipsboolInclude faction memberships
m_SaveRuntimeFactionsboolInclude runtime-created factions
m_SaveDiplomacyStatesboolInclude diplomacy states
m_DebugLoggingboolLog save/load operations

CapRegistrar

NEW

Scene ComponentVisual component for registering relationship caps without code. Supports GC2 PropertyGet for entity references. Caps use directional clamping (only prevent crossing boundaries).

Create: Add Component → Relationship System → Cap Registrar

Properties

PropertyTypeDescription
m_EntityAPropertyGetGameObjectFirst entity in the relationship (GC2 PropertyGet)
m_EntityBPropertyGetGameObjectSecond entity in the relationship (GC2 PropertyGet)
m_DefinitionRelationshipDefinitionOptional definition scope for multi-dimensional relationships
m_CapIdstringUnique identifier for this cap (for later removal)
m_SourcestringDisplay name for cap source (e.g., 'Guild Quest')
m_UseMinCapboolEnable minimum value cap
m_MinValuefloatMinimum value (directional: prevents dropping below)
m_UseMaxCapboolEnable maximum value cap
m_MaxValuefloatMaximum value (directional: prevents rising above)
m_AutoRegisterboolAutomatically register cap on Start
m_AutoUnregisterboolAutomatically unregister cap on OnDestroy

Methods

RegisterCap()
UnregisterCap()
UpdateCap()
IsRegistered (property)