So guys, I am trying to reproduce an effect from a game where when an enemy gets hit, the damage pops up above them for just a brief second. I made a text mesh pro text box, made it a prefab and made a script that takes this prefab ( the enemy script ) …
When I take damage, I instantiate the TMPUI right above the enemy with the damage … this all seems to work. From the SS below, you can see in the Hierarchy that I am getting TMP clones and if you look at the scene view you will see them above enemies… but in game, you never see the text.
If I pause and inspect these clones they even have the damage set as their text value. Any ideas?
private void ShowDamageText(int damage)
{
Vector3 damageTextPosition = transform.position + new Vector3(0f, 1.5f, 0f); // Adjust the Y value as needed
TextMeshProUGUI damageText = Instantiate(damageTextPrefab, damageTextPosition, Quaternion.identity);
damageText.text = damage.ToString();
Destroy(damageText.gameObject, 5.0f); //made it 5 seconds just to see if I could see it...
}