How to display text when player is near an object?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hermo

Hello! I wanna display some simple text like in the Mario games. Something like this:

You get near an object or touch it and then some text in a box above appears. Then you press a button or get far away and it disappears.

What’s the Node I should add? Richtextlabel? How can I script it to make it appear disappear? Any tutorials out there?

Thank you very much!

:bust_in_silhouette: Reply From: kidscancode

Label or RichTextLabel can both work, depending on how much formatting you need in your text.

You can show/hide the box with the visible property.

For detecting proximity, use an Area2D. On the body_entered signal, show the box, and on body_exited hide it.

As for tutorials, while you might not find exactly this, there are many tutorials out there on using the individual components.