Pathfinding.GridGraph.GetNodesInArea C# (CSharp) Method

GetNodesInArea() public method

public GetNodesInArea ( Bounds b ) : List
b UnityEngine.Bounds
return List
        public List<Node> GetNodesInArea(Bounds b)
        {
            return GetNodesInArea (b, null);
        }

Same methods

GridGraph::GetNodesInArea ( Bounds b, GraphUpdateShape shape ) : List
GridGraph::GetNodesInArea ( GraphUpdateShape shape ) : List

Usage Example

        // this is the optimized version. Other graphs cannot be optimised this way because they have irregular structures unfortunately. Still, we shouldn't miss on the advantages of this specific graph type, so I included it specifically.
        void mohogonyGrid()
        {
            nodes = new List<Node>();
            nodes.Add(node as Node);
            graph = AstarPath.active.graphs[node.graphIndex] as GridGraph;

            GraphUpdateShape gus = new GraphUpdateShape();
            if (useRealCollider.Value)
            {

                if(go.collider.GetType() == typeof(BoxCollider)) // take render bounds, then turn them into world coordinates
                {
                    Debug.Log("It's a box collider");
                    bounds.center = (go.collider as BoxCollider).center;
                    bounds.size = (go.collider as BoxCollider).size;

                    calculateBox(gus);

                }
                else if(go.collider.GetType() == typeof(MeshCollider))
                {
                    gus.points = (go.collider as MeshCollider).sharedMesh.vertices;
                    for(var i=0; i < gus.points.Count(); i++ )
                    {
                        gus.points[i] = go.transform.TransformPoint((go.collider as MeshCollider).sharedMesh.vertices[i]);
                    }
                    Debug.Log("It's a mesh collider!");
                }
                else // any other collider
                {
                    calculateBox(gus);
                    Debug.Log("This type of collider is not specifically supported. Using bounds instead...");
                }

            }

            else // get the points of the render bounds
            {
                bounds = (go.renderer.GetComponent<MeshFilter>()).sharedMesh.bounds;
                calculateBox(gus);
            }

            //gus.convex = true;
            nodes = graph.GetNodesInArea(gus);

            if(getWalkableOnly.Value)
            {
                connected = new List<Node>();
                for(var i=0; i < nodes.Count(); i++ )
                {
                    if(nodes[i].walkable)
                    {
                        connected.Add(nodes[i]); // connected is a substitute for a better named one :D There is no real sense behind the name here.
                    }
                }
                nodesOutput.Value = SetNodes(connected);
            }

            else
            {
                nodesOutput.Value = SetNodes(nodes);
            }

            Debug.Log("i" + nodes.Count);

            return;
        }