I’m using the AIFollow script on all my enemy GameObjects, which I have in a pool which I enable/disable as needed.
Since I upgraded to Unity 4 and the latest A* Pathfinding build, I’m getting this error:
Coroutine couldn't be started because the the game object 'Bat(Clone)' is inactive! UnityEngine.MonoBehaviour:StartCoroutine(IEnumerator) AIFollow:OnPathComplete(Path) (at Assets/Plugins/AstarPathfindingProject/ExampleScenes/ExampleScripts/AIFollow.cs:82) Seeker:OnPathComplete(Path, Boolean, Boolean) (at Assets/Plugins/AstarPathfindingProject/Core/AI/Seeker.cs:296) Seeker:OnPathComplete(Path) (at Assets/Plugins/AstarPathfindingProject/Core/AI/Seeker.cs:257) Pathfinding.Path:ReturnPath() (at Assets/Plugins/AstarPathfindingProject/Core/Path.cs:583) AstarPath:ReturnPaths(Boolean) (at Assets/Plugins/AstarPathfindingProject/Core/AstarPath.cs:1939) c__Iterator9:MoveNext() (at Assets/Plugins/AstarPathfindingProject/Core/AstarPath.cs:1891)
It links me to this section of the code:
` /** Called when a path has completed it's calculation */
public void OnPathComplete (Path p) {
/*if (Time.time-lastPathSearch >= repathRate) {
Repath ();
} else {*/
StartCoroutine (WaitToRepath ()); // <~~ CAUSE OF ERROR
//}
//If the path didn't succeed, don't proceed
if (p.error) {
return;
}
//Get the calculated path as a Vector3 array
path = p.vectorPath.ToArray();
//Find the segment in the path which is closest to the AI
//If a closer segment hasn't been found in '6' iterations, break because it is unlikely to find any closer ones then
float minDist = Mathf.Infinity;
int notCloserHits = 0;
for (int i=0;i<path.Length-1;i++) {
float dist = Mathfx.DistancePointSegmentStrict (path[i],path[i+1],tr.position);
if (dist < minDist) {
notCloserHits = 0;
minDist = dist;
pathIndex = i+1;
} else if (notCloserHits > 6) {
break;
}
}
}`
Any suggestions on how to avoid the error? Although it seems relatively harmless…