A* Pathfinding Project  4.0.5
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
WaypointPathTester.cs

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.Generic;
public class WaypointPathTester : MonoBehaviour {
public Transform[] targets;
// Use this for initialization
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();
}
// Update is called once per frame
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);
}
}
}