Hello I would like to display text when torpedo colide with obstacle and its working but then after two seconds I want this text to change value to empty string = “”; and this part don’t work.
code looks like this:
IEnumerator OnTriggerEnter(Collider other)
if (other.tag == "Torpedo")
{
Instantiate(explosion, transform.position, transform.rotation);
Destroy(other.gameObject);
Destroy(gameObject);
hoverText = GameObject.FindGameObjectWithTag("buoyText").GetComponent<Text>();
Vector3 newTextPosition = Camera.main.WorldToScreenPoint(this.transform.position);
hoverText.transform.position = newTextPosition;
hoverText.text = scoreValue.ToString();
gameController.AddScore(scoreValue);
gameController.AddCoins(coinsScoreValue);
yield return new WaitForSeconds(2);
hoverText.text = "";
}
Thanks in advance.