MultiGate Doesnt Work Inside Functions

I am finding something weird as I clean up event graphs by taking inputaction events (aka an action mapping) that execute x number of nodes and turning those nodes into a function.

When I use an action mapping for something bound to say F3 (using it to switch camera components on a pawn) when I have a multigate set to loop == true, start index -1 and is random == false then Out0 changes to one camera, Out1 switches to next, and it repeats.

This works fine in event graph.

When I take gate and nodes after it and put them into a function however, It will only execute Out0.

I even tried Out0 and Out1 to be simple print strings, It will only execute Out0 no matter how many times I press f3 ( input action event) and I tried just using a regular key event too.

How to replicate:
-Create an action mapping in project settings to key of your choice
-Put InputAction ‘your_name_here’ node into event graph
-Create a function and have input action (or even just a simple key event) call it on “presssed”
-In function have it execute a gate (Like I said im using is random = false, loop = true, start index = -1, but settings dont matter) and have out0 PrintString > “hello world” and have out 1 PrintString > “Hello world again”,

Only out0 aka “Hello world” will be printed.

Heres what does not work, CamSwitch is funcition being called by a keyevent or action mapping/input action


Here is what does work… exact same thing just, not in a function

Hi ,

Thanks for screenshots! I was able to reproduce this issue in 4.7.4 as well as our main internal build, and I’ve entered a bug report for it (UE13209). I’ll let you know as soon as I see an update on it. Thanks!

Hi ,

So this is unfortunately (somewhat) by design. It can be frustrating and confusing in some scenarios (like yours), but in others, it can be equally as confusing. current behavior lets you utilize a multigate in a function without worry of having to reset it (what if you’re using it in a for loop?).

broad reason is this: functions do not keep state. It is a high level principal that we wish to stay consistent with. If you used a local variable inside function, would you expect it to have value that it was set to last time that function was called, or would you want it to reset to its initial default value (hopefully later)? You can think of multigates like this; internally they have a local variable that tracks node’s state, and functions start from a clean internal state every time you call them.

Our bigger concern here is discrepancy when collapsing a multigate into a function (behavior is changed). We’re internally debating how to best communicate this to user. If you have any ideas, we’d love to hear them.

Thanks for bringing this to our attention (in testing this, it did expose a nasty multigate crash bug).

I just stumbled upon same Problem.
PLEASE add a at least a single line of documentation stating that " multigate may not work as intended when used in functions" ( or better copy or link to explanation above ) to multigate documentation over here.

This is basically a 5 Minute Fix that will make it easier for future users. I understand why technical issue is a “won’t fix”. however, missing documentation on this design decision is definitely not fixed.

1 Like

request for documentation on this has been submitted as UEDOC-3840. When this has been completed we will update this post.

All the local variables inside a Function get reset once a function fires again externally, this includes Multigate, Do once, etc, basically a function is “new” every time it runs, you can use a multigate node connected to loops within the function, but once the logic leaves the function everything is reset