대화로직 수정중
This commit is contained in:
27
Assets/02_Scripts/Communication/Dialog/DialogRegion.cs
Normal file
27
Assets/02_Scripts/Communication/Dialog/DialogRegion.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
|
||||
// 영역 트리거. 이 콜라이더(isTrigger) 안으로 NPC(DialogPlayer 보유)가 들어오면
|
||||
// 그 NPC의 현재 영역을 _regionKey로 전환한다.
|
||||
// _regionKey는 해당 영역에서 재생할 DialogGroup의 이름과 일치해야 한다 (예: "Coast", "Hill").
|
||||
//
|
||||
// 주의: OnTriggerEnter가 동작하려면 들어오는 쪽(또는 트리거 쪽)에 Rigidbody가 있어야 하고,
|
||||
// 이 오브젝트의 Collider는 Is Trigger여야 한다.
|
||||
[RequireComponent(typeof(Collider))]
|
||||
public class DialogRegion : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private string _regionKey; // DialogGroup 이름과 일치
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
// 컴포넌트 추가 시 편의상 트리거로 설정
|
||||
var col = GetComponent<Collider>();
|
||||
if (col != null) col.isTrigger = true;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
var player = other.GetComponentInParent<DialogPlayer>();
|
||||
if (player != null)
|
||||
player.SetRegion(_regionKey);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user