How to change scenes/ destroy 'Astarpath' without errors?

Basic question: How do I avoid errors when switching scenes. Im guessing it has something to do with ending all threads. Maybe call FlushGraphUpdates before switching scenes? It only happens occasionally so I want to make sure I’m using the ‘best practice’.

thanks

Hi

What error are you seeing?

Ok I fixed it. I was subscribed to AiLerp.OnPathFound in a behavior tree node. I put a null reference check for AstarPath.active in the AiLerp.SearchPath

NullReferenceException: No AstarPath object found in the scene. Make sure there is one or do not create paths in Awake
Pathfinding.Path.Reset () (at Assets/AstarPathfindingProject/Core/Path.cs:493)
Pathfinding.ABPath.Reset () (at Assets/AstarPathfindingProject/Pathfinders/ABPath.cs:143)
Pathfinding.Path.Pathfinding.IPathInternals.Reset () (at Assets/AstarPathfindingProject/Core/Path.cs:806)
Pathfinding.PathPool.GetPath[ABPath] () (at Assets/AstarPathfindingProject/Core/Misc/PathPool.cs:73)
Pathfinding.ABPath.Construct (Vector3 start, Vector3 end, Pathfinding.OnPathDelegate callback) (at Assets/AstarPathfindingProject/Pathfinders/ABPath.cs:85)
Pathfinding.Seeker.StartPath (Vector3 start, Vector3 end, Pathfinding.OnPathDelegate callback) (at Assets/AstarPathfindingProject/Core/AI/Seeker.cs:350)
Pathfinding.Seeker.StartPath (Vector3 start, Vector3 end) (at Assets/AstarPathfindingProject/Core/AI/Seeker.cs:338)
Atomicrops.Game.Pathfinding.AiLerpAtom.SearchPath () (at Assets/Atomicrops/Scripts/Game/Pathfinding/AiLerpAtom.cs:38

Hi

Yeah, that looks like you are trying to search for a path while there is no AstarPath component in the scene. Possibly that callback that you have registered to is called when the AstarPath component has been destroyed.