Skip to main content

TextPopup

A class in Root.Township, Alta.Utilities.

Client: pooled floating text that drifts upward, faces the local player's head and scales with distance. It switches itself off beyond maxDistance and back on when the player comes close. DamagePopup extends it.

Constructors​

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

Fields​

5 private and internal fields
MemberWhat it is
private LocomotionController locomotionControllerThe local player's locomotion controller, used to detect when they come back in range.
private float maxDistanceSquared distance beyond which the popup stops updating. Set as 10 metres in the inspector.
private AnimationCurve scaleBasedOnDistanceCurve mapping distance to the head onto the popup's scale.
private Text textUI text component that shows the message.
private float upSpeedHow fast the popup rises, in metres per second.

Properties​

MemberWhat it is
PooledObject PooledObject { get; set; }The pooled object this popup belongs to. The popup stops updating once it is released.
1 private and internal property
MemberWhat it is
private Transform LocalPlayerHead { get; set; }The local player's head transform the popup faces.

Methods​

MemberWhat it is
void UpdateText(string textToDisplay)Sets the text, in red unless a colour is given.
void UpdateText(string textToDisplay, Color color)Sets the text, in red unless a colour is given.
5 private and internal methods
MemberWhat it is
private void Awake()Gets the pooled object and the local player's head, and hooks local player changes.
private void CheckEnabled(PlayerController player, Vector3 oldPosition, Vector3 newPosition, LocomotionFunction function)Locomotion handler: re-enables the popup once the player moves within range.
private void OnDestroy()Unhooks the locomotion and local player events.
private void Update()Moves the text up, turns it to face the head and scales it, or disables itself when the player is too far.
private void UpdateHead(PlayerController player)Takes the head and locomotion controller of a newly set local player.

Used in​

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