I know that some time has passed, but I have encountered the same problem in the last two hours. Finally, I managed to mix both components (NavMeshAgent and NavMeshObstacle). The only requirement is that they cannot be turned on at the same time. My strategy was to disable agents and obstacles (with the carve option turned on), and when I move the block, disconnect the obstacle and turn on the agent.
Just the last comment. I found that disabling the obstacle and including the agent in the same frame causes a slight problem of unit bias, so I had to use a coroutine to do this:
public IEnumerator EnableUnitMovementCoroutine()
{
if (obstacle != null && obstacle.enabled)
{
obstacle.enabled = false;
}
yield return new WaitForEndOfFrame();
if (agent != null && !agent.enabled)
{
agent.enabled = true;
destinationSet = false;
}
yield return new WaitForEndOfFrame();
unitMoving = true;
}
After that, simply use the agent methods to calculate the path. BTW, you can see navmesh in real time, including device obstacles, by selecting the “Navigation” tab in playback mode.
, !
PS. , :
_agent.pathStatus != NavMeshPathStatus.PathComplete
, , . . .