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(); }
public override void OnInspectorGUI(NavGraph target) { LayerGridGraph graph = target as LayerGridGraph; graph.mergeSpanRange = EditorGUILayout.FloatField("Merge Span Range", graph.mergeSpanRange); graph.characterHeight = EditorGUILayout.FloatField("Character Height", graph.characterHeight); graph.maxClimb = Mathf.Clamp(EditorGUILayout.FloatField("Max climb", graph.maxClimb), 0, graph.characterHeight); graph.neighbours = NumNeighbours.Four; textureVisible = false; base.OnInspectorGUI(target); if (graph.neighbours != NumNeighbours.Four) { Debug.Log("Note: Only 4 neighbours per grid node is allowed in this graph type"); } if (graph.collision.thickRaycast) { HelpBox("Note: Thick raycast cannot be used with this graph type"); } }
void Awake() { if (PeGameMgr.IsStory) { CaveData.Add(storyCaves); } CaveData.Load("Cave/CaveData"); if (AstarPath.active == null) { throw new System.Exception("There is no AstarPath object in the scene"); } layerGridGraph = AstarPath.active.astarData.layerGridGraph; if (layerGridGraph == null) { throw new System.Exception("The AstarPath object has no GridGraph"); } UpdateCavePosition(); }