Hi there,
Sorry for posting this as it seems absurd I can not firgure this out, but I am continaully getting a NullExceptionReference.
I have a List of roads (road_script), in a roadsMng. The roadsMng at start asks roads[0], to perform a task. The road does, however I immediately get a message back of null reference exception. I have not removed or asked anything else to happen.
Scratching my head.
public List<roadsScript> roads;
///roads mng
void Start(){
roads[0].doThis();
}
//road script
public void doThis(){
//this road does this.
}
I then get the error referencing the line 1 of Start in the roads mng.
!!!***
did you initialise the roads array to contain “things”? i.e. some sort of for loop putting something in each array “slot”? or did you just declare that an array of “slots for things” exist?
If the slots haven’t been filed with something trying to call a function from something that isn’t there will cause this error message.
They are all filled, it is a list, not an array.
Array or list… same thing. You did put something in it?
can we see the code that puts things in the list?
///roads mng, prints all return correct values.
void Start(){
print("roads[0] " + roads[0].transform.name);
print("roads[1] " + roads[1].transform.name);
print("roads[2] " + roads[2].transform.name);
print("roads[3] " + roads[3].transform.name);
print("stat node " + StartNode.name);
roads[0].getRoad(StartNode);
}
///road script...
public void getRoad(Transform lastRoadEndNodeDel){
///this road section is loaded....
//set parent
transform.parent = moverTransform;
//remove from list
RoadsMng_Data.roads.RemoveAt(0);
///place start point at last road end point
transform.localPosition = lastRoadEndNodeDel.localPosition;
///movement handled by the main roads mng, player controller
//report back to roads mng, of this end point
RoadsMng_Data.endNode = endNode;
}
??
AH HAH!!!
So Sorry,
I had duplicated the mng, to use as another transform and forgot to remove the mng component.
#Monday