I have a Function that has a simple “Flip/Flop” script inside it. But when my main blueprint calls this function from a ClickOn event, the Flip/Flop does not work properly. It always picks A. Any solution or suggestions?
Where do you store the flipflop state value?
Well the flipflop is inside the custom made function. The flipflop itself didn’t have any variables or anything if thats what you mean?
The flipflop needs to store its current state somewhere, right?
How else would the flipflop know what state to transitin into when triggered…?
Ok. I will create a Boolean variable for it to store its state and give that a try. Thanks for the feedback!
just be aware that local variables are not preserved between function calls (which was my initial suspicion in your case)…
I was not able to get the flip/flop method to work, but I did get it to work using a Branch and a non-local variable. But thanks for your feedback!
KVogler is right, the FlipFlop appears NOT to work because the function graph is not “persisted”.
To get a little abstract, essentially every function call is a unique instance of that function at run time. Everytime you call the function, the FlipFlop contained begins from its initial state.
Sorry, I probably didn’t explain that very well.
Make Macro instead of function, macros can have 2 execute outputs in return node.
And yes make variable.
Or play with blueprintable component, that has such function.
I think you can double click on FlipFlop node to open it, as it’s actually a macro and check what it does internally.
That is because like in most programming languages, a variable is “destroyed”, once it goes out of scope.
And the scope of local function variables, as their name implies, is only the function body…
What is really a bit surprising for me is the fact that the “array item” pin of a loop also get invalid after exiting the loop.
In coding, you can usually access the last iteration data, so I have to work around that as well to make some of my usual routines work…)