Skip to main content

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.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private CustomTeleportation customCustom teleport behaviour on the current target, if any.
private bool hasStartedSet once Start has run.
private Interactor interactorThe controller's interactor, fetched on first use.
private bool isOverObjectWhether the pointer is over a valid target.
private bool isShowingWhether the pointer is showing.
private Teleporter otherTeleporterThe other hand's teleporter; its teleport is cancelled when this one fires.
private Pointer pointerThe pointer extension on the same controller.

Properties​

MemberWhat it is
int DirectionSetting { get; set; }A settable value with no reader in this class.
1 private and internal property
MemberWhat it is
private Collider LastColliderHit { get; set; }The collider the pointer last hit, to detect target changes.

Events​

MemberWhat it is
event Action<Vector3> DepartedRaised with the hand's position when a teleport happens. Plays the depart sound.

Methods​

MemberWhat 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
MemberWhat 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: