I am working on a endless runner game played on a road, im just working on basic pooling system right now and no matter how much at stare at this code i cannot understand why it keeps giving me the error:
" UnassignedReferenceException: The variable prefabcar of DestroyObst has not been assigned.
You probably need to assign the prefabcar variable of the DestroyObst script in the inspector."
even though i have set the variable in the inspector abt 100 times.
Just some brief context im spawning all of the objects in the beginning and adding them into a list so i can track them and reuse them through out the game.
Vector3 inactivespawn = new Vector3 (0f, 20f, -10f);
public static List<GameObject> Cars = new List<GameObject> ();
public static List<GameObject> Supercars = new List<GameObject> ();
public static List<GameObject> Trucks = new List<GameObject> ();
public GameObject prefabcar;
public GameObject prefabsupercar;
public GameObject prefabtruck;
void Awake(){
}
void Start () {
for (int i = 0; i <=35; i++) {
Cars.Add((GameObject) Instantiate(prefabcar, inactivespawn, Quaternion.identity));
Cars[Cars.Count-1].SetActive(false);
Supercars.Add((GameObject) Instantiate(prefabsupercar, inactivespawn, Quaternion.identity));
Supercars[Supercars.Count-1].SetActive(false);
Trucks.Add((GameObject) Instantiate(prefabtruck, inactivespawn, Quaternion.identity));
Trucks[Trucks.Count-1].SetActive(false);
}
}