Having problems with interactions

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

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?

:bust_in_silhouette: Reply From: flurick

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.

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?

Destroyer2000 | 2019-04-01 20:47

actually first let me try it without the input

Destroyer2000 | 2019-04-01 20:48

yeah that didn’t work. Nevermind.

Destroyer2000 | 2019-04-01 20:49

Hmm… maybe I have to… I’ll try something again

Destroyer2000 | 2019-04-01 20:49

welp. that didn’t work

Destroyer2000 | 2019-04-01 20:51

I’m going to try something else :stuck_out_tongue:

Destroyer2000 | 2019-04-01 21:02