Hello,
In the game i work on there is a textmesh above character that shows its health. I want number in text to reduce one by one every sec when character takes damage but instead health text reduces to the current health of character all of a sudden like time.deltaTime has no effect on the function.
If you could help me on that i would appreciate it. Have a nice day.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class HealthText : MonoBehaviour
{
public WheelFighter fighter;
public TextMeshProUGUI text;
// Start is called before the first frame update
void Start()
{
text.text = fighter.maxHealth.ToString();
}
// Update is called once per frame
void Update()
{
int healthInText = int.Parse(text.text);
if (healthInText > fighter.health)
{
healthInText = (int)(healthInText - 1 * Time.deltaTime);
text.text = healthInText.ToString();
}
}
}