Ejemplo n.º 1
0
        public WWAIManager()
        {
            GameObject obj = new GameObject("AIScript");

            obj.transform.position = new Vector3(0.0f, 0.0f, 0.0f);
            obj.AddComponent <AstarPath>();

            //RVOSimulator rsim = obj.AddComponent<RVOSimulator>();

            ProceduralGridMover gridMover = obj.AddComponent <ProceduralGridMover>();

            gridMover.target         = Camera.main.transform;
            gridMover.updateDistance = 5;
            gridMover.floodFill      = true;

            // This holds all graph data
            AstarData data = AstarPath.active.data;

            // This creates a Grid Graph
            LGG = data.AddGraph(typeof(LayerGridGraph)) as LayerGridGraph;

            // Setup a grid graph with some values
            int   width    = 80;
            int   depth    = 80;
            float nodeSize = 0.5f;

            LGG.characterHeight = 2;
            LGG.maxClimb        = 1.5f;

            LGG.collision.collisionOffset = 1;
            LGG.collision.diameter        = 2.5f;
            LGG.collision.type            = 0;

            LGG.center = new Vector3(0, 0, 0);

            // Updates internal size from the above values
            LGG.SetDimensions(width, depth, nodeSize);

            LGG.collision.heightMask = LayerMask.GetMask("Terrain");
            LGG.collision.mask       = LayerMask.GetMask("Obstacles");

            //set erode iterations to givebetter edges for obstacles
            LGG.erodeIterations = 0;

            // Scans graph
            LGG.Scan();
        }
Ejemplo n.º 2
0
 public void RefreshGrid()
 {
     LGG.Scan();
 }