Сделал базовое управление машиной и персонажем

This commit is contained in:
bybohka committed 2026-09-19 16:56:59 +03:00
1 parent 10d42b72b8
commit 48753f65fb
152 files changed
+15117 -174

No files matched your search

@@ -0,0 +1,30 @@
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<IInteractable>();
if (interactable != null)
{
// Здесь в будущем можно выводить UI текст interactable.GetPrompt() на экран
if (Input.GetKeyDown(KeyCode.E))
{
// Передаем корневой объект игрока (не камеру)
Debug.Log("Кнопка нажата");
interactable.Interact(transform.root.gameObject);
}
}
}
}
}
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 55f66c5b12bc40f08c38b6fad86ad694
timeCreated: 1789819467