적과 타워가 서로 공격하지 않는 문제 수정

This commit is contained in:
2026-02-24 16:08:35 +09:00
parent 907e2e24c8
commit 98d071480c
22 changed files with 883 additions and 365 deletions

View File

@@ -180,7 +180,7 @@ namespace Northbound
}
}
// 1. Player 감지 (코어로 가는 도중에도 Player 타겟팅)
// 1. Player 감지 (코어로 가는 도중에도 Player/건물을 타겟팅)
GameObject detectedPlayer = DetectTarget();
if (detectedPlayer != null)
{
@@ -189,20 +189,7 @@ namespace Northbound
return;
}
// 2. 코어로 가는 경로가 '완전(Complete)'한지 확인
// NavMesh가 갱신되었다면 에이전트는 즉시 Complete 상태가 됩니다.
if (_agent.hasPath && _agent.pathStatus == NavMeshPathStatus.PathComplete)
{
if (!_hasSetCoreDestination)
{
_agent.SetDestination(_core.GetNavMeshPosition());
_hasSetCoreDestination = true;
}
// [중요] 길이 열렸으므로 아래의 장애물 탐지 로직을 아예 실행하지 않고 리턴!
return;
}
// 3. 길이 막혔을 때(Partial)만 아주 좁은 범위에서 장애물을 찾음
// 2. 경로 상의 장애물(건물) 감지 - 경로 상태와 관계없이 확인
GameObject obstacle = DetectObstacle();
if (obstacle != null)
{
@@ -211,8 +198,8 @@ namespace Northbound
return;
}
// 4. 경로가 유효하지 않을 때만 재설정
if (!_agent.hasPath || _agent.pathStatus == NavMeshPathStatus.PathInvalid)
// 3. 코어로 가는 경로 설정
if (!_hasSetCoreDestination || !_agent.hasPath || _agent.pathStatus == NavMeshPathStatus.PathInvalid)
{
_agent.SetDestination(_core.GetNavMeshPosition());
_hasSetCoreDestination = true;