Why can't i change the boolean?

First, remember the first rule of GameObject.Find():

Do not use GameObject.Find();

More information: Regarding GameObject.Find · UnityTipsRedux

More information: Why cant i find the other objects? - Unity Engine - Unity Discussions

In general, DO NOT use Find-like or GetComponent/AddComponent-like methods unless there truly is no other way, eg, dynamic runtime discovery of arbitrary objects. These mechanisms are for extremely-advanced use ONLY.

If something is built into your scene or prefab, make a script and drag the reference(s) in. That will let you experience the highest rate of The Unity Way™ success of accessing things in your game.

“Stop playing ‘Where’s GameWaldo’ and drag it in already!”

Here’s why all this stuff is CRAZY code:

Second, NOTHING needs to be a coroutine there: you’re doing everything in one frame. If you don’t understand that, hurry to a coroutine tutorial.

Coroutines in a nutshell:

Our very own Bunny83 has also provided a Coroutine Crash Course:

Coroutines are NOT always an appropriate solution: know when to use them!

“Why not simply stop having so many coroutines ffs.” - orionsyndrome on Unity3D forums

2 Likes