Getting an exception when calling WaitForPath in editor (non-playing)

Hi. I’m trying to call WaitForPath on a MultiTargetPath while in the editor (not in play mode):

// My code
var p = MultiTargetPath.Construct(origin, targets, onPathCompletes, OnPathComplete);
p.pathsForAll = true;

I’m getting the following exception:

 System.NullReferenceException: Object reference not set to an instance of an object
  at AstarPath.WaitForPath (Pathfinding.Path p) [0x00148] in /Users/mikelaurence/projects/lunar-lockdown-2d/Assets/AstarPathfindingProject/Core/AstarPath.cs:2244

This is what’s at AstarPath line 2244:

//Calculate some paths

Any suggestions for how to move forward here?

I’m on v 3.8.12.


3.x does not have support for using pathfinding outside of play mode.
4.1.x does have that however, you can take a look at the docs for it here:

Great – I upgraded and it works, thanks!

1 Like