44 lines
1.4 KiB
GDScript
44 lines
1.4 KiB
GDScript
extends Node3D
|
|
|
|
var toggle: bool = true
|
|
var interactable: bool = true
|
|
var time: int
|
|
|
|
@onready var animation_player: AnimationPlayer = $SignAnimation
|
|
@onready var label: Label3D = $"../InteractLabel"
|
|
@onready var Player: Node3D = get_tree().get_first_node_in_group("player")
|
|
@onready var construct: Node3D = get_tree().get_first_node_in_group("Constructs")
|
|
@onready var player_ray: RayCast3D = get_tree().get_first_node_in_group("player_ray")
|
|
|
|
func ready():
|
|
time = Player.current_time
|
|
|
|
func _physics_process(_delta: float) -> void:
|
|
|
|
if construct.CONSTRUCT_TYPE.name == "Time" and Input.is_action_just_pressed("UseConstruct"):
|
|
if Player.current_time in [8,9,10,11,12,13,14,15,16,17,18,19] and toggle == false:
|
|
interact()
|
|
if Player.current_time in [1,2,3,4,5,6,7,20,21,22,23,24] and toggle == true:
|
|
interact()
|
|
|
|
if player_ray.is_colliding() and player_ray.get_collider() == $".":
|
|
label.show()
|
|
else:
|
|
label.hide()
|
|
|
|
func interact():
|
|
|
|
if interactable == true:
|
|
interactable = false
|
|
toggle = !toggle
|
|
if toggle == false:
|
|
animation_player.play("flip_sign")
|
|
#print(toggle)
|
|
if toggle == true:
|
|
animation_player.play_backwards("flip_sign")
|
|
#print(toggle)
|
|
## waits for a one second timer to finish before leaving the interactable if loop
|
|
## the false statement makes it so when the game is paused the timer is too
|
|
await get_tree().create_timer(0.5, false).timeout
|
|
interactable = true
|