I’m trying to do a Kruskal algorithm (pathfinding), but I’m having a problem when putting the nodes list in the list of list of nodes (each node is in a separate list and as the nodes connect, the lists are combined).
Here is my code:
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class Kruskal : MonoBehaviour {
public List<List<Nodo>> bosque;
public GameObject[] goNodos;
public List<Nodo> nodos;
void Start () {
goNodos = GameObject.FindGameObjectsWithTag("Nodo");
for (int i = 0; i < goNodos.Length; i++) {
nodos.Add(goNodos*.GetComponent<Nodo>());*
-
}* -
for (int i = 0; i < nodos.Count; i++) {*
bosque_.Add(nodos*); //It throws an error here. (NullReferenceException: Object reference not set to an instance of an object)
}*_
* }*
}
What am I doing wrong?