How to pass by a variable by reference in a function and set it in blueprints?
I'm not too new to the concepts in C++, I understand pointers, how they work, and I want to try to use something similar in blueprints if the system would let me.
I have a series of buttons that toggle their own bool when pressed and released. I recently discovered that my design is flawed because the Makey Makey I have buttons wired to only has an N-key rollover of 6. I'm redesigning my button scheme to instead of being held down to set a true and release to set as false, I'm going to tie them to a timer that sets their value to false after a few seconds. Given how the
Is there a better way to do a wait timer for what I want? I feel like I'm using this timer method incorrectly.
If what you want is to pass the bool by reference to the timer so it can change the state of the inputted variable without the need to return the value and set it again outside of the function, you can do exactly that.
Go inside the function that is called by your timer, and on the inputs tab, extend the properties of your boolean input. There should be a Pass-by-Reference checkbox that you can tick.
Then you can just set your boolean from inside the function to whatever you need.
All the best.
answered Jul 30 '16 at 03:16 PM
You can specify the function within the UMG widget BP which contains the button and boolean variable. So instead of drawing from the input boolean to set boolean to false, just create a new Set Boolean from the execution call.
In BP the main execution could look something like this:
Assuming you're using a UMG 2D UI layout, you can store the UI within a variable in your player character class. Then pass the value of the UI by reference after casting from your player character class. After you have obtained the UI value, you can pretty much access any function within the UI class that you have defined.
Edit: Forgot to add, there is nothing wrong with your set timer function. It should work fine.
Follow this question
Once you sign in you will be able to subscribe for any updates here