using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using TMPro;
|
using UnityEngine;
|
|
public class HealthText : MonoBehaviour
|
{
|
public Vector3 moveSpeed = new Vector3(0, 75, 0);
|
|
public float timeToFade = 1f;
|
public float startToFade = 1f;
|
private float timeElapsed = 0f;
|
|
RectTransform textTransform;
|
|
TextMeshProUGUI textMeshPro;
|
|
private void Awake()
|
{
|
textTransform = GetComponent<RectTransform>();
|
textMeshPro = GetComponent<TextMeshProUGUI>();
|
}
|
|
private void Update()
|
{
|
timeElapsed += Time.deltaTime;
|
if (timeElapsed >= startToFade)
|
{
|
textMeshPro.alpha = (1 - ((timeElapsed - startToFade) / timeToFade));
|
if (timeElapsed >= (startToFade + timeToFade))
|
{
|
Destroy(gameObject);
|
}
|
}
|
textTransform.position += moveSpeed * Time.deltaTime;
|
}
|
}
|