I have 3D text in my scene and I want it to get destroyed or deactivated after 5 seconds from when the game starts.
How would I do this? (If you reply with code, please state if it is javascript or C#)
Thanks in advance
I have 3D text in my scene and I want it to get destroyed or deactivated after 5 seconds from when the game starts.
How would I do this? (If you reply with code, please state if it is javascript or C#)
Thanks in advance
Using coroutines is one possibility.
If you’re using C# for your game manager script, you could declare a public GameObject property that you would link the Text Mesh via Inspector.
public GameObject gameObject;
Your game manager’s Start method would like
void Start () {
StartCoroutine(DeleteObject(gameObject, 5.0f));
}
which would call the following co-routine:
IEnumerator DeleteObject (GameObject obj, float t)
{
yield return new WaitForSeconds (t);
Destroy (obj);
}