건설 시 모든 오브젝트와 충돌 검사

This commit is contained in:
2026-01-27 23:01:21 +09:00
parent 387991caab
commit 8799c4f8f4

View File

@@ -108,6 +108,26 @@ namespace Northbound
return false;
}
// 물리적 충돌 체크 (플레이어, 유닛, 기타 오브젝트와의 충돌)
// Physics.OverlapBox를 사용하여 해당 위치에 다른 Collider가 있는지 확인
Collider[] colliders = Physics.OverlapBox(
boundsCenter,
shrunkSize * 0.5f,
Quaternion.Euler(0, rotation * 90f, 0),
~groundLayer // groundLayer를 제외한 모든 레이어와 충돌 검사
);
// 충돌한 Collider가 있으면 배치 불가
if (colliders.Length > 0)
{
Debug.Log($"<color=yellow>[BuildingManager] 물리적 충돌 감지: {colliders.Length}개의 오브젝트와 겹침</color>");
foreach (var col in colliders)
{
Debug.Log($" - {col.gameObject.name} (Layer: {LayerMask.LayerToName(col.gameObject.layer)})");
}
return false;
}
return true;
}