using UnityEngine; public class PlayerInteractor : MonoBehaviour { [SerializeField] private float interactRange = 3f; [SerializeField] private LayerMask interactableLayer; // Создайте слой "Interactable" в Unity private void Update() { // Пускаем луч из центра экрана Ray ray = new Ray(transform.position, transform.forward); if (Physics.Raycast(ray, out RaycastHit hit, interactRange, interactableLayer)) { IInteractable interactable = hit.collider.GetComponentInParent(); if (interactable != null) { // Здесь в будущем можно выводить UI текст interactable.GetPrompt() на экран if (Input.GetKeyDown(KeyCode.E)) { // Передаем корневой объект игрока (не камеру) Debug.Log("Кнопка нажата"); interactable.Interact(transform.root.gameObject); } } } } }