vrp-gruppe-sechs/disco-escape-roomv-5/import_scene/book_holder.gd

33 lines
896 B
GDScript

extends Node3D
@export var right_controller: XRController3D
@export var activation_distance: float = 1.0 # 100cm Reichweite
var button_was_pressed = false
func _process(_delta):
if not right_controller:
return
# Prüfe Distanz zum Controller
var distance = global_position.distance_to(right_controller.global_position)
var button_pressed = right_controller.is_button_pressed("by_button")
# Toggle wenn nah genug und Button neu gedrückt
if distance < activation_distance and button_pressed and not button_was_pressed:
show_tutorial()
else:
not_show_tutorial()
button_was_pressed = button_pressed
func show_tutorial():
if has_node("MeshInstance3D/Label3D"):
var label = get_node("MeshInstance3D/Label3D")
label.visible = true
func not_show_tutorial():
if has_node("MeshInstance3D/Label3D"):
var label = get_node("MeshInstance3D/Label3D")
label.visible = false