extends Node3D

@export var active : bool = true

@onready var player: Node3D = get_tree().get_nodes_in_group("Player").front()
@onready var turret_head = $TurretHead
@onready var laser = $TurretHead/Laser

func _process(_delta):
	if not active or not player:
		return

	var aim_position = player.global_position
	aim_position.y = turret_head.global_position.y
	turret_head.look_at(aim_position, Vector3.UP)

func activate():
	active = true
	laser.activate()

func deactivate():
	active = false
	laser.deactivate()
