0 votes
    extends Area2D
export var door = "name"

func _ready():
    add_to_group("door")

func open_door_request_dialog():
    var dialog = Dialogic.start(door)
    dialog.pause_mode = PAUSE_MODE_PROCESS
    Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
    dialog.connect('timeline_end', self, 'end_dialog')
    get_tree().paused = true


func end_dialog(_data):     
    get_tree().paused = false
    Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)

Using dialogic to add dialogue in my game but am currently having trouble with having an area (player) entering another area (the door) to start the dialog.

Before this i had:

    func open_door_request_dialog():
        var dialog = Dialogic.start(door)
        dialog.pause_mode = PAUSE_MODE_PROCESS
        Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
            get_parent().add_child(dialog)
        dialog.connect('timeline_end', self, 'end_dialog')
        get_tree().paused = true

In which I got back Attempt to call function 'add_child' in base 'null instance' on a null instance.

I thought removing it would help but instead I was bestowed this next error.

in Engine by (25 points)

1 Answer

0 votes

The thing is your Node isn't in Scene tree itself. He has no parent and he can't refer scene_tree. This script, that extends Area2D, it needs to be childed to anything in the scene. You propably instance it somewhere and forget to child it.

by (5,132 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.