I have a script, with 2 functions. These 2 functions are called at different moments, by another script on another gameObject.
The first function, creates a variable (it's the length of an array that this 1st function creates at runtime using "GameObject.FindGameObjectsWithTag").
I want to use this variable that the 1st function creates in the 2nd function, but when I put it in the 2nd function like this:
I get the error:
"varName" is not a member of 'function ():void'
What should I do then, to use in the 2nd function, the variable that the 1st function creates?
You need to declare the variable outside of the functions. That way, it's in the scope of the class, which lets you use it from both functions
answered Jan 15 '11 at 09:12 PM