So I have a scene with a bunch of simple AI characters in it. The AI characters wander around more or less at random through the scene by picking random points and then going there (with some small shifting if there’s an object right in front of them in the way).
The only problem is that if they accidentally pick a point that’s, say, inside a wall or tree, or below the terrain, then they are never able to reach it. They fetch up against the object or ground and then keep trying to get to this inaccessible point. (They don’t have this problem if the point is, say, behind a wall and there’s still a path to it - only if the point is embedded inside an object.)
Does anyone have any suggestions on how to check if a point is “clear” before choosing it as a target? It looks like there’s no function to check if a point is inside a collider, which would seem like the most obvious way (although that doesn’t account for the under the terrain problem, but I think I’ll have to deal with that separately anyway), and raycasts/spherecasts don’t work because they have to be large enough to intersect the actual planes of the collider (ie, if the raycast is entirely inside the object and doesn’t touch its sides, then it registers as “clear,” even though it’s actually inside the object), and there’s no way of telling how far that should be without knowing what object the point is inside of.
Is there some way that unity games typically do this? Or am I going to be forced to create a small, static set of viable points for the AI to go between?