Skip to main content

Controller

A class in Root.Township, the global namespace.

One hand of a player: the network behaviour that holds the grip point, the Hand, the input and the controller extensions such as the Interactor. Both sides; reach one through PlayerController.LeftController or RightController.

Constructors​

MemberWhat it is
Controller()Unity makes components itself; use AddComponent or spawn a prefab instead of new.

Fields​

10 private and internal fields
MemberWhat it is
private List<ControllerExtension> allExtensionsUnused list; AllExtensions has its own backing.
private List<ControllerExtension> existingExtensionsExtensions already on the prefab, added to AllExtensions first.
private ControllerExtensionGroup extensionsGroupExtension group added for every player.
private Transform extensionsOnIKHandThe IK hand copy of extensionsGroup, moved by MoveExtensionsObjects.
private Transform gripPointBacking field for GripPoint.
private Hand handBacking field for Hand.
private Interactor interactorCached interactor extension, found on first use.
private ControllerExtensionGroup localExtensionsGroupExtension group added only for the local player (formerly ownedExtensionsGroup).
private NetworkTransform networkTransformCached network transform, found on first use.
private Transform ownedExtensionsOnIKHandThe IK hand copy of localExtensionsGroup, if any.

Properties​

MemberWhat it is
ControllerActionsManagerProxy ActionsManager { get; }Proxy to this hand's input actions; linked to the PlayerInput actions manager on initialize.
List<ControllerExtension> AllExtensions { get; }Every controller extension on this hand, including the ones spawned from extension groups.
CharacterInfo CharacterInfo { get; private set; }The owning player controller's Info.
Transform GripPoint { get; set; }Transform held items attach to; given a kinematic rigidbody at build time.
Hand Hand { get; }The hand model this controller drives.
Interactor Interactor { get; }This hand's Interactor extension, cached on first use.
bool IsLocomotingBlocked { get; set; }Flag set by other code to stop this hand's input driving locomotion.
NetworkTransform NetworkTransform { get; }The NetworkTransform on this hand, cached on first use.
PlayerController PlayerController { get; private set; }The player controller this hand belongs to.
PlayerInput PlayerInput { get; private set; }The input for this hand. Disabled on hands that are not the local player's.

Methods​

MemberWhat it is
T GetControllerExtension<T>()Returns the first extension of the given type, or null with a warning.
void Initialize(PlayerController controller, PlayerInput input)Links the hand to its player controller and input, spawns extension groups (local-only ones only for the local player) and initializes them.
void MoveExtensionsObjects(bool isToMasterHand)Reparents the IK-hand extension objects to the master hand root or the IK hand root.
override void OnConnected(Player player)Calls OnConnectedToPlayer on every extension one frame later.
void TriggerHaptic(float strength, float duration, float frequency = 80)Vibrates this hand's controller, by strength and duration or by a curve. The strength version only acts on clients.
void TriggerHaptic(AnimationCurve curve, float strength = 1, float frequency = 80)Vibrates this hand's controller, by strength and duration or by a curve. The strength version only acts on clients.
bool TryGetHeldPickup(out Pickup pickup)Returns the pickup this hand is holding, if the interactor is holding a Pickup.
4 private and internal methods
MemberWhat it is
private void AddExtension(ControllerExtensionGroup group)Instantiates an extension group twice, once for the ghost hand and once for the IK hand.
private void CreateExtensionObject(ControllerExtensionGroup group, bool isIKHand)Instantiates an extension group under the master or IK hand root, keeping only the components meant for that hand and linking them to this controller.
private void OnDestroy()Unlinks the actions manager and clears the input's target transform if it pointed here.
private bool SetupGripPointRigidbody()Editor apply method: makes sure the grip point has a kinematic rigidbody.

Used in​

Members of other types that take, return or hold a Controller:

CharacterCollisionController.CollidersToDisableWhenInteracting.controller, CharacterCollisionController.CollidersToDisableWhenInteracting.Controller, GhostHandController.controller, GhostHandController.Controller, Hand.controller, Hand.Controller, Hand.SetupWithController, HandStore.HandStore, HandStore.sourceController, LandmarkDebugger.Run, SceneWidgetsAction.Run, Inventory.AddHandItem, PickupDock.TriggerHaptic, PickupDock.TriggerHoverHaptic, QamOptionAsButtonCommand.GetControllerHack, BoneWeightTestsMenuAction.Run, DebugLightMenuAction.Run, DecreaseHeightMenuAction.Run, EmptyMenu.Run, EquipmentModeQuickAccess.Run, MemoryDumpMenuAction.Run, MicMuteQuickAccessAction.Run, MODSMicMuteQuickAccessAction.Run, MuteNonFriendsQuickAccessAction.Run, NestingMenuAction.Run, PhysicsFPSMenuAction.Run, QuickAccessMenuAction.Run, QuickAccessMenuBubble.Run, ReturnToMainMenuAction.Run, SettingsQuickAccessMenu.Run, ShowNames.Run, SummonActionItemQuickAccess.Run, ToggleAccessibleDockMenuAction.Run, ToggleDebugMovementMenuAction.Run, ToggleEnemyHealthBars.Run, ToggleLiveDataDisplayMenuAction.Run, ToggleLocalSpeedMenuAction.Run, ToggleRuntimeConsole.Run, ToggleRuntimeConsole.UpdateConsolePosition, TriggerDebugSetSpawnMenuAction.Run, UpdateFarClipMenuAction.Run, UpdateHeightMenuAction.Run, VivoxConnectionQuickAccessAction.Run, SummonCameraQuickAccess.Run, CharacterInfo.LeftController, CharacterInfo.RightController, ClimberSettings.GetHapticOverUpwardAlignment, ClimberSettings.GetHapticStrengthOverDistance, ControllerExtension.controller, ControllerExtension.Controller, ControllerInputButtonPressed.controller, ControllerMod.RunMod, CustomFixedJoint.Controller, CustomizationPlayerController.SetupController, EmptyJoint.Controller, ClimbingHand.ClimbingHand, ClimbingHand.Controller, HandGestureTrigger.CleanController, HandGestureTrigger.TrackController, HandHandler.Controller and 13 more.