How can i make Text appear when i collide with a trigger??

I’m Currently working on a game and can’t figure out how to fade in text when i step on a trigger of some sort then have it stay there for a second or two then fade out. Any help would be greatly appreciated!

I would create the animation for the fade, attach it to your text object. Then use something like this attached to the triggering object (don’t forget to add a collider and check “Is Trigger”). Not tested, but this is something for you to start with I guess… If this text will be occurring fairly regularly I advise object pooling for performance reasons.

public class Trigger : MonoBehaviour
{
    public GameObject fadeInText; //Drag prefab via inspector

    public void OnTriggerEnter ()
    {
        Instantiate (fadeInText);
        //Set position etc. here
        Destroy (fadeInText, 2f); 
    }
}
1 Like