0 votes

So, I'm having troubles with interactions. Basically, I'm trying to figure out how to have a dialogue box appear when the play is in an area 2D while also having pressed a button (in this case it's enter).
And while I did have it so that the game would crash when you did this, it no longer does.
Also to note, in case this is important, I have the code in the Area2D code. Thought I should point that out.

    extends Area2D    

var inarea = false

export var text = ["A broken Cart."]

func _ready():
    if inarea == true:
        if (Input.is_action_just_pressed("ui_interact")):
            handledialog()



func _area_entered(object):     
    inarea = true


func _area_exited(object):     
    inarea = false


func handledialog():
    get_node("../NinePatchRectangle").vairable("printing")

That is the code.

As you can see, I'm trying to call a variable from another script for the dialog box to display. It isn't working. Anyone have a solution?

in Engine by (12 points)

1 Answer

0 votes

I would first test if handledialog() is ever reached by adding a print() in there somewhere. Then make sure vairable("printing") does what you think it does, since it is your custom implementation, and that it is not left on the projects todo list somehow.

by (911 points)

handledialog() unfortunately does not work. I might have a bad placement of the area. it's right in front of the object I want to interact with. Is that a problem?

actually first let me try it without the input

yeah that didn't work. Nevermind.

Hmm... maybe I have to... I'll try something again

welp. that didn't work

I'm going to try something else :P

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.