So today I was refurbishing a scene when this happened. After baking a new Navmesh the SamplePosition() returned only infinity. I tried a lot of things out but eventually went back to an older version of my project. Sooner or later I will have to bake a new Navmesh though, so I'd really like to know what happened there.
Here is the part of the code that appears to cause trouble:
Vector3 randomDirection = Random.insideUnitSphere * roamRadius; NavMeshHit hit; NavMesh.SamplePosition(randomDirection, out hit, roamRadius, 1); direction = hit.position;
And of course this, since it tries to look into infinity I suppose:
transform.LookAt(transform.position - direction, Vector3.up);
Again, this code works fine. Only after baking a Navmesh this fails horribly.