How do I check if a body is currently in an area?

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

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?

:bust_in_silhouette: Reply From: SnapCracklins

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.