Error Queue and StartPath (A* pathfinding)

i have a problem about the Seeker.cs script. i write a javascript code for Enemy Orb. And Also i use the AIFollow.cs on my orb.

Here is te code:

var target : Transform;
var myPosition : Vector3;
var enemies : Transform[];
var counterHit : int;



var damping = 6.0;

function Start () 
{    
	counterHit=0;
	GetEnemies();    
	myPosition = transform.position;    
	target = FindClosest(enemies);
	
}

function Update(){

	this.transform.position.y=20;
	
	GetEnemies();
	myPosition=transform.position;
	target=FindClosest(enemies);
	
	this.GetComponent("Seeker").StartPath(this.transform.position,target.position); //Use The Seeker.
	
	var rotation = Quaternion.LookRotation(target.position - transform.position);
	transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * damping);
	
	
}



function GetEnemies () 
{    
		var enemyObjects = GameObject.FindGameObjectsWithTag("Target");    
		enemies = new Transform[enemyObjects.Length];    

		for (i = 0; i < enemyObjects.Length; i++) 
		{        	
				enemies[i] = enemyObjects[i].transform;    
		}
}

function FindClosest (targets : Transform[]) : Transform 
{    

		var closestDistance = (enemies[0].position - myPosition).sqrMagnitude;    
		var targetNumber = 0;    
		
		for (i = 1; i < targets.Length; i++) 
		{        
				var thisDistance = (enemies[i].position - myPosition).sqrMagnitude;        
				if (thisDistance < closestDistance) 
				{            
								closestDistance = thisDistance;            
								targetNumber = i;        
				}    
		}    
	return enemies[targetNumber];
}

i put the drone more than 10 (and there are 10 EmptyGameobject in the scene, they make clone of orb when the Orbs are destroyed) . During cloning of the Orbs , Orbs do not move anywhere. And they do not work…

In my A* object here is the Advanced Values:

Heap Size : 0.5;

Path Queue Size : 5000;

Here is first error:

[COLOR="red"]MissingReferenceException: The object of type 'Seeker' has been destroyed but you are still trying to access it.[/COLOR]
Your script should either check if it is null or you should not destroy the object.
Seeker.OnComplete (.Path p) (at Assets/AstarAI/Standard Assets/Pathfinding/Seeker.cs:182)
AstarPath+<CalculatePaths>c__Iterator4.MoveNext () (at Assets/AstarAI/Standard Assets/Pathfinding/AstarPath.cs:557)

There is another error after The first error is showed :

[COLOR="red"]To Many Paths In Queue, please increase queue size or call StartPath less often[/COLOR]
UnityEngine.Debug:LogError(Object)
AstarPath:StartPath(Path) (at Assets/AstarAI/Standard Assets/Pathfinding/AstarPath.cs:490)
Seeker:StartPath(Vector3, Vector3) (at Assets/AstarAI/Standard Assets/Pathfinding/Seeker.cs:270)
Seeker:Seeker$StartPath$UnityEngine.Vector3$UnityEngine.Vector3(Object, Object[])
UnityScript.Lang.UnityRuntimeServices:Invoke(Object, String, Object[], Type)
WorkerWayFinder:LateUpdate() (at Assets/Scripts/WorkerOrb/WorkerWayFinder.js:48)

How can i fixed the problem ?

There are some screenshots from my project…

Any Help i will appriciate…

477083--16743--$Statistics.jpg



i handle it :slight_smile: it requires the control of the StartPath() function. An Example:

function Update(){

 if(!target){  //This control the StartPath() function.You call it less often. 

 GetEnemies();
 FindClosest();
 
 this.GetComponent(Seeker).StartPath(transform.position,target.transform.position);

 }

}