cawez_puzzlebox/objectives/objective_switcher.gd
2024-06-28 22:06:18 -04:00

27 lines
639 B
GDScript

extends Node3D
@export var buttons : Array[Area3D]
var timeout = 0.0
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(_delta):
var sum = 0
for button in buttons:
if button.children != 0:
sum += 1
if sum == buttons.size():
timeout += _delta
if timeout > 1:
$objective_dead.position = Vector3(10000, 0, 0)
$objective.position = Vector3(0, 0, 0)
else:
timeout = 0.0
$objective_dead.position = Vector3(0, 0, 0)
$objective.position = Vector3(10000, 0, 0)