How to interact with objects by pressing the spacebar

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

I am creating a simple 2d story game. When the player wants to read or interact on an object to know what that object is (by showing text), the player must stand right there and press the spacebar button, and the screen will show the text. How do I do that? And how to show text on the screen?

:bust_in_silhouette: Reply From: Bot7

You should add a area2d to the object. Set the Input key Spacebar with Spacebar. Than you should take the signal area_entered to your script and check if Input.is_action_pressed_Spacebar: and show an Label. (I don’t know how great you are but this is very basic. You should make Youtube Tutorials first.)