A* Pathfinding Project ,,, how to use the Seeker in the code ?

hey all

i am using a arongranberg’s project the " pathfinding-project " and i follow the tutorial in that website
Here

and then write the code in that website like this :

using UnityEngine;
using System.Collections;

using Pathfinding;

public class AstarAI : MonoBehaviour {
	public Vector3 targetPosition;
    public void Start () {
        Seeker seeker = GetComponent<Seeker>();
        //Start a new path to the targetPosition, return the result to the MyCompleteFunction
        //seeker.StartPath (transform.position,targetPosition, MyCompleteFunction);
		seeker.StartPath (transform.position,GameObject.Find("target").transform.position, MyCompleteFunction);
    }
    
    public void MyCompleteFunction (Path p) {
		
        Debug.Log ("Yey, we got a path back. Did it have an error? "+p.error);
    }
}

and then add the component Seeker to the game object when i run the game the line (Gizmo) is appear from the start point to the target in the scene, but how I can use the Seeker class in the code ? when I start to write Seeker nothing show like it doesn’t exists and when use the “seeker” object with the dot ( seeker. ) no method or variable appear ?

second thing can i apply the same idea but not on game object but on first person controller .

last thing how to make a specific object follow that path ?

i really need your help

You should probably look into using the path finding system that comes with Unity 3.5 instead of this one. I’ve used Aron Granberg’s system in another project and it worked great, but I think the system in 3.5 is better.

That said, if you still want to use Aron’s system it seems like you’re saying that the Seeker class is not available. You should make sure that it’s in the project and that it is being compiled before the script you’re trying to use it from. Having the script you’re writing and the path finding scripts in your ‘Scripts’ folder should do the trick.

1 Like