Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class Node : MonoBehaviour {
- public GameObject[] neighbors;
- public GameObject goal;
- void OnDrawGizmos(){
- Gizmos.DrawWireCube (transform.position, Vector2.zero);
- foreach(GameObject neighbor in neighbors){
- Gizmos.DrawLine(transform.position, neighbor.transform.position);
- Gizmos.DrawWireSphere(neighbor.transform.position, 0.25f);
- }
- if (goal) {
- GameObject current = gameObject;
- Stack<GameObject> path = DijkstraAlgorithm.Dijkstra(GameObject.FindGameObjectsWithTag("Node"), gameObject, goal);
- Debug.Log ("Got here:");
- Debug.Log (path);
- foreach(GameObject obj in path){
- Debug.Log ("Got here also:");
- Gizmos.color = Color.green;
- Gizmos.DrawWireSphere(obj.transform.position,1.0f);
- Gizmos.DrawLine(current.transform.position, obj.transform.position);
- current = obj;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement