0 votes

Hello, I am trying to create a dialog box that shows up when you are currently in an area. I need it so that when you press the space key, and you are also in the area, the dialog box will show up. How would I make that happen?

in Engine by (15 points)

1 Answer

0 votes

Signals could do it. Connect the node here:

func _ready():
    Self.connect(“body_entered”, self, “on_body_entered”)

And then put your event here, assuming the player object is called “player”:

func on_body_entered():
     If body.name == “player”:
         If Input.is_action_pressed(‘space_key’):
             # your text event

My logic is a bit messy but that should be enough to get you there. There is also a plugin named Dialogic that can help specifically with the effect you are looking for.

by (291 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.