여전히 문제는 해결되지 않았지만 튜터님이 예상되는 원인을 찾아주셔서 해결 중이다!
오브젝트 풀에서 다시 생성될 때 제대로 초기화되지 않는 부분이 있는 것 같다고 조언해 주셔서 찾아보고 있다.
그 외에도 Walk나 Run에서 경로를 설정할 때 매번 경로를 재설정하지 않고 변경되었을 때만 재설정하도록 코드를 수정했다. 훨씬 효율적으로 동작하도록 코드를 변경해주셨다!
[ 이전 코드 ]
public bool ArriveToDestination(Vector3 target)
{
agent.ResetPath();
agent.SetDestination(target);
bool flag = agent.remainingDistance <= agent.stoppingDistance;
if (!flag)
StartCoroutine(ReturnHumanProcess());
return flag;
}
[ 변경된 코드 ]
public bool ArriveToDestination(Vector3 target)
{
if (oldTarget != target)
{
oldTarget = target;
NavMeshPath path = new NavMeshPath();
agent.CalculatePath(target, path);
agent.SetPath(path);
}
bool flag = agent.hasPath;
if (!flag)
StartCoroutine(ReturnHumanProcess());
return flag;
}'내일배움캠프 > TIL' 카테고리의 다른 글
| [내배캠][Unity6기][TIL] NavMesh 트러블슈팅 (2) (0) | 2024.12.11 |
|---|---|
| [내배캠][Unity6기][TIL] NavMesh 트러블슈팅 (0) | 2024.12.09 |
| [내배캠][Unity6기][TIL] 최종 프로젝트 중간 기록 (1) (0) | 2024.12.05 |
| [내배캠][Unity6기][TIL] Behavior Tree 구조 설계 (3) (0) | 2024.12.04 |
| [내배캠][Unity6기][TIL] 11.15 최종 프로젝트 시작 전, 알아두면 좋을 것들 특강(스탠다드) (2) (0) | 2024.12.03 |