Files
Generic/Assets/Scripts/UIDamageIndicator.cs
2025-04-26 21:54:32 +01:00

31 lines
643 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class UIDamageIndicator : MonoBehaviour
{
public TMP_Text damageText;
public float moveSpeed;
public float lifetime = 3f;
private RectTransform myRect;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
Destroy(gameObject, lifetime);
myRect = GetComponent<RectTransform>();
}
// Update is called once per frame
void Update()
{
myRect.anchoredPosition += new Vector2(0f, -moveSpeed * Time.deltaTime);
}
}