The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates.

godotengine.org | Twitter

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 (26 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 (8,188 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 Frequently asked questions and 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 [email protected] with your username.