Need help with dialogue triggering

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: 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):
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.

:bust_in_silhouette: Reply From: gradyplayer

it is possible you are overloading something here…
_process() is called by the engine with a delta… not a body… it shouldn’t be connected to any game actions.

you also shouldn’t call _on_area_3d_body_entered(body) yourself, presumably that should be triggered by some hit detection.

wouldn’t need to see more to guess more.

I get errors when I tried to use _process(delta)

GamesByMike | 2023-06-23 01:18