Hi all,
I’m a newbie scripter slogging my way through Sue Blackman’s book and I’ve made it to page 879 (huge triumph for me w/ all the scattered errata)
so unfortunatly,now I’m Stuck (w/ only 27 pages to go!)
Ive attached a snapshot of errors and the code snippet.
btw all errors are from the ‘for loop’
here’s the problem code section:
//Action Objects - get the list generated by the GameManager on Awake
var ao = GameObject.Find("Control Center").GetComponent(GameManager).actionObjects;
for (var x = 0; x < ao.length; x++){ //iterate througth the array of action objects
//save its current state
if(ao[x].active == true)
sWrite.WriteLine(ao[x].currentState);
else { //if inactive, wake it up longenough to save its current state
ao[x].active = true; //activate it
sWrite.WriteLine(ao[x].currentState);
ao[x].active = false;//deactivate it
}
// if it is an object that can be moved, store its current location/orientation
if (ao[x].dropType == 1) {
sWrite.WriteLine(ao[x].transform.position.x);
sWrite.WriteLine(ao[x].transform.position.y);
sWrite.WriteLine(ao[x].transform.position.z);
sWrite.WriteLine(ao[x].transform.localEulerAngles.x);
sWrite.WriteLine(ao[x].transform.localEulerAngles.y);
sWrite.WriteLine(ao[x].transform.localEulerAngles.z);
}
}//end for
if I do a print of the var ao (line 2), it returns a list of all the objects requested in the line:
var ao = GameObject.Find(“Control Center”).GetComponent(GameManager).actionObjects;
but then I get the errors attached.
I also understand the error, unless Im wrong, “var ao” is only an array list of the “action objects” from the script “Game Manager”, then in the lower section, in the for loop, I’m requesting a lot of information from each object (ie -is it active, transform, current state etc.) w/o contacting it.
btw this is from page 879 of her book is its helpful
Also - I’ve tried declaring the ‘var ao =…’ as ‘var ao: Array =…’ to no avail
thanks for any help - I hope this is somewhat clear.