CharacterInteractor
Character component that manages interaction raycasting, interactable detection, highlighting, and interaction triggering. Bridges the character's camera view to the Interaction System.
Definition
Namespace: Paragon.Townskeep.CharacterSystem
Assembly: Townskeep.dll
[Serializable]
public class CharacterInteractor : CharacterComponentInheritance: ParagonComponent<Character> → CharacterComponent → CharacterInteractor
Remarks
CharacterInteractor is a serializable component attached to a Character that handles first-person interaction detection. Each tick, it performs a SphereCastNonAlloc from the character's camera position/direction and maintains a reference to the closest Interactable in view.
Key behaviors:
Raycasting — Uses a sphere cast with 0.05 radius and configurable
Rangeto detect interactables.Highlighting — Automatically highlights/unhighlights interactables when the character (possessed by a
Player) looks at them.Interaction triggering — Delegates to the underlying
Interactorcomponent to start interactions with the viewed interactable.Arm rigs — Exposes
LeftArmRigandRightArmRigfor animation IK during interactions.
Quick Lookup
Try to interact with what's in view
characterInteractor.TryInteractInView(trigger)
Cancel current interaction
characterInteractor.CancelInteraction()
Get the underlying Interactor
characterInteractor.Interactor
Get active interactions
characterInteractor.ActiveInteractions
Check if player-controlled
characterInteractor.HasInputControl()
Properties
Interactor
The underlying Interactor instance that manages active interactions.
ActiveInteractions
All currently active interactions on this character's interactor. Returns null if the interactor is not initialized.
Fields
LeftArmRig
ArmRig
Left arm IK rig for interaction animations
RightArmRig
ArmRig
Right arm IK rig for interaction animations
Range
float
Maximum raycast distance for detecting interactables
Methods
TryInteractInView
Attempts to interact with the interactable currently in the character's view.
trigger
InteractionTrigger
The interaction trigger type (e.g., press, hold)
Does nothing if no interactable is currently in view. On success, unhighlights the interactable if the character is player-possessed.
CancelInteraction
Cancels the first active interaction on this character.
HasInputControl
Returns whether this character is currently possessed by a Player.
Returns: true if the character is player-possessed.
Lifecycle
OnInitialize()
Allocates raycast hit buffer (size 5), initializes the Interactor with the character's GameObject
Tick(dt)
Performs sphere cast, updates interactable-in-view tracking and highlighting
OnDestroy()
Cancels any active interaction
Common Pitfalls
Raycast buffer size is fixed at 5 — Only the 5 closest hits are considered. Dense scenes with many interactables at close range may miss some.
Highlighting is player-only — Highlighting logic only runs when Character.IsPossessedBy<Player>() returns true. NPC characters do not trigger highlights.
Interactable priority is distance-weighted — The "closest" interactable is determined by a dot-product distance metric relative to camera direction, not raw Euclidean distance.
See Also
CharacterInventory — inventory system that triggers carry interactions via this interactor
Interactor / Interactable — core interaction system
Last updated