File was renamed from Assets/Scripts/HealthText.cs |
| | |
| | | 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); |
| | |
| | | // 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; |
| | |
| | | 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); |
| | | } |
| | | |