Question by
BrightFyre · May 27, 2020 at 07:06 PM ·
scripting problemarrayboolean
Checking multiple game objects with the same script for a bool
I'm making a game where to open a door, you need to walk over several platforms. As you walk over them, they change colors and make a bool return as true. I want the script to check all the different scripts, and if all of them return the bool as true, it will open the door. public ColorChangeBlock[] turnColors; public bool allAreTouched = false; void Update() { if (allAreTouched) { Debug.Log("All Are Touched"); } foreach (ColorChangeBlock turnColor in turnColors) { if (turnColor.touched) { allAreTouched = true; } else { allAreTouched = false; } } }
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612235426im_/https://answers.unity.com/themes/thub/images/avi.jpg)