- Edited
I chose to pick up Godot as an engine for my coursework and followed a tutorial to make a 2D platform shooter. One of the features I included was an NPC interaction (using Dialogic) which triggered them to speak when the player moves within their Area2D/ Collision shape.
I managed to get it to work before but I messed up the code and now the text doesn't appear anymore and I can't make sense of it (literally first time ever programming) It's probably a silly error, or a much easier way to trigger it- but this is the basic gist of what I've copied down and messed around with:
var dialog = null
var is_quest_accepted = false
var is_quest_finished = false
#Called when the node enters the scene tree for the first time.
func _ready():
$Area2D/Speech.visible = false
func _on_Area2D_body_entered(body):
is_quest_accepted = true
is_quest_finished = true
if get_node_or_null('DialogNode') == null:
if is_quest_accepted and is_quest_finished:
dialog = Dialogic.start ('finish')
dialog.connect('dialogic_signal', self, 'dialog_msg')
#dialog.connect('dialogic_signal', self, 'dialog_msg')
add_child(dialog)
$Area2D/Speech.visible = true
func dialog_msg(msg):
if msg == 'yes' and is_quest_accepted:
is_quest_accepted = true
is_quest_finished = false
func _on_Area2D_body_exited(body):
$Area2D/Speech.visible = false
if dialog and is_instance_valid(dialog):
dialog.queue_free()
This does trigger the text to come up when the Player comes near the NPC, however, it automatically triggers it when you press play which overlaps other dialogue boxes and is what I'm trying to get rid of. I'm not well versed on programming languages or logic so simple explanations will be appreciated