Hi Aron! I am struggling against a little problem.
I have a simple plane with just one obstacle in the middle. When I bake the navmesh with a recast graph, if I set walkable height/walkable climb to 0 the resulting graph shows that there still is a portion of the navmesh under the obstacle. My AIs can avoid the obstacle (because of the limits of the graph near the border of the obstacle, as you can see from the screenshot), but the problem arise when I try to select some random points to spawn my units.
I use the following code to do that:
GameObject plane = GameObject.Find("Plane"); NNInfo info = AstarPath.active.GetNearest (new Vector3( Random.Range (-plane.transform.localScale.x*10, plane.transform.localScale.x*10), 0, Random.Range(-plane.transform.localScale.z*10, plane.transform.localScale.z*10) )); Vector3 closest = info.clampedPosition; Instantiate(GameObject.CreatePrimitive(PrimitiveType.Cube),closest, Quaternion.identity);
With this code, sometimes units are spawned above the obstacle.
There are two possibilities:
- my code is somewhat wrong
- the navmesh under the obstacle get considered by get nearest so the unit is placed wrong
What do you think? Am I missing something?
(navmesh settings are indicated in the screenshot)