I am having trouble on debugging value of a bool

So I have this bool, that doesn’t seem to be changing from False to true like it’s supposed to. The only way for me to confirm this is to make a debug statement that will return the current status of the bool when it’s meant to change. I think I should put the statement in an Update function in the script. The problem is, I cannot find an answer to how I would code the statement. I know it’s something simple, but I can’t remember.

i’m confused about what your problem is. you can just debug.log(yourbool) wherever you like but adding code to your question would help a lot.

I tried to do Debug. Log(yesSelected); in an update function, I got the error that the yesSelected had no context, so I posted it here. I will not that the bool is established in a function further down the script if that makes a difference.

You can’t reference a variable in one function, if it’s defined in a different function. It has to be declared in the same function and before the Debug.Log, or at the class level.

are you checking the bool on the same script that contains it?

are you setting a default value for your bool?

are you even setting it before checking for it?

please upload code so i can help you more without the guesswork :slight_smile:

edit: as arachnidanimal said, if you’re just trying to use the bool in another script without getting a reference to the object (and if it’s private you won’t be able to either), then your other script has no way of knowing the bool exists.

Follow these instructions and stop wondering how your code executes and what your variable’s values are:

1 Like