Companion System

v2.0.0

Components

Complete reference for all CPS components, ScriptableObjects, and MonoBehaviours

Convention: Components marked Singleton need exactly one instance in the scene. ScriptableObject assets are created via the Project context menu. MonoBehaviour components are added to GameObjects.

CompanionManager

Singleton

Central 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

PropertyTypeDescription
MaxActiveCompanionsintMaximum companions in scene (from CompanionSettings)
ActiveCompanionsList<ICompanionBrain>Currently active companions (read-only)
StoredCompanionsList<CompanionData>Companions in storage (read-only)
ActiveCountintNumber of active companions
CanSummonMoreboolTrue 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 brain

CompanionBrain

MonoBehaviour

The central component on each companion prefab. Drives state machine, motor control, follow behavior, idle system, bonding, and events. Initialized by CompanionManager on summon.

Properties

PropertyTypeDescription
DefinitionCompanionDefinitionThe companion species/type
CurrentStateCompanionStateCurrent state (Following, Idle, Waiting, Commanded, etc.)
ProximityStateProximityStateDistance to formation slot (Beside / Near / Far)
OwnerICompanionOwnerThe character this companion follows
CustomNamestringDisplay name (overrides definition name)
CompanionIdstringUnique runtime identifier
IsInitializedboolTrue after Initialize() completes
ActiveCommandCompanionCommandCurrently executing command (or null)
BondLevelfloatCurrent bond 0–1
BondTierBondTierStranger / Familiar / Loyal / Bonded
IsOwnerStationaryboolTrue when owner hasn't moved for Idle Enter Delay
IsVisitingInterestPointboolTrue when navigating to or at a POI
BondingBondingBehaviorBond level management (internal)
EventsCompanionEventsInspector-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 runtime

CompanionMotor

MonoBehaviour

Wraps 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

PropertyTypeDescription
IsReadyboolTrue when GC2 Character is resolved
IsFollowingboolCurrently following a target
IsMovingboolCompanion 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 gesture

CompanionOwnerAdapter

MonoBehaviour

Add 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

PropertyTypeDescription
OwnerTransformTransformOwner world transform
ForwardVector3Owner facing direction
VelocityVector3Current movement velocity

CompanionDefinition

ScriptableObject

Defines 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 Definition

Properties

PropertyTypeDescription
DisplayNamestringName shown in UI
DescriptionstringTooltip description
CategoryCompanionCategoryPet / Ally / Mount / Summon / Other
IconSpritePortrait for party UI
PrefabGameObjectCompanion prefab (needs GC2 Character)
GuidstringAuto-generated unique identifier for save/load
FollowProfileFollowProfileOverride follow profile (falls back to Settings default)
IdleBehaviorIdleBehaviorProfileIdle behavior configuration
PersonalityCompanionPersonalityBonding speed and reaction intensity (optional)
ReactionProfileReactionProfileAudio/VFX reactions to events (optional)
CommandSetCompanionCommand[]Available commands for this companion type

FollowProfile

ScriptableObject

Controls 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 Profile

Properties

PropertyTypeDescription
InnerRadiusfloatStop distance from owner (default: 2m)
OuterRadiusfloatRun-trigger distance (default: 8m)
TeleportRadiusfloatTeleport-trigger distance (default: 25m)
WalkSpeedfloatSpeed when Near proximity
RunSpeedfloatSpeed when Far proximity
AvoidanceRadiusfloatFormation spacing between companions
FormationOffsetVector3Base offset behind owner
StuckTimeoutfloatSeconds 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 / MethodDescription
MaxHealthMaximum health points
CurrentHealthCurrent health (read-only)
HealthPercent0–1 fraction of max health
IsDead / IsAliveDeath state flags
IsInCombatTrue when recently damaged (CombatTimeout window)
IsInvulnerableGet/set — blocks all incoming damage
ResourceTypeNone / Mana / Energy / Stamina / Rage
CurrentResource / MaxResourceSecondary 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
Inspector settings: MaxHealth, HealthRegen, RegenOutOfCombatOnly, ResourceType, MaxResource, ResourceRegen, CombatTimeout, DisableOnDeath, AutoReviveTime.

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.

Death & State: When 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.

SectionProperties
IdentityAbilityId, DisplayName, Icon, Description
TimingCooldown (0–300s), CastTime (0=instant), TriggersGCD
CostResourceCost, HealthCostPercent
TargetingTargetType (None/Self/Friendly/Enemy/Ground), Range, RequiresLineOfSight
RequirementsMinBondTier, RequiresIdle
EffectsGC2 InstructionList, AnimationTrigger, CastSound, VFXPrefab
EventsOnCastStart, OnCastComplete, OnCooldownEnd (UnityEvents)

CompanionAbilitySet MonoBehaviour

Add to the companion prefab. Manages 8 slots, GCD, and cast state.

Property / MethodDescription
IsCastingTrue during a cast (cast time > 0)
IsOnGCDGlobal 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
Bond Gate: Abilities with a 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.

SectionProperties
IdentityTraitId, DisplayName, Icon, Description, Rarity (Common→Legendary), Category (Combat/Support/Utility/Social)
Stat ModifiersArray of StatModifier (stat type + value). Applied by CompanionTraitHolder.
AbilitiesBonusAbility (CompanionAbility) + BonusAbilitySlot — granted while trait is active
RequirementsMinBondTier, IncompatibleTraits[], RequiredTrait
VisualTraitColor, AuraPrefab (spawned on companion while trait is active)
EventsOnAssigned, OnRemoved (UnityEvents)
Rarity colors: Common (gray) · Uncommon (green) · Rare (blue) · Epic (purple) · Legendary (orange)

CompanionTraitHolder MonoBehaviour

Add to the companion prefab to enable trait assignment.

Property / MethodDescription
TraitCountNumber of currently active traits
CanAddTraitTrue 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 / OnTraitRemovedC# 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 / MethodDescription
HasTargetTrue if a target is currently selected
CurrentTargetTypeEnemy / 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
OnTargetChangedC# 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.

PropertyDescription
BondGrowthRateMultiplier on all bond gains (0.5 = slow, 2 = fast)
PassiveBondPerMinuteBond gained per minute while near owner
BondPerCommandBond gained when completing a command
BondPerPOIBond gained when visiting an interest point
Tier thresholdsBond levels at which Familiar / Loyal / Bonded unlock
ReactionCooldownMinimum seconds between reactions
BaseReactionChanceProbability 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.

OnSummonedOnRecalledOnCommandReceivedOnCommandCompletedOnIdleEnterOnArrivedBesideOwnerOnOwnerSprintOnStuckOnStuckRecoveredOnInterestPointReachedOnBondTierUpOnCompanionJoinedOnCompanionLeftOnGroupAlert
System Triggers: Summoned, Recalled, Stuck, Command, and BondTierUp reactions always fire regardless of bond level — they're functional feedback. Ambient reactions (IdleEnter, ArrivedBeside, OwnerSprint) scale with bond level and personality frequency.

Interest 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

PropertyDescription
InteractionRadiusHow close the companion needs to be to interact
InteractionDurationSeconds spent at the point
CooldownMinimum time before the same companion revisits
MaxSimultaneousMax companions at this point at once
PointTypeTag 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.

PropertyDescription
InitialDelaySeconds before idle actions begin after entering Idle state
MinInterval / MaxIntervalRandom interval between idle actions
ActionPoolList of IdleActions to randomly pick from (weighted)
EnableInterestPointsAllow visiting nearby CompanionInterestPoints
InterestPointRadiusSearch radius for interest points
NavigationTimeoutMax 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.

SectionSettings
GeneralMax Active Companions, Debug Logging
Follow DefaultsDefault Follow Profile, Default Formation (Line/VShape/Circle)
Stuck RecoveryRecovery Mode (Repath / SoftTeleport), Fade Duration
TraitsMax Traits per companion