Skip to main content

ControllerExtension

An abstract class in Root.Township, the global namespace.

Base for a component that adds behaviour to a player's hand controller, placed under the ghost hand or the IK hand. Runs on every copy of the player; IsLocal tells you if it's yours.

Constructors​

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

Fields​

4 private and internal fields
MemberWhat it is
private PlayerMode activeForPlayer modes (VR runtimes such as OpenVR, Oculus or OpenXR, or fly and auto cam) this extension runs in; it destroys itself otherwise.
private Controller controllerThe controller this extension is on, found in the parents. Backing field for Controller.
private NetworkEntity entityThe player entity; set from the controller on initialize. Backing field for Entity.
private bool isAddedToIKHandWhether the extension goes under the IK hand instead of the ghost hand. Backing field for IsAddedToIKHand.

Properties​

MemberWhat it is
ControllerActionsManagerProxy Actions { get; }The controller's action manager, for reading input actions such as interact.
CharacterInfo CharacterInfo { get; private set; }The character info of the controller's player, set in InitializeControllerExtension.
Controller Controller { get; set; }The hand controller this extends. Found in parents on first use; can only be set once.
NetworkEntity Entity { get; }The player's network entity, taken from the controller on init.
PlayerInput Input { get; }The controller's PlayerInput.
bool IsAddedToIKHand { get; }True if the extension belongs under the IK hand instead of the ghost hand.
bool IsLocal { get; private set; }True if the controller belongs to the local player.
protected bool IsInteractFree { get; }True if the hand can interact now: locomotion is not blocked and it is not busy with an interaction.

Methods​

MemberWhat it is
virtual void InitializeControllerExtension()Copies the character info, entity and local-player flag from the controller.
virtual void OnConnectedToPlayer(Player player)Hook called when the extension is connected to a player. Does nothing by default.
protected virtual void Awake()Destroys the component if the current XR mode is not in its activeFor flags.

Used in​

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