In the Level Blueprint I wanted to run one of two option depending on that same variable.
Unfortunately when I compile and run it, it shows that it’s always taggled off, and when i hover over “GoggleOn?” in the Level Blueprint, it says “variable is not in scope”. Any ideas of what could be the problem?
I’ve had this a few times and for me it’s seems to be when the variable isn’t being bound/referenced as intended. It could be that your GoggleOn? variable isn’t being read properly from your Kobu Reference. I’m very new to visual scripting so not sure how much I can help but perhaps try creating a local variable which you can Cast to from your Level BP. I’ve found getting communication a bit hard to get my head around. But i’ve managed to do similar by keeping inventory of items to pickup in a level and posting messages like “3 objects left” etc. The key ways I know so far are:
BP Interfaces.
Using a function (press the +f next to new variable)
Cast from one to another
Create a variable with type set to the BP Class you want access to (I think this is what you’ve done)
By using your method I also had a similar problem. Perhaps try one of the other methods until some one more knowledgeable can help out. Creating a function is good because you can call it from other classes easily. Same with BP Interfaces
I think Pixeldamage has good advice for the out-of-scope watch variable problem. I would also like to see the debug watch feature become more robust as it is an invaluable tool.
The reason your graphs don’t function properly might be due to using the latent delay node in your tick event. In general, you probably shouldn’t be using latent nodes (the ones with the clock icon in the upper right) in your tick events. You could use the timer manager to fire periodic events like this:
The principle is the same.
In C++, If you declare a variable inside one function, other functions can’t use that variable because it’s out of scope.
In blueprint, if you declare a variable inside one blueprint, the other blueprints can’t use that variable because it’s out of scope.
So what you have to do is to create a function, because this way you ask for the variable every time you call the function. So first you have to declare the function (click on the ƒ+ to create one) and specify one output parameter (boolean) then set it up like you see here. After that just call that function from the event graph.
There are many similarities with c++ but other blueprints can see any variable on the other instances (unless those are set to “private”) but the default behavior is for every variable to be public. In this case the problem was not using a function of other sort of mechanism to get the current (not the old) value
Yeah, that was it for me, as a programmer I fnid that weird that it does that only once…absolutely having a Getter function can be a good habit, but it’s still weird
Could be; I just wanted to get the point across of what’s happening and how to fix it; adding arguments to the function just makes it more confusing for beginners.