gives error:
NullReferenceException: Object reference not set to an instance of an object
Pathfinding.AstarData.RemoveGraph (Pathfinding.NavGraph graph) (at C:/Users/User/Desktop/Lumberjack Mills 2D/Assets/AstarPathfindingProject/Core/AstarData.cs:605)
Can you share any details about your setup? Most helpful would be screenshots of your scene, graph settings, agent settings, and the relevant code for when you call RemoveGraph().
public static bool Graph1 = true;
public static bool areaDone = true;
public int graphMask = 1;
// Start is called once before the first execution of Update after the MonoBehaviour is created
void Start()
{
}
// Update is called once per frame
void Update()
{
if (!Graph1 && !areaDone)
{
AstarPath.active.data.RemoveGraph(AstarPath.active.data.graphs[0]);
areaDone = true;
AstarPath.active.Scan();
}
}
Graph1 and areaDone become false when the guy leaves the box area
Ah I see, thanks for the information. Where does your agent move to when the graph is removed? And what’s the expected action, to simply stay where he was before the graph was removed?
Well if he’s outside the remaining graph when the first graph is removed that could cause issues. Is there a special reason you’re using two graphs in the first place and trying to remove the first?
so the first area has zombies and once it’s cleared, the main guy moves on and cannot go back so I remove the graph there which should activate the graph in the next area which has the boss zombie
You may want to just use a single graph then that spans the entire level, and turn your enemies behavior on or off when needed. So far I’m not seeing any use case here that a single grid graph can’t handle.
ok, i reduced the graphs to 1 but the boss zombie isnt moving even with all the components for ai path
also, my main char is still teleporting when he damages the boss even with the removegraph code gone
I think I need a little more information- what happens when they try to move, do they just never budge? Are they properly getting their destination and a path and just not moving? You can check the Debug information for more info too.
For a Grid Graph without a lot of obstacles you don’t need much density imo. You can get away with just default node size and just make your graph fit the scene and you’ll be good if not great in most cases. I can’t give a single number though as it’s dependent on the size of your play area.
Also your video isn’t playing- or playable at all for some reason. Try uploading it again elsewhere maybe?