extends Node3D
@onready var ray_cast: RayCast3D = $RayCast3D

const Interactable = preload("uid://d1pa8ssvmxbn")

@export var max_distance: float = 100

func _ready() -> void:
	ray_cast.target_position = Vector3(0,0,-max_distance)
	
func _input(event: InputEvent) -> void:
	if event.is_action_pressed("interact"):
		if ray_cast.is_colliding():
			var collider = ray_cast.get_collider()
			if collider.get_script() == Interactable:
				var interactable: Interactable = collider
				interactable.hit()
