CompanionManager
SingletonCentral singleton managing all active and stored companions. Add to a persistent GameObject in your scene. Handles summoning, recalling, storage, group commands, and formation updates.
Properties
| Property | Type | Description |
|---|---|---|
| MaxActiveCompanions | int | Maximum companions in scene (from CompanionSettings) |
| ActiveCompanions | List<ICompanionBrain> | Currently active companions (read-only) |
| StoredCompanions | List<CompanionData> | Companions in storage (read-only) |
| ActiveCount | int | Number of active companions |
| CanSummonMore | bool | True if below the MaxActiveCompanions limit |
Methods
SummonCompanion(definition, position, owner) — Spawn and initialize a companion
RecallCompanion(brain, delay?) — Remove companion from scene (optional VFX delay)
RecallAllCompanions() — Recall all active companions
StoreCompanion(brain) — Move companion to storage
RetrieveFromStorage(definition, position, owner) — Spawn a stored companion
GroupSetState(state) — Set all companions to same state
GroupSendCommand(command) — Send command to all (skips unsupported)
GroupSetFormation(formation) — Change formation for all companions
FindActiveByDefinition(definition) — Get brain by definition
IssueCommand(brain, command) — Issue command on a specific brainCompanionBrain
MonoBehaviourThe central component on each companion prefab. Drives state machine, motor control, follow behavior, idle system, bonding, and events. Initialized by CompanionManager on summon.
Properties
| Property | Type | Description |
|---|---|---|
| Definition | CompanionDefinition | The companion species/type |
| CurrentState | CompanionState | Current state (Following, Idle, Waiting, Commanded, etc.) |
| ProximityState | ProximityState | Distance to formation slot (Beside / Near / Far) |
| Owner | ICompanionOwner | The character this companion follows |
| CustomName | string | Display name (overrides definition name) |
| CompanionId | string | Unique runtime identifier |
| IsInitialized | bool | True after Initialize() completes |
| ActiveCommand | CompanionCommand | Currently executing command (or null) |
| BondLevel | float | Current bond 0–1 |
| BondTier | BondTier | Stranger / Familiar / Loyal / Bonded |
| IsOwnerStationary | bool | True when owner hasn't moved for Idle Enter Delay |
| IsVisitingInterestPoint | bool | True when navigating to or at a POI |
| Bonding | BondingBehavior | Bond level management (internal) |
| Events | CompanionEvents | Inspector-wirable UnityEvents |
Methods
SetState(state) — Transition to new state (fires events)
IssueCommand(command) — Execute a command (validates against CommandSet)
SendCommand(command) — Group-safe command (silently skips if unsupported)
CompleteCommand() — Signal command is done, return to Following
SetOwner(owner) — Transfer to a new owner at runtimeCompanionMotor
MonoBehaviourWraps GC2 Character Motion for companion movement. Provides follow, stop, teleport, speed control, gesture, and LookAt via GC2 Facing layers. Added automatically to companion prefabs.
Properties
| Property | Type | Description |
|---|---|---|
| IsReady | bool | True when GC2 Character is resolved |
| IsFollowing | bool | Currently following a target |
| IsMoving | bool | Companion is in motion |
Methods
StartFollow(target, minDist, maxDist) — Follow a Transform via GC2 Motion
StopFollow() — Stop following and halt movement
SetSpeed(speed) — Set movement speed
Teleport(position, rotation) — Instant reposition
LookAt(target) — Face a target via GC2 Facing layer
StopLookAt() — Remove LookAt layer
PlayGesture(clip) — Play animation clip as a gestureCompanionOwnerAdapter
MonoBehaviourAdd to your Player Character to make it a companion owner. Bridges the GC2 Character to the ICompanionOwner interface, providing position, forward direction, and velocity tracking. Auto-added by the Summon instruction if missing.
Properties
| Property | Type | Description |
|---|---|---|
| OwnerTransform | Transform | Owner world transform |
| Forward | Vector3 | Owner facing direction |
| Velocity | Vector3 | Current movement velocity |
CompanionDefinition
ScriptableObjectDefines a companion type — its prefab, display name, follow/idle profile overrides, commands, personality, and reaction profile. Create via Create > Companion System > Companion Definition.
Create via:
Create > Companion System > Companion DefinitionProperties
| Property | Type | Description |
|---|---|---|
| DisplayName | string | Name shown in UI |
| Description | string | Tooltip description |
| Category | CompanionCategory | Pet / Ally / Mount / Summon / Other |
| Icon | Sprite | Portrait for party UI |
| Prefab | GameObject | Companion prefab (needs GC2 Character) |
| Guid | string | Auto-generated unique identifier for save/load |
| FollowProfile | FollowProfile | Override follow profile (falls back to Settings default) |
| IdleBehavior | IdleBehaviorProfile | Idle behavior configuration |
| Personality | CompanionPersonality | Bonding speed and reaction intensity (optional) |
| ReactionProfile | ReactionProfile | Audio/VFX reactions to events (optional) |
| CommandSet | CompanionCommand[] | Available commands for this companion type |
FollowProfile
ScriptableObjectControls follow behavior parameters. Multiple profiles allow different companion types to move differently (e.g., a dog runs faster than a turtle).
Create via:
Create > Companion System > Follow ProfileProperties
| Property | Type | Description |
|---|---|---|
| InnerRadius | float | Stop distance from owner (default: 2m) |
| OuterRadius | float | Run-trigger distance (default: 8m) |
| TeleportRadius | float | Teleport-trigger distance (default: 25m) |
| WalkSpeed | float | Speed when Near proximity |
| RunSpeed | float | Speed when Far proximity |
| AvoidanceRadius | float | Formation spacing between companions |
| FormationOffset | Vector3 | Base offset behind owner |
| StuckTimeout | float | Seconds before stuck recovery (default: 3s) |
Companion Vitals
A standalone health and secondary resource system that works without GC2 Stats. Add CompanionVitals to any companion prefab to enable HP, damage, healing, death, and auto-revive.
CompanionVitals MonoBehaviour
| Property / Method | Description |
|---|---|
| MaxHealth | Maximum health points |
| CurrentHealth | Current health (read-only) |
| HealthPercent | 0–1 fraction of max health |
| IsDead / IsAlive | Death state flags |
| IsInCombat | True when recently damaged (CombatTimeout window) |
| IsInvulnerable | Get/set — blocks all incoming damage |
| ResourceType | None / Mana / Energy / Stamina / Rage |
| CurrentResource / MaxResource | Secondary resource values |
| TakeDamage(amount, source) | Apply damage; returns actual amount dealt |
| Heal(amount, source) | Restore health; returns actual amount healed |
| HealToFull() | Restore health to max |
| Die() / Revive(percent) | Kill or revive at given health percentage |
| SpendResource(amount) | Deduct resource; returns false if insufficient |
| RestoreResource(amount) | Add to secondary resource |
VitalsProfile ScriptableObject
A reusable template for vitals configuration. Assign in CompanionDefinition to apply the same stats to multiple companions of the same type. Create via Create → Companion System → Vitals Profile.
Die() is called, CompanionVitals automatically sets the companion's state to Recalled. On Revive(), it transitions back to Following.Ability System
Companions can have up to 8 ability slots. Each ability is a ScriptableObject defining timing, cost, targeting requirements, and optional GC2 instructions that execute on cast.
CompanionAbility ScriptableObject
Create via Create → Companion System → Ability.
| Section | Properties |
|---|---|
| Identity | AbilityId, DisplayName, Icon, Description |
| Timing | Cooldown (0–300s), CastTime (0=instant), TriggersGCD |
| Cost | ResourceCost, HealthCostPercent |
| Targeting | TargetType (None/Self/Friendly/Enemy/Ground), Range, RequiresLineOfSight |
| Requirements | MinBondTier, RequiresIdle |
| Effects | GC2 InstructionList, AnimationTrigger, CastSound, VFXPrefab |
| Events | OnCastStart, OnCastComplete, OnCooldownEnd (UnityEvents) |
CompanionAbilitySet MonoBehaviour
Add to the companion prefab. Manages 8 slots, GCD, and cast state.
| Property / Method | Description |
|---|---|
| IsCasting | True during a cast (cast time > 0) |
| IsOnGCD | Global cooldown active |
| UseAbility(slot, target) | Attempt to use ability in slot (validates requirements) |
| CanUseAbility(slot, target, out reason) | Check usability without executing |
| SetAbility(slot, ability) | Assign ability to slot |
| ClearSlot(slot) | Remove ability from slot |
| ResetAllCooldowns() | Instantly reset all ability cooldowns |
| CancelCast() | Interrupt current cast |
| GetSlot(index) | Get AbilitySlot runtime state by index |
MinBondTier set above Stranger will fail CanUseAbility until the companion's bond reaches that tier. This creates a natural progression mechanic.Traits System
Traits are permanent modifiers assigned to companions. They apply stat multipliers, grant bonus abilities, and can spawn aura VFX. Use traits to create unique companions — a "Fierce" wolf that deals more damage, or a "Loyal" companion that gains bond faster.
CompanionTrait ScriptableObject
Create via Create → Companion System → Trait.
| Section | Properties |
|---|---|
| Identity | TraitId, DisplayName, Icon, Description, Rarity (Common→Legendary), Category (Combat/Support/Utility/Social) |
| Stat Modifiers | Array of StatModifier (stat type + value). Applied by CompanionTraitHolder. |
| Abilities | BonusAbility (CompanionAbility) + BonusAbilitySlot — granted while trait is active |
| Requirements | MinBondTier, IncompatibleTraits[], RequiredTrait |
| Visual | TraitColor, AuraPrefab (spawned on companion while trait is active) |
| Events | OnAssigned, OnRemoved (UnityEvents) |
CompanionTraitHolder MonoBehaviour
Add to the companion prefab to enable trait assignment.
| Property / Method | Description |
|---|---|
| TraitCount | Number of currently active traits |
| CanAddTrait | True if below MaxTraits limit |
| AssignTrait(trait) | Add trait (validates compatibility and requirements) |
| RemoveTrait(trait) | Remove trait and reverse its effects |
| HasTrait(trait) | Check if a specific trait is active |
| ClearAllTraits() | Remove all traits |
| AssignRandomFromPool(pool) | Pick a weighted random trait from a TraitPool |
| OnTraitAssigned / OnTraitRemoved | C# events fired on trait change |
TraitPool ScriptableObject
A curated list of traits with weighted random selection. Rarity affects weight automatically. Use with the Assign Random Trait instruction to create unique companions on summon. Create via Create → Companion System → Trait Pool.
Target System
A lightweight targeting system that works alongside abilities. The player or game logic selects a target; abilities validate it against their TargetType and range requirements.
TargetManager Singleton
Add to a persistent GameObject alongside CompanionManager (optional — only needed if using the targeting features).
| Property / Method | Description |
|---|---|
| HasTarget | True if a target is currently selected |
| CurrentTargetType | Enemy / Friendly / Neutral / Self |
| SetTarget(targetable) | Select a specific target |
| ClearTarget() | Deselect current target |
| TargetNearest(type, maxRange) | Auto-select the nearest entity of a given type |
| CycleTargets(type) | Tab-cycle through available targets |
| IsTargetInRange(from, range) | Check distance to current target |
| OnTargetChanged | C# event: fires when target changes (prev, current) |
Targetable MonoBehaviour
Add to any GameObject to make it targetable (enemies, allies, companions, objects). Exposes Faction (Player / Enemy / Neutral) and a highlight method called by TargetManager when the entity is selected or deselected.
Personality & Reactions
Two optional ScriptableObjects that bring companions to life. Assign both in the CompanionDefinition.
CompanionPersonality ScriptableObject
Controls bonding speed, reaction frequency, and idle behavior intensity. Create via Create → Companion System → Personality.
| Property | Description |
|---|---|
| BondGrowthRate | Multiplier on all bond gains (0.5 = slow, 2 = fast) |
| PassiveBondPerMinute | Bond gained per minute while near owner |
| BondPerCommand | Bond gained when completing a command |
| BondPerPOI | Bond gained when visiting an interest point |
| Tier thresholds | Bond levels at which Familiar / Loyal / Bonded unlock |
| ReactionCooldown | Minimum seconds between reactions |
| BaseReactionChance | Probability of reacting (scales with bond level) |
ReactionProfile ScriptableObject
Defines what audio clips, gestures, and VFX to play for each reaction trigger. Create via Create → Companion System → Reaction Profile.
Each ReactionEntry maps a trigger type to a random audio clip array, volume, optional gesture, and VFX prefab. Reactions can be gated to specific bond tiers.
OnSummonedOnRecalledOnCommandReceivedOnCommandCompletedOnIdleEnterOnArrivedBesideOwnerOnOwnerSprintOnStuckOnStuckRecoveredOnInterestPointReachedOnBondTierUpOnCompanionJoinedOnCompanionLeftOnGroupAlertInterest Points
Place CompanionInterestPoint in your scene to create locations that idle companions will navigate to and interact with (campfires, fountains, food bowls, etc.).
CompanionInterestPoint MonoBehaviour
| Property | Description |
|---|---|
| InteractionRadius | How close the companion needs to be to interact |
| InteractionDuration | Seconds spent at the point |
| Cooldown | Minimum time before the same companion revisits |
| MaxSimultaneous | Max companions at this point at once |
| PointType | Tag for IdleBehaviorProfile filtering |
Companions also passively "glance" at nearby interest points they haven't visited yet. Bond points are awarded upon a successful POI visit (configured in CompanionPersonality).
IdleBehaviorProfile
ScriptableObject configuring what companions do when idle. Assign to a CompanionDefinition or set a default in CompanionSettings.
| Property | Description |
|---|---|
| InitialDelay | Seconds before idle actions begin after entering Idle state |
| MinInterval / MaxInterval | Random interval between idle actions |
| ActionPool | List of IdleActions to randomly pick from (weighted) |
| EnableInterestPoints | Allow visiting nearby CompanionInterestPoints |
| InterestPointRadius | Search radius for interest points |
| NavigationTimeout | Max seconds to reach a POI before aborting |
CompanionSettings
Project-wide defaults. Access via Tools → Companion System → Settings. The Settings window auto-creates the asset if not found.
| Section | Settings |
|---|---|
| General | Max Active Companions, Debug Logging |
| Follow Defaults | Default Follow Profile, Default Formation (Line/VShape/Circle) |
| Stuck Recovery | Recovery Mode (Repath / SoftTeleport), Fade Duration |
| Traits | Max Traits per companion |