using System.Collections; using System.Collections.Generic; using UnityEngine; using TMPro; public class DamageText : MonoBehaviour { public float moveSpeed;// text 이동속도 public float alphaSpeed;// 투명도 변환속도 public float destroyTime;// 파괴속도 TextMeshPro text; Color alpha; public float damage; void Start() { text = GetComponent(); text.text = damage.ToString(); alpha = text.color; Invoke("DestroyObject", destroyTime); } void Update() { transform.Translate(new Vector3(0, moveSpeed * Time.deltaTime, 0)); alpha.a = Mathf.Lerp(alpha.a,0,Time.deltaTime*alphaSpeed); text.color = alpha; } private void DestroyObject() { Destroy(gameObject); } }