Skip to main content

Pointer

A class in Root.Township, the global namespace.

The teleport arc on a hand. Each frame it traces a curved arc from the hand, finds where it lands and whether the player may teleport there, and draws the arc and target. Client, local player.

Constructors​

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

Fields​

58 private and internal fields
MemberWhat it is
private readonly int _ProgressShader id of the _Progress property, used to show charge progress.
private readonly int _TintColorShader id of the _TintColor property, used for valid or invalid colour.
private float arcGravityGravity used to bend the arc (default 9.8), scaled by player size.
private Material baseMaterialMaterial the teleporter arc and target are copied from.
private Material baseMaterialAndroidAndroid version of baseMaterial. Not read in this build.
private float baseRotationLerpBase lerp for turning the target to the new surface normal.
private LayerMask blockageMaskLayers that stop the arc without being standable.
private Vector2 climbingOffsetOffset for climb teleports. Not read in this class.
private Color currentValidColorValid arc colour in use, changed by hunger level.
private float distanceRotationLerpExtra rotation lerp per unit the target moved this frame.
private float fadedAlphaArc alpha at full fade.
private float fadeEndAngleAim pitch at which the arc is fully faded and no longer traced (default 60).
private float fadeStartAngleAim pitch at which the arc starts to fade (default 45).
private HungerStat hungerDefinitionHunger stat whose level picks the arc colour.
private Pointer.HungerMaterial[] hungerMaterialsArc colours per hunger level.
private Dictionary<int, Color> hungerMaterialSetHunger level to arc colour lookup, built in Start.
private Renderer[] intervalObjectsSpawned arc piece renderers.
private Vector3[] intervalPointsArc points from the last trace.
private Renderer intervalPrefabPrefab for one arc piece.
private Renderer intervalPrefabAndroidAndroid version of intervalPrefab. Not read in this build.
private int intervalsToSkipNumber of arc points near the hand that aren't shown.
private float intervalTimeTime step between arc points (default 0.2).
private Color invalidColorArc colour when the spot can't be teleported to.
private bool isLimitingTeleportRadiusBacking field for IsLimitingTeleportRadius.
private bool isValidWhether the current landing spot is valid.
private int lastActiveIntevalIndex of the last arc piece shown, from the previous frame.
private bool lastValidisValid from the previous frame, for detecting changes.
private float limitRadiusSquaredBacking field for LimitRadiusSquared.
private float maxAngleForClimbTeleportDot limit for climb teleports. Not read in this class.
private float maxAngleForTeleportSteepest surface, in degrees, the player can teleport onto (default 30).
private float maxDistanceDownFurthest drop below the hand a valid landing can be, scaled by player size.
private float maxDistanceUpHighest rise above the hand a valid landing can be, scaled by player size.
private int maximumIntervalsMost arc points traced (default 100).
private float minimumTimeSeconds the pointer must be held before a teleport is valid. Below 0 means no wait.
private float minimumVelocityLowest arc speed.
private Vector3 oldNormalTarget normal from the previous frame, for smoothing.
private Vector3 oldPositionTarget position from the previous frame, for smoothing.
private Transform originTransform the arc starts from and the pieces are parented to.
private PlayerController playerControllerThe player this pointer belongs to.
private LayerMask playerPersonalSpaceLayer of other players' personal space. The arc slides off it to land beside them.
private float positionLerpLerp for moving the target to the new spot.
private RaycastHit previousHitHit from the last trace, exposed as Hit.
private PooledObject readyEffectPooled effect shown when the charge completes.
private PooledObjectDefinition readyEffectDefinitionPool definition for the ready effect.
private PooledObjectDefinition readyEffectDefinitionAndroidAndroid version of readyEffectDefinition. Not read in this build.
private LayerMask standableMaskLayers the player can land on, unless the current unlock overrides teleport layers.
private MaterialGroup targetObjectSpawned landing target.
private MaterialGroup targetPrefabPrefab for the landing target.
private MaterialGroup targetPrefabAndroidAndroid version of targetPrefab. Not read in this build.
private LayerMask teleportAwareTriggerMaskLayers checked for teleport aware triggers along the arc.
private float teleportDistanceMultiplierWhileHoldingArc speed multiplier while the hand holds something (default 0.5).
private Material teleporterMaterialMaterial copy for the arc and target, tinted each frame.
private HashSet<ITeleportAwareTrigger> triggersPassedThroughBacking field for TriggersPassedThrough.
private PlayerUnlockManager unlockManagerPlayer's unlock manager, checked for teleport layer overrides.
private Color validColorArc colour for a valid spot when hunger doesn't change it.
private AnimationCurve velocityCurveArc speed over seconds held. Longer holds reach further.
private float velocityTimeSeconds the pointer has been active, used for arc speed and charge.
private bool wasReadyWhether the ready effect has played for this charge.

Properties​

MemberWhat it is
RaycastHit Hit { get; }The raycast hit where the arc landed last frame.
bool IsAgedEnough { get; }True once the arc has been held for at least the minimum time.
bool IsLimitingTeleportRadius { get; set; }When true, targets farther than LimitRadiusSquared from LimitCenter are invalid.
bool IsTargetShowing { get; set; }Whether the landing target marker is drawn. True by default.
bool IsValidTeleport { get; }True if the current landing spot is valid and the arc has been held long enough.
Vector3 LimitCenter { get; set; }Centre for the teleport radius limit. Character customization sets it to its own position.
float LimitRadiusSquared { get; set; }Squared radius for the teleport limit.
AnimationCurve OverrideVelocityCurve { get; set; }Settable velocity curve. Not read anywhere in this build; the arc uses its own curve.
LayerMask StandableMask { get; }Layers the player can teleport onto. The current unlock can override it.
HashSet<ITeleportAwareTrigger> TriggersPassedThrough { get; }Teleport-aware triggers the arc passed through this frame.
1 private and internal property
MemberWhat it is
private float MaxDotToTeleport { get; set; }Lowest surface normal y a landing spot may have, worked out from maxAngleForTeleport.

Events​

MemberWhat it is
event PointerEventHandler TargetChangedRaised when the landing collider or its validity changes.

Methods​

MemberWhat it is
protected override void Awake()Makes the arc material and reads the max teleport angle and the player's unlock manager.
9 private and internal methods
MemberWhat it is
private Vector3 GetPosition(float time, Vector3 forward, float velocity)Offset along the teleport arc at a given time, from the aim direction, speed and gravity, scaled by player size.
private void LateUpdate()Each frame, traces the teleport arc, checks whether the landing spot is valid, places the arc pieces and target, and raises TargetChanged.
private void OnDestroy()Cleans up the teleporter material copy.
private void OnDisable()Hides the arc, target and ready effect, resets the charge time and raises TargetChanged with no target.
private void OnDrawGizmosSelected()Editor: draws a line down from the pointer, coloured by whether the ground below could be teleported to.
private void OnTargetChanged(Collider collider, bool isValid)Raises TargetChanged.
private void Start()Sets up hunger colours and spawns the arc pieces and target object under the origin.
private void TryFindTeleportAwareTriggers(Vector3 oldPoint, Vector3 newPoint, LayerMask mask, RaycastHit hit)Adds any teleport aware trigger crossed by one arc segment to TriggersPassedThrough.
private void UpdateHunger(Stat stat)Picks the valid arc colour for the player's current hunger level.

Used in​

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