Teleporter
A class in Root.Township, the global namespace.
Hand controller extension for pointer teleporting: shows the pointer while the teleport action is held and moves the player there on release. Local player only, and not in auto cam mode.
- Listed in Global namespace: T to X
- Inherits or implements
ControllerExtension
Constructors
| Member | What it is |
|---|---|
Teleporter() | Unity makes components itself; use AddComponent or spawn a prefab instead of new. |
Fields
7 private and internal fields
| Member | What it is |
|---|---|
private CustomTeleportation custom | Custom teleport behaviour on the current target, if any. |
private bool hasStarted | Set once Start has run. |
private Interactor interactor | The controller's interactor, fetched on first use. |
private bool isOverObject | Whether the pointer is over a valid target. |
private bool isShowing | Whether the pointer is showing. |
private Teleporter otherTeleporter | The other hand's teleporter; its teleport is cancelled when this one fires. |
private Pointer pointer | The pointer extension on the same controller. |
Properties
| Member | What it is |
|---|---|
int DirectionSetting { get; set; } | A settable value with no reader in this class. |
1 private and internal property
Events
| Member | What it is |
|---|---|
event Action<Vector3> Departed | Raised with the hand's position when a teleport happens. Plays the depart sound. |
Methods
| Member | What it is |
|---|---|
void AttemptTeleport(PlayerInput controller, bool isDisabling) | Called when the teleport action ends. Teleports if the pointer has a valid target, and cancels the other hand's pointer. |
override void InitializeControllerExtension() | Finds the hand's Pointer and links to the other hand's teleporter once the local player is set. |
void StartShowPointer(PlayerInput controller) | Shows the pointer while teleporting is allowed (not downed, hand free, locomotion not blocked). |
11 private and internal methods
| Member | What it is |
|---|---|
private void CancelTeleport(ControllerActionProxy proxy) | Ends the teleport without moving when the Teleport action is disabled. |
private IEnumerator CheckShowPointer() (iterator) | Coroutine that keeps the teleport pointer shown while the input stays valid. |
private bool CheckValidEndInput() | True if the pointer is showing, the hand is free and the player is alive. |
private bool CheckValidInput() | True if teleporting isn't blocked, Teleport is held, the hand is free and locomotion isn't blocked. |
private void HandleTeleportEnd(bool isAttempting) | Hides the pointer and, if attempting and valid, teleports to the hit point or runs the target's custom teleport. |
private void OnDisable() | Cancels any teleport and unhooks the Teleport action events. |
private void OnEnable() | Hooks the Teleport action events in VR modes, and shows the pointer if the button is already held. |
private void SetupOtherTeleporter() | Finds the other hand's teleporter once the player is linked as local. |
private void Start() | Marks the teleporter as started. |
private void TargetChanged(Pointer pointer, Collider collider, bool isValid) | Ends and begins CustomTeleportation on targets as the pointer moves between colliders. |
private void TeleportStartedSound(Vector3 position) | Plays the teleport depart sound at the given position. |
Used in
Members of other types that take, return or hold a Teleporter: