AI Script behavior: Multiple target

Hello,

I made my own AI script base on the Mine Bot Ai script given as exemple in the free A* version.
It’s actualy working great: my AI is following the target, calculating the shorter path, updating it if necessary.

Now I want to have the possibility to have multiple target and the AI will choose the closest one. I saw the part about Multiple target free (http://arongranberg.com/astar/docs/_multi_target_free_8cs-example.php).
But I don’t know how to integrate this in my own script.
I’m actualy knowing a little bit about script, but I’m not skill enough to do that.
Can someone help me with this please?

There is my code:
`using UnityEngine;
using System.Collections;
using Pathfinding.RVO;

namespace Pathfinding {
/** AI controller specifically for basic AI with no animation
*/
[RequireComponent(typeof(Seeker))]
public class AIFollowV2 : AIPath {

	/** Minimum velocity for moving */
	public float sleepVelocity = 0.4F;
	
	/** Effect which will be instantiated when end of path is reached.
	 * \\see OnTargetReached */
	public GameObject endOfPathEffect;
	
	public new void Start () {
		//Call Start in base script (AIPath)
		base.Start ();
	}
	
	/** Point for the last spawn of #endOfPathEffect */
	protected Vector3 lastTarget;
	
	/**
	 * Called when the end of path has been reached.
	 * An effect (#endOfPathEffect) is spawned when this function is called
	 * However, since paths are recalculated quite often, we only spawn the effect
	 * when the current position is some distance away from the previous spawn-point
	*/
	public override void OnTargetReached () {
		
		if (endOfPathEffect != null && Vector3.Distance (tr.position, lastTarget) > 1) {
			GameObject.Instantiate (endOfPathEffect,tr.position,tr.rotation);
			lastTarget = tr.position;
		}
	}
	
	public override Vector3 GetFeetPosition ()
	{
		return tr.position;
	}
	
	protected new void Update () {
		
		//Get velocity in world-space
		Vector3 velocity;
		if (canMove) {
		
			//Calculate desired velocity
			Vector3 dir = CalculateVelocity (GetFeetPosition());
			
			//Rotate towards targetDirection (filled in by CalculateVelocity)
			RotateTowards (targetDirection);
			
			dir.y = 0;
			if (dir.sqrMagnitude > sleepVelocity*sleepVelocity) {
				//If the velocity is large enough, move
			} else {
				//Otherwise, just stand still (this ensures gravity is applied)
				dir = Vector3.zero;
			}
			
			if (navController != null) {
			} else if (controller != null)
				controller.SimpleMove (dir);
			else
				Debug.LogWarning ("No NavmeshController or CharacterController attached to GameObject");
			
			velocity = controller.velocity;
		} else {
			velocity = Vector3.zero;
		}
		
		
		//Animation
		
		//Calculate the velocity relative to this transform's orientation
		Vector3 relVelocity = tr.InverseTransformDirection (velocity);
		relVelocity.y = 0;

	}
}

}`

I hope you can light me on this problem :slight_smile:
Thanks