Example usage of the WaypointPath example script.This script shows example usage of the WaypointPath example script.
- See Also
 - WaypointPath.cs example
 
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class WaypointPathTester : MonoBehaviour {
    public Transform[] targets;
    
    void Start () {
        Vector3[] ps = new Vector3[targets.Length];
        for (int i = 0; i < targets.Length; i++) ps[i] = targets[i].position;
        WaypointPath p = new WaypointPath(ps, OnPathComplete);
        p.StartPath();
    }
    
    void OnPathComplete (WaypointPath p) {
        if (p.HasError()) {
            Debug.LogError("Noes, could not find the path!");
            return;
        } else {
            List<Vector3> vp = p.vectorPath;
            for (int i = 0; i < vp.Count-1; i++) Debug.DrawLine(vp[i], vp[i+1], Color.red, 2);
        }
    }
}