![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Scyonix |
Im trying to make a dialogue system for NPC’s. However this error comes at the end when i put in the code
get_parent().add_child(_dialogue)
Here is the complete code for the NPC script.
extends Area2D
var can_interact = false
const _dialogue = preload("res://Game Mechanic Scenes/DialogueBox.tscn")
func _on_InteractionPoint_body_entered(body):
if body.name == "Player":
$Label.visible = true
can_interact = true
func _on_InteractionPoint_body_exited(body):
if body.name == "Player":
$Label.visible = false
can_interact = false
func _input(_event):
if Input.is_action_just_pressed("Interact") and can_interact == true:
$Label.visible = false
var newDialogue = _dialogue.instance()
get_parent().add_child(_dialogue)
The Error: Parser Error: At “add_child()” call, argument 1. The passed argument’s type (PackedScene) doesn’t match the function’s expected argument type (Node).
What have I done wrong?