2026-06-19 월드다이얼로그 프로토타입
This commit is contained in:
Binary file not shown.
@@ -6,6 +6,12 @@
|
||||
public class DialogPlayer : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private List<DialogGroup> _dialogGroups;
|
||||
|
||||
[Header("Dialog HUD Placement")] // 씬에서 캐릭터 위치/주변(벽 등)에 맞춰 조절
|
||||
[SerializeField] private float _hudChestHeight = 1.2f; // 화자 발 기준 가슴 높이
|
||||
[SerializeField] private float _hudForwardOffset = 0.5f; // 화자→플레이어 방향으로 띄울 거리
|
||||
[SerializeField] private float _hudLateralOffset = 0f; // 좌우 오프셋 (+ 플레이어 시점 오른쪽)
|
||||
|
||||
private Dictionary<string, DialogGroup> _dialogGroupMap;
|
||||
private Animator _animator;
|
||||
private int _initialGestureHash;
|
||||
@@ -134,9 +140,9 @@ private async Awaitable RotateToRotation(Transform target, Quaternion targetRota
|
||||
|
||||
private async Awaitable PlayNode(DialogNode node)
|
||||
{
|
||||
// 화자 옆 DialogHud에 대사 표시
|
||||
// 화자 옆 DialogHud에 대사 표시 (배치 오프셋은 이 NPC의 설정값 사용)
|
||||
if (DialogHud.Instance != null)
|
||||
DialogHud.Instance.Show(node.Speaker, node.TalkText);
|
||||
DialogHud.Instance.Show(node.Speaker, node.TalkText, _hudChestHeight, _hudForwardOffset, _hudLateralOffset);
|
||||
|
||||
// 보이스 재생
|
||||
if (node.Voice != null && node.Speaker != null)
|
||||
|
||||
@@ -17,11 +17,16 @@ public class DialogHud : MonoBehaviour
|
||||
[SerializeField] private TMP_Text _speakerName;
|
||||
[SerializeField] private TMP_Text _dialogueText;
|
||||
|
||||
[Header("Placement")]
|
||||
[Header("Placement (기본값 — Show에서 오프셋을 안 넘길 때 폴백)")]
|
||||
[SerializeField] private float _chestHeight = 1.2f; // 화자 발 기준 가슴 높이
|
||||
[SerializeField] private float _forwardOffset = 0.5f; // 화자→플레이어 방향으로 띄울 거리
|
||||
[SerializeField] private float _lateralOffset = 0f; // 좌우 오프셋 (+ 플레이어 시점 오른쪽)
|
||||
|
||||
private Transform _speakerTransform;
|
||||
private float _activeChestHeight;
|
||||
private float _activeForwardOffset;
|
||||
private float _activeLateralOffset;
|
||||
private bool _placed; // 처음 한 번만 배치하고 이후엔 고정
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -35,9 +40,17 @@ private void OnDestroy()
|
||||
if (Instance == this) Instance = null;
|
||||
}
|
||||
|
||||
// DialogHud 자체 기본 오프셋 사용
|
||||
public void Show(CharacterData speaker, string text)
|
||||
=> Show(speaker, text, _chestHeight, _forwardOffset, _lateralOffset);
|
||||
|
||||
// 배치 오프셋을 직접 넘겨 사용 (DialogPlayer가 NPC/씬별 값 전달)
|
||||
public void Show(CharacterData speaker, string text, float chestHeight, float forwardOffset, float lateralOffset)
|
||||
{
|
||||
_speakerTransform = speaker != null ? CharacterVoiceObject.Find(speaker)?.transform : null;
|
||||
_activeChestHeight = chestHeight;
|
||||
_activeForwardOffset = forwardOffset;
|
||||
_activeLateralOffset = lateralOffset;
|
||||
|
||||
if (_speakerName != null)
|
||||
_speakerName.text = speaker != null ? speaker.Name : string.Empty;
|
||||
@@ -53,10 +66,12 @@ public void Hide()
|
||||
if (_speakerName != null) _speakerName.text = string.Empty;
|
||||
if (_panel != null) _panel.SetActive(false);
|
||||
_speakerTransform = null;
|
||||
_placed = false; // 다음에 다시 뜰 때 재배치
|
||||
}
|
||||
|
||||
private void LateUpdate()
|
||||
{
|
||||
if (_placed) return; // 처음 위치에 고정 — 이후 플레이어가 움직여도 안 따라감
|
||||
if (_speakerTransform == null || Camera.main == null) return;
|
||||
|
||||
var camTr = Camera.main.transform;
|
||||
@@ -67,10 +82,13 @@ private void LateUpdate()
|
||||
if (toCam.sqrMagnitude < 0.0001f) return;
|
||||
Vector3 dir = toCam.normalized;
|
||||
|
||||
Vector3 chestWorld = _speakerTransform.position + Vector3.up * _chestHeight;
|
||||
transform.position = chestWorld + dir * _forwardOffset;
|
||||
Vector3 right = Vector3.Cross(dir, Vector3.up); // 플레이어 시점 기준 오른쪽(수평)
|
||||
Vector3 chestWorld = _speakerTransform.position + Vector3.up * _activeChestHeight;
|
||||
transform.position = chestWorld + dir * _activeForwardOffset + right * _activeLateralOffset;
|
||||
|
||||
// 빌보드 — 캔버스의 -Z(읽는 면)가 카메라를 향하도록 +Z를 카메라 반대로
|
||||
transform.rotation = Quaternion.LookRotation(-dir);
|
||||
|
||||
_placed = true; // 한 번 배치 후 고정
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
@@ -43,6 +43,7 @@ MonoBehaviour:
|
||||
- rid: 6595524284503556412
|
||||
- rid: 6595524284503556423
|
||||
- rid: 6595524284503556434
|
||||
- rid: 6595524284503556444
|
||||
m_GraphStickyNoteModels: []
|
||||
m_GraphPlacematModels: []
|
||||
m_GraphVariableModels: []
|
||||
@@ -153,6 +154,14 @@ MonoBehaviour:
|
||||
Hash: 68f89b4619f130d76186d50b78a7609a
|
||||
m_Category: 2
|
||||
m_Index: 4
|
||||
- m_Guid:
|
||||
m_Value0: 3380853770992205313
|
||||
m_Value1: 18053617693641326980
|
||||
m_HashGuid:
|
||||
serializedVersion: 2
|
||||
Hash: 01be87999734eb2e84c132e4a3558bfa
|
||||
m_Category: 2
|
||||
m_Index: 5
|
||||
m_EntryPoint:
|
||||
rid: 6595524284503556358
|
||||
m_Graph:
|
||||
@@ -908,3 +917,35 @@ MonoBehaviour:
|
||||
- rid: 6595524284503556443
|
||||
type: {class: DialogLineNode, ns: WhaleAdventure.Dialog.GraphTool.Editor, asm: Assembly-CSharp-Editor}
|
||||
data:
|
||||
- rid: 6595524284503556444
|
||||
type: {class: WireModel, ns: Unity.GraphToolkit.Editor, asm: Unity.GraphToolkit.Internal.Editor}
|
||||
data:
|
||||
m_Guid:
|
||||
m_Value0: 3380853770992205313
|
||||
m_Value1: 18053617693641326980
|
||||
m_HashGuid:
|
||||
serializedVersion: 2
|
||||
Hash: 01be87999734eb2e84c132e4a3558bfa
|
||||
m_Version: 2
|
||||
m_FromPortReference:
|
||||
m_NodeModelGuid:
|
||||
m_Value0: 13710833896111860515
|
||||
m_Value1: 8096942652718749771
|
||||
m_NodeModelHashGuid:
|
||||
serializedVersion: 2
|
||||
Hash: 23eb2110c9aa46be4b980276711e5e70
|
||||
m_UniqueId: Out
|
||||
m_PortDirection: 2
|
||||
m_PortOrientation: 0
|
||||
m_Title:
|
||||
m_ToPortReference:
|
||||
m_NodeModelGuid:
|
||||
m_Value0: 15671640390660357946
|
||||
m_Value1: 11221916553219458534
|
||||
m_NodeModelHashGuid:
|
||||
serializedVersion: 2
|
||||
Hash: 3a7ff944e7d97cd9e6c5b81da641bc9b
|
||||
m_UniqueId: In
|
||||
m_PortDirection: 1
|
||||
m_PortOrientation: 0
|
||||
m_Title:
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user