인터랙션 시스템 및 터널 기능 생성

This commit is contained in:
2026-01-15 16:45:14 +09:00
parent f70223a4aa
commit b8ecb9a24c
12 changed files with 959 additions and 37 deletions

View File

@@ -0,0 +1,42 @@
using UnityEngine;
public class TunnelNode : MonoBehaviour, IInteractable
{
public TunnelNode connectedNode;
public TunnelNode otherEndOfThisSegment;
public float detectionRadius = 0.5f;
public LayerMask tunnelLayer;
// --- IInteractable 구현부 ---
public void Interact(GameObject user)
{
// 상호작용한 플레이어의 TunnelTraveler를 찾아 이동 시작!
TunnelTraveler traveler = user.GetComponent<TunnelTraveler>();
if (traveler != null)
{
traveler.StartTravel(this);
}
}
public string GetInteractionText()
{
return "통로 진입";
}
// ----------------------------
void Start() => FindNeighborNode();
public void FindNeighborNode()
{
Collider[] colliders = Physics.OverlapSphere(transform.position, detectionRadius, tunnelLayer);
foreach (var col in colliders)
{
TunnelNode neighbor = col.GetComponent<TunnelNode>();
if (neighbor != null && neighbor != this && neighbor != otherEndOfThisSegment)
{
connectedNode = neighbor;
break;
}
}
}
}