I’m feeling rather ineffectual at the moment - I’m attempting to grab a width value from a script attached to a GameObject using GetComponent for each item in an array of GameObjects.
Except - it likes to tell me the “Object reference not set to an instance of an object.”
public GameObject[] chunks;
private LevelChunk[] levelChunks;
void Start () {
for (int x = 0; x < chunks.Length; x++)
{
levelChunks[x] = chunks[x].GetComponent<LevelChunk>();
print (levelChunks[x].width);
}
What am I doing wrong here?
Thanks for any help.