Hi everyone,
My problem is this; I create buildings dynamically on a map but I would confirm that they do not block the way of the moving units (my buildings have the nav mesh obstacle component with the carve property set to true).
Is there a way to achieve this?
I tried with the following code, but without success:
_baseTowerObstacle.enabled = true; // I turn on the nav mesh obstacle component to take into account in the calculation of the path.
NavMesh.CalculatePath(_spawn.position, _target.position, -1, _path);
_baseTowerObstacle.enabled = false; // I immediately disables the nav mesh obstacle component to prevent my units stay locked during the placement of my building.
if (_path.status == NavMeshPathStatus.PathComplete)
{
// It's ok, let's build.
}
else
{
// PROBLEM : I never go there, even when I have an obstacle in the middle of the road =/
}