Skip to main content

NearbyPlayerScaler

A class in Root.Township, the global namespace.

Scales an object up when the local player comes close and down when they move away, and turns on extra behaviours while shown. Client side.

Constructors​

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

Fields​

7 private and internal fields
MemberWhat it is
private float activateDistanceDistance at which the object shows.
private Transform cachedTransformCached transform.
private float deactivateDistanceDistance at which it hides again.
private bool debugViewInspector button flag for DebugView.
private Behaviour[] enabledWhileActivatedBehaviours turned on only while shown.
private float sqrdActivateDistanceactivateDistance squared.
private float sqrdDeactivateDistancedeactivateDistance squared.

Properties​

MemberWhat it is
bool? IsScalingForced { get; set; }When set, forces shown or hidden regardless of distance.

Events​

MemberWhat it is
event Action<bool> OnNearChangedRaised with true when the object shows and false when it hides.

Methods​

MemberWhat it is
void DebugView()Editor button: shows the object.
void SetScale(float progress)Sets the scale from the curve at the given progress and toggles dock visuals.
protected override void Awake()Caches distances, scales to zero and turns off the linked behaviours.
protected override void OnDisable()Hides the object when disabled.
3 private and internal methods
MemberWhat it is
private void LateUpdate()Shows or hides the object by the local player's head distance, or hides it while the player is dead.
private void OnEnable()Sets shown or hidden right away from the current distance.
private void Set(bool isOn)Shows or hides with the scale animation and toggles the linked behaviours.

Used in​

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