Local Variables "Out of Scope" and not firing on conditionals

This bug thread is created based on conversation here: [Blueprint Local Variables are Unique? - Blueprint - Epic Developer Community Forums][1]

During testing for a bug on scope of local variables, I created a function that takes three integer inputs, assigns them to local variables, performs a check, and then sends a exec signal out to fire same function again with different inputs if check is true.

local variables are considered ‘out of scope’ , conditional check is never called ( if iUnitA % iUnitLength == 0), and If conditional always returns true. What is really strange is that at end of two of same function being daisy chained together, final output variable has in fact been updated which leads me to suspect that local variable assignment IS taking place, and that this is simply a case of conditional never firing which resets input variables to 0 at each call.

Question 1: When viewing graph of a function by double-clicking on function in event graph, does it take you to main function graph, or to an instance of function graph specific to one being clicked?

Question 2: Could 'Variable Out of Scope" message be because editor does not know which version of function you are looking at? (two of same function fires and it doesn’t know which one to watch)

Question 3: Why didn’t conditional check fire inside function?

20337-worldclock_function_1.png

Thanks RAVaught,

I’ll try reproducing this issue with a simpler setup to narrow down problem. In meantime, if you feel comfortable attaching .uasset for this Blueprint, I can take a look at it. I’ll let you know when I have some information for you.

Sure, no problem. See attached … (Wouldn’t let me attach .uasset file directly)

Regards,
link text

Hey ,

When you watch a Blueprint during play, all of information, including function, belongs to instance of Blueprint that you are watching in Debug Filter. So when you double-click a function, it takes you to function running inside that same instance.

It looks like Local Variables being out of scope is a known issue, and has already been reported in UE-2821. I have added a note with your information, and I will let you know if I see an update. Being out of scope does not stop them from working, however, and does not mean that you’re looking at wrong instance of Blueprint.

problems you’re running into stem from order in which your nodes are firing. Functions are meant to happen instantly, but if there’s a lot going on inside them they can screw up order. To see what’s happening in your Blueprint, place a breakpoint on Set Cur Seconds node right before first Update Time Units function, and then PIE. Then step through each node, and you’ll see it stop at branch inside function and go back out to event graph to begin second function. Obviously this sets your inputs incorrectly, which will probably lead to an incorrect result.

I don’t see anything in function that should be causing this to happen, however, so I will continue investigating and let you know what I find. In meantime, running function inside of a Custom Event instead of a Function should clear up some of this problem, though you won’t be able to use Local Variables with that.

Additionally, if I understand it correctly, you’re using first part of Blueprint to calculate seconds? It’s generally best to avoid putting events on Tick if possible, as it eventually will get bogged down, and in this case using a Timer is probably a much easier and safer option for project in long run. You can set Time to 1 and have Function or Custom Event loop based on that Time.

I’m leaving this post unresolved for now so I can see why your function is upsetting order, but I hope some of this helped for now!

I kind of suspected first part of what you said there. I could tell variables were getting set somehow because hour variable at end was updating, I just couldn’t figure out how they were making it through conditional branches when I knew conditions weren’t being met.

Thanks for heads up regarding stepping through code, I will take a look at that tonight. I am more of a designer than a programmer, so there are definitely some of more nuanced elements of good program design and processes that I am unaware of. Someone else had mentioned timers as well, but this was more of a proof of concept for setting up a custom in game calendar and event Tick system. I would not dream of putting that in a final project.

By way, I’ve seen you mention bug reports several times now. Is there somewhere we can check to see bug list so that we don’t take up time feeding back on bugs that are already being addressed?

Thanks

Unfortunately no, right now we put them in answers so we can check them easily later. More of an internal reference. Don’t worry about reporting things that have already been reported; if you can’t find it doing a search on AnswerHub, it’s very likely that it hasn’t been reported yet and it’s our job to look into it.