2026-06-27 클리어 요정 높이 수정 불가 현상 개선, 씬 정리

This commit is contained in:
2026-06-27 01:14:55 +09:00
parent c748bbd21b
commit 68bfddf8c7
460 changed files with 757 additions and 928 deletions

View File

@@ -16,6 +16,10 @@ public struct Relocation
{
public GameObject Target; // 옮길 오브젝트 (NPC 등)
public Transform Destination; // 옮길 위치/회전 기준
[Tooltip("체크하면 NavMeshAgent의 Base Offset을 아래 값으로 변경한다 (높이 조절용). NavMeshAgent가 없으면 무시됨.")]
public bool OverrideBaseOffset; // NavMeshAgent의 baseOffset을 바꿀지 여부
public float BaseOffset; // 적용할 baseOffset 값
}
// 클리어 시 적용할 존 상태 한 쌍
@@ -52,11 +56,19 @@ public void OnGameClear()
public void Relocate()
{
foreach (var r in _relocations)
Relocate(r.Target, r.Destination);
Relocate(r.Target, r.Destination, r.OverrideBaseOffset, r.BaseOffset);
}
// 단일 오브젝트 재배치(baseOffset 변경 없음). 기존 호출부 호환용 오버로드.
public void Relocate(GameObject target, Transform destination)
{
Relocate(target, destination, false, 0f);
}
// 단일 오브젝트 재배치. NavMeshAgent가 있으면 Warp로 옮겨야 경로/내부상태가 안 깨진다.
public void Relocate(GameObject target, Transform destination)
// NavMeshAgent는 (NavMesh 표면 높이 + baseOffset)으로 y가 강제되므로,
// 높이를 바꾸려면 destination.y가 아니라 baseOffset을 조정해야 한다.
public void Relocate(GameObject target, Transform destination, bool overrideBaseOffset, float baseOffset)
{
if (target == null || destination == null) return;
@@ -66,6 +78,10 @@ public void Relocate(GameObject target, Transform destination)
if (target.TryGetComponent(out NavMeshAgent agent) && agent.isOnNavMesh)
{
// 높이 조절: Warp 전에 baseOffset을 바꿔야 옮긴 위치에 바로 반영된다.
if (overrideBaseOffset)
agent.baseOffset = baseOffset;
Debug.Log($"엔드포지션 : {destination.position}");
agent.Warp(destination.position);
target.transform.rotation = destination.rotation;