diff --git a/Assets/Scripts/BuildingManager.cs b/Assets/Scripts/BuildingManager.cs index eacdb03..d243967 100644 --- a/Assets/Scripts/BuildingManager.cs +++ b/Assets/Scripts/BuildingManager.cs @@ -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($"[BuildingManager] 물리적 충돌 감지: {colliders.Length}개의 오브젝트와 겹침"); + foreach (var col in colliders) + { + Debug.Log($" - {col.gameObject.name} (Layer: {LayerMask.LayerToName(col.gameObject.layer)})"); + } + return false; + } + return true; }