Use Local Variables in Macro

Hi, I’m trying to make a macro to plug into inputs that check if you’re pressing the button once, double tapping it, or holding it, and it works fine except for when I use 2 buttons at the same time with this macro, because the ‘Button Pressed’ isn’t a local variable, it changes when any of the buttons are pressed, so I can press one button, then a second button, and it will register as a double tap with the second button. How would I make the variable a local variable? I’d use functions but you can’t have multiple Input execution pins or use Delay nodes…

Here’s what I’ve got so far:

Looks like a bit of a ‘mare’…

You can have local variables in macros, but are horrid to work with.

I’d advise doing this with a function. You get proper local variables, and you can multple return routes. It wont take 5 mins, just copy and paste most of it… :slight_smile:

What would I do about the second input execution pin? And the 4 different output execution pins? Since I can only have one on each in a function, and I need them all for it to work as intended…

And also the 2 delays and 1 retriggerable delay? Since delays aren’t allowed in functions either :confused:

If there is no workaround to them, then how would I use local variables in the macro? They might be horrid to work with but I assume it will still do the job?

Here’s what it’s being used for, I have some inputs that are different depending on if you’re using a keyboard or controller, some things execute when held on controller, but only need to be pressed on keyboard, etc…

Ah, execution pins, then you’re stuck with local variable in the macro. Should have looked more closely :-/

Right click in the background of the macro and search for local. The way you have to assign them is messy:

setlocal.JPG

1 Like

Ah thank you, I’ve changed all of the booleans to these local booleans, but it’s still registering as me double tapping the second button if I tap the first one and then a second one straight away, it doesn’t seem to have made any difference :confused:

Since the Local Boolean is just one node without a naming system, does it only count as one variable no matter how many nodes you use? So you can only have one local boolean variable in the whole macro? Because my macro uses 2 booleans, one for ‘Button Pressed?’, and one for ‘Double Tap’. I’m thinking that’s the case, it’s not working because I tried using one ‘Local Boolean’ node as its own variable, and replaced all of the ‘Set/Get Button Pressed?’ references with the ‘Set Boolean (by ref)’ linking the target to that one ‘Local Boolean’ node, and then have a second ‘Local Boolean’ node for ‘Double Tap’ and do the same.

If that’s the case, is there any way to use 2 different local boolean variables in the same macro?

I think 2 nodes = 2 bools. Best to try it out.

1 Like

I just passed by to confirm this (I just realized). If you need to get a reference to a variable in a macro, all the wires must come from the same node.
Thanks!

2 Likes

there is no set boolean (by ref) or set local boolean in macros in unreal 5.3.2

1 Like

Well, it’s miraculously back in 5.5 :slight_smile:

You have to get the search term right, could that be it?

They have to be there, as lots of the default Epic stuff uses them.