Godot Version
Replace this line with your Godot version
Question
this code below have the function that
if the player click at certain area2d it
just activates a panel alongside a rich
textlabel and if you clicked again it
woulve change but when i test the project the first text repeats twice before being deactivaded
instead of changing.
can someone tell me why this happens
extends Area2D
var thoght = 0
var entered = false
func _on_body_entered(body: Node2D) -> void:
entered = true
func _on_body_exited(body: Node2D) -> void:
entered = false
func _unhandled_input(event: InputEvent) -> void:
if event.is_action_pressed("ui_change"):
vthg()
func vthg():
if thoght == 0 and entered == true:
$"../CanvasLayer/Panel".set_deferred("visible", true)
$"../CanvasLayer/Panel/HBoxContainer/VBoxContainer/RichTextLabel".set_deferred("text", "It's written 'Godym University'.")
thoght = 1
elif thoght == 1:
$"../CanvasLayer/Panel/HBoxContainer/VBoxContainer/RichTextLabel".set_deferred("text", "Could you enter?")
thoght = 2
elif thoght == 2:
$"../CanvasLayer/Panel".set_deferred("visible", true)
$"../CanvasLayer/Panel/HBoxContainer/VBoxContainer/RichTextLabel".set_deferred("text", "It's written 'Godym University'.")
thoght = 0