![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | GamesByMike |
I’m working on an 3D RPG game, I’ve tried using Dialogic 2.0 and Dialogue Manager but couldn’t get them working and I don’t want to deal with JSON files. So I made my own.
The problem I’m having is that I need some dialogue to trigger when the player approaches an NPC.
Here is my code that is attached to a control node and signaling the NPC:
extends Control
var Textchange = 0
func _on_area_3d_body_entered(body):
visible = true
if Textchange == 1:
$TEXT2.text = "Dad: Hello my Son! Need something?"
if Textchange == 2:
$TEXT2.text = "Paper: I want to get off this island and go on an adventure!"
if Textchange == 3:
$TEXT2.text = "Dad: Yeah, NO WAY!!"
if Textchange == 4:
$TEXT2.text = ""
if Textchange == 5:
visible = false
func _process(body):
_on_area_3d_body_entered(body)
if Input.is_action_just_pressed("enter"):
Textchange += 1
The code displays a text box and the “Textchange” variable changes what text is shown.
My problem is that all this shows when the game starts, not when interacting with the NPC.
What am I doing wrong? I am still very new to Godot.