While working on lecture 105 “Simplifying Click to Move” it occured to me how to determine if the ray cast hit was on a NavMesh. Here is the code, which I also posted in the forum for the lecture.
public static bool isOnNavMesh(Vector3 point) {
const float MAX_DISTANCE_FROM_POINT = 0.2f; //Adjusted through testing
NavMeshHit navMeshHit; //Required for Sampleposition call but not used
return NavMesh.SamplePosition(point, out navMeshHit, MAX_DISTANCE_FROM_POINT, NavMesh.AllAreas);
}