From c8b8bec7b3ea533e3b7b0b2db03cc51101deccd6 Mon Sep 17 00:00:00 2001 From: miepzerino <o.skotnik@gmail.com> Date: Tue, 01 Apr 2025 17:04:30 +0000 Subject: [PATCH] #21 added floating ore text --- Assets/Scripts/PlayerFloatingText.cs | 14 +++++++++----- 1 files changed, 9 insertions(+), 5 deletions(-) diff --git a/Assets/Scripts/HealthText.cs b/Assets/Scripts/PlayerFloatingText.cs similarity index 83% rename from Assets/Scripts/HealthText.cs rename to Assets/Scripts/PlayerFloatingText.cs index 4113c69..79f6e9e 100644 --- a/Assets/Scripts/HealthText.cs +++ b/Assets/Scripts/PlayerFloatingText.cs @@ -4,7 +4,7 @@ using TMPro; using UnityEngine; -public class HealthText : MonoBehaviour +public class PlayerFloatingText : MonoBehaviour { // x = oscillation amount (0 = no oscillation), y = upwards speed public Vector3 moveSpeed = new Vector3(25f, 75, 0); @@ -15,8 +15,9 @@ // start fading after x seconds public float startToFade = 1f; private float timeElapsed = 0f; - private float randomStartingPointX; - private float randomStartingPointY; + public bool randomStartingPoint = false; + private float randomStartingPointX = 0f; + private float randomStartingPointY = 0f; private Vector3 startingPosition; RectTransform textTransform; @@ -28,8 +29,11 @@ textMeshPro = GetComponent<TextMeshProUGUI>(); startingPosition = textTransform.position; // add random starting position for text - randomStartingPointX = UnityEngine.Random.value - 0.5f; - randomStartingPointY = UnityEngine.Random.value * 15f; + if (randomStartingPoint) + { + randomStartingPointX = UnityEngine.Random.value - 0.5f; + randomStartingPointY = UnityEngine.Random.value * 15f; + } textTransform.position = new Vector3(textTransform.position.x, textTransform.position.y + randomStartingPointY, textTransform.position.y); } -- Gitblit v1.9.3