A* Pathfinding Project

Seeker.GetCurrentPath() returns a Path with NULL .path & .vectorPath


#1

Does anyone know why seeker.GetCurrentPath() returns a Path which sometimes has a valid .path & .vectorPath and sometimes doesn’t? I understand it’s set on a separate thread so I call;

if (!path.error && path.vectorPath != null)

I can see the blue debug line on RichAI pointing to the nextCorner so there must be a reference somewhere. Just when I want to access it, it’s only occassionally there?

Thanks in advance.


#2

Hi

Sorry for the late answer. I have been traveling and have not been able to answer support requests for some time.
The GetCurrentPath method returns the last path that was started using seeker.StartPath. This path may not have been calculated yet which is why it sometimes has a null vectorPath.
The RichAI movement script actually doesn’t save the path instance anywhere because it doesn’t need it.
You could access it by overriding RichAI.OnPathComplete. However then you need to make sure to also call path.Claim(this) on the path, and then later when you are done with the path object you should call path.Release(this). See https://arongranberg.com/astar/docs/pooling.html.