Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Melonad3 |
(Beginner)
I watched a video about dialogue boxes and used a part of the code from it but it doesn’t seem to be working for me.
Like, the dialogue scene (Text.tscn) works fine by itself but while trying to call it from a different scene using my NPC, it doesn’t work.
I can’t seem to find the problem.
Thanks for the help!
extends Area2D
var active = false
const Dialog = preload("res://scenees/Text.tscn")
func _process(delta):
$Ping.visible = active
$Label.visible = active
func _on_NPC_body_entered(body):
if body.name == 'Player':
active = true
func _on_NPC_body_exited(body):
if body.name == 'Player':
active = false
func _input(event):
if Input.is_action_just_pressed("Interact") and active == true:
print("ehyyyyyyyyyyyyyy")
#Just checking if it works. As of now, it prints but doesn't call an instance of the scene
$Label.visible = false
$Ping.visible = false
#should be calling the Text scene but its not
var dialog = Dialog.instance()
get_parent().add_child(dialog)`
I mean, there could be issues in the code (e.g. a typo like sceenes
). It’s tough to figure out what’s going on here; perhaps there’s a debug message or something in the output window?
As an alternative, you could just instance the dialog in the scene itself and control its visibility via code. There’s little need to instance the scene here, imho.
spaceyjase | 2021-12-07 11:13
Hmmm…
I’ll try to instance it in the main scene like you said then.
Thanks a lot!
Melonad3 | 2021-12-07 11:49