using System.Collections;
using System.Collections.Generic;
public class PathTest : MonoBehaviour {
public Node start;
public Node end;
public float threshold;
private List<Node> myPath;
private int currntNode;
// Use this for initialization
void Start () {
Debug.Log ("Breathwise search:");
List<Node> path = Pathfinding.BreadthwiseSearch (start, end);
for (int i = 0; i < path.Count; i++) {
Debug.Log (path [i].transform.name);
}
myPath = new List<Node> (path);
Debug.Log ("Depthwise search:");
path = Pathfinding.DepthwiseSearch (start, end);
for (int i = 0; i < path.Count; i++) {
Debug.Log (path [i].transform.name);
}
Debug.Log ("A* search:");
path = Pathfinding.AStar(start, end);
for (int i = 0; i < path.Count; i++) {
Debug.Log (path [i].transform.name);
}
}
// Update is called once per frame
void Update () {
//2 things
//-motion (as smooth as posible)
//-input(as responsive as posible)
transform.LookAt (myPath [currntNode].transform);
transform.Translate (transform.forward * 5 * Time.deltaTime, Space.World);
//this is not OK
float distance= Vector3.Distance(myPath[currntNode].transform.position,transform.position);
if (distance < threshold) {
currntNode++;
currntNode %= myPath.Count;
}
}
}
No hay comentarios:
Publicar un comentario