Pass by reference variables in custom events


I have a Custom Event with an int parameter passed by reference. I call my custom event with an int variable linked to this parameter. Inside the event I use “Set int (by ref)” node to modify the value of the parameter. It modifies the value inside the event blueprint, but not in the caller blueprint.

What am I doing wrong?

I replaced custom event by a function and it works as expected (i.e. parameter value is modified in the caller)

Not sure how/if it’s expected to be used with custom events.

Events are broadcast out and have no communication back to the calling location either through the passed in variables or as a return value.

Arguably we should probably be preventing specifying by reference variables on an event because they make no sense.

Reference variables on events are fine, but it does look like there’s a bug here. I just tried locally, and got the same results. I’ll log the bug to get it fixed up; both events and functions should treat reference parameters the same! Thanks for the report!

Apologies for the necro; couldn’t find any other topics that directly address this.

Looks like the last two official responses are somewhat in conflict with each other, and I’m getting warnings trying to pass-by-ref through a custom event. Did you guys end up going with Marc’s answer or Nick’s?

Pass by reference is not working in 4.15 Custom Events with Custom Structs and I can’t continue working without this…

If don’t work atleast remove the option or fix it, this was posted 3 years ago and still without changes

Pass-by-ref does not work in 4.16.1 for Custom Events with Custom Structs either. It never has, which I’ve always believed was an intentional ‘feature’. (even though it seems like an option)
Using functions for this is not an option for you I assume.

I’m having this issue in 4.18.3. I have a blueprint function (not event) which accepts a Scene Component object reference. Passing it by ref will result in nothing being passed, but passing by value works fine. I enabled/disabled passing by ref several times, and it consistently failed by ref.

I also can confirm it is not fixed in 4.19. You can reproduce this by adding a custom event and making one of its inputs passed by reference (except arrays, strange !)

Still getting this as well in 4.22.3

I just ran headfirst into this bug in a bizarre situation: Subclassing.


void BPBaseClass::Test(UParam(Ref) FStruct& A)

is a function in BPBaseClass Everything works fine, “FStruct& A” is passed successfully.

Now if we override Test() in BPSubClass, that function gets turned into an Event since it does not have a return value (WHY?? EPIC WHY??), which breaks because “FStruct& A” cannot be passed by ref in Event.

And that took me a whole day to debug and fix up everything in the subclass chain. Seriously, fix up this inconsistent **** will ya.


Edit: Found the issue ticket for “function getting turned into event”, which is fixed by 4.24.

This issue still exists as of 4.23. It’s stopping my development and really frustrating, please fix.

Same issue in 4.24

This is still happening in 4.25, sadly. I wanted to make a tweening Library in C++ and expose it to Blueprints by having two custom events, a getter and setter (just like Unity’s DOTween). Since Events can’t return anything, I used a by-ref float variable to “return” the value to the C++ tweening function, but I’m only getting zero.

4.26.0: same issue, but we took a step back since it doesn’t return a warning like in 4.25 (but now the pins are round shaped instead of squared). Please, remove the “pass by ref” checkbox form events if implementation is not planned.

TESTED in 4.26 , also no working to pass By Ref to Event… so sad


But it’s a local event, is there really the need for pass by reference? You can always set a variable by reference if you must:


Or use a function instead. [HR][/HR]
Events support latent actions, imagine what would happen if you pass-by-ref to an event from another blueprint, the event fires a delay, the original actor gets destroyed. You’ll be* accessing none* after the delay.

Not advocating for artificial limitations, but blueprints do that all the time. It’s already a tangled mess.

Could you describe a scenario where this could be useful and safe to use?