I have create a maze, I want after clicking I want to draw a path line but no matter where I click everytime Navmesh.calculatepath returns false value.
Here is my code.
void Update()
{
if (Input.GetMouseButtonDown(0)){
StartCoroutine(Makepath());
}
}
private IEnumerator Makepath(){
Ray Moveposition = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(Moveposition, out var hitposition))
{
Vector3 agentpos = agent.transform.position;
NavMeshPath path = new NavMeshPath();
agent.SetDestination(hitposition.point);
NavMesh.CalculatePath(agentpos, hitposition.point, NavMesh.AllAreas, path);
Debug.Log(path.corners.length + "<<<<Path.corner length");
Debug.Log(agentpos + "<<<agentpos");
Debug.Log(hitposition.point + "<<<hitposition.point");
}
yield return null;
}
and here is output I found in console