I have a script called "switcher" on the parent GO with a public bool called "end" and a starting value of "false". I want one child to set "end" to "true" and have all its siblings know that. I'm using GetComponentInParent and it works, but only if I *directly* address it every time like so on the child: Code (CSharp): if(someConditionOnChild) { gameObject.GetComponentInParent<switcher>().end = true; } and like so on the siblings Code (CSharp): if( gameObject.GetComponentInParent<switcher>().end == false ) { //go ahead and do stuff } But if I try referencing it, like: Code (CSharp): public bool myEnd; public switcher mySwitcher; void Start () { mySwitcher = gameObject.GetComponentInParent<switcher>(); myEnd = mySwitcher.end; } void Update () { if(someConditionOnChild) { myEnd = true; } if(myEnd == false) { //go ahead } it doesn't work. Any clues most appreciated.
The issue is bools are value types, not reference types. You essentially are setting myEnd = to the value of mySwitcher.end. Which means it simply gets the value and applies that to the myEnd variable. If you want to change the parents value, you'll want to do it by accessing mySwitcher.end