Continuously monitor childrens properties
Hello guys,
im back with another question. There an object with few hundreds children. At some point through player interaction the variable public bool done = false;
of evry child will become true
. My intetntion is to monitor all the objects at once through the parent.
Some code for the parent (as i imagine it):
void Update () {
if (for(int i = 0; i < children; i++) children[i].GetComponent<Child_Script>().done = true;) {
Debug.Log ("all done");
}
}
What are your thoughts, I reached a dead end of some kind.
Greetings
Rather than continuously spam$$anonymous$$g GetComponent, set up the script reference with GetComponent One Time in Start() and then you can simply use the dot operator to refer to members of that script. Doing it this way is much much faster.
Answer by Konomira · Oct 16, 2015 at 02:09 PM
you only have one = in your if statement, the program thinks you're assigning a value. use == to check if one variable is equal to a state.
Your answer
Follow this Question
Related Questions
Can someone please help me find out what wrong with my code. 1 Answer
Does anyone have a good script that can be used to make a horse/vehicle rideable? 0 Answers
How would i modify my current script to remove these UI buttons without killing my pause menu? 1 Answer
Why does NetworkServer.ReplacePlayerForConnection not recognize the instantiated object parameter? 0 Answers
I get a "NullReferenceException" when trying to change the text of a UI text box. 1 Answer