unitysteer and path

Hello,

i'm trying to implement unitysteer with path combined! first i have build opon the path demo to figure Path out. i got it working and my object is following a path.

Now i want it to combine with unitysteer. i proberly need to use AngryAntPathway to constuct my pathway from an arraylist of path and such. But i could not get it to work. perhaps any1 has an example?

Here's some sample code, snipped from a larger project. You'll need a MonoBehavior that is an ISearchMonitor (for Path).

public class Ship : MonoBehaviour, ISearchMonitor, IRadarReceiver {

In this case we have three properties; the first is the list of nodes returned by Path, the second a path seeker, and finally a UnitySteer PathFollower vehicle.

protected ArrayList path;
protected Seeker seeker;
private PathFollower shipVehicle;

On the behavior start we initialize the PathFollower vehicle to the current object's transform. Notice that this vehicle did not move vertically, but that was specific my implementation case.

protected void Start () {
    shipVehicle = new PathFollower(this.transform, 1, null, radius);
    shipVehicle.MovesVertically = false;
    shipVehicle.MinCollisionTime = 2;
    shipVehicle.MaxSpeed = maxSpeed;
    shipVehicle.Mass = 0.1f;
    shipVehicle.MaxForce = maxForce;
    shipVehicle.AvoidDeg = 30;
}

The GoTo method is pretty much Path boilerplate - it creates a seeker, adds a monitor and starts it on the control. I'm just adding it here for reference purposes.

public void GoTo(Vector3 destination)
{
    seeker = new Seeker( transform.position, destination, maxFrameTime, radius, null );
    if( seeker.Start != null && seeker.End != null )
    {
        this.Moving = true;
    	seeker.AddMonitor(this);
    	Control.Instance.StartSeeker( seeker );
    }
}

When we receive a notification that the search was completed, we create a UnitySteer AngryAntPathway based on the resulting path ArrayList, and pass it to the vehicle for following.

public void OnSearchCompleted( Seeker seeker )
{
    this.seeker = null;
    this.path = seeker.Solution;
    this.destination = seeker.To;

    if (this.path == null) 
    {
        return;
    }

    if (seeker.Start != seeker.End)
    {
        shipVehicle.Pathway = new AngryAntPathway(path, 0.25f, false);
    }
    else
    {
        shipVehicle.Moving = false;
    }

}

And finally, if we have a path, on Update we tell the vehicle to update our position.

protected void Update () {
    if (path == null) return;
    shipVehicle.Update(Time.deltaTime);
}

That's it. :-)