So I’ve recently messing with creating a graph at runtime instead of saving a premade one into a prefab and loading it. However, whenever I try to make a call to either AstarPath.active to add the graph or any calls to my seeker (now, even using the premade grid) I get a null reference exception saying that there is no AstarPath object. I’m not doing anything astar related in my main Awake() call, and even when I try adding a graph in Start() I still get this error. Here’s the relevant code snippet from my main game engine for adding my graph:
void Start(){
GridGraph graph = (GridGraph) AstarPath.active.astarData.AddGraph(typeof(GridGraph));
graph.nodeSize = 10f;
graph.width = (int)GameData.Instance.map.terrainData.size.x/10;
graph.depth = (int)GameData.Instance.map.terrainData.size.z/10;
graph.center = new Vector3 (graph.width / 2, 0, graph.depth / 2);
graph.UpdateSizeFromWidthDepth();
graph.collision.heightMask = LayerMask.GetMask(“Terrain”);
AstarPath.active.Scan();
//Start the turns
turnController.start();
}