Set Variable by Reference not working with Custom Events

When I click on the door, I want the value of the variable to change to 50, but it stays at 0. Why is this not working? It works without the custom event, but I want to use a custom event so I can reuse scripting.

I think you need to make this parameter ‘by ref’ also

1 Like

It’s just the custom event, it works with functions macros, etc., or? At least for me.

1 Like

I looked into the source and probably it’s linked to this comment (not 100% validated):

// Inputs flagged as pass-by-reference will also be flagged as 'const' here to conform to the expected native C++
// declaration of 'const Type&' for input reference parameters on functions with no outputs (i.e. events). Array
// types are also flagged as 'const' here since they will always be implicitly passed by reference, regardless of
// the checkbox setting. See UEditablePinBase::PostLoad() for more details.
2 Likes

Like this

1 Like

Oh wait sorry, that solution didn’t work. In the custom event I checked Pass-By-Reference, and then a warning showed and it doesn’t work.

image

I see you’ve makered this as solved, but is it really? I’m having trouble with getting Pass-By-Refrences to work in Custom Events too (in both UE 4.27 and 5.2). Just doesn’t seem to work. It works with Functions and Macros though.
In a Custom Event, when I check the Pass-By-Ref box, it doesn’t turn into a diamond shape pin. The only way to get that pin is to drag off the Target on the Set Float By-Ref node, but then I get the warning as seen in Timophobic’s post above and it does not work.

Any ideas welcome. I need this to work with Custom Events as I need to use a Timeline and you can’t use Timelines in Functions or Macros. Thanks

Hello,

I’ve also encountered this problem with custom USTRUCT - passing object of this struct by reference in Events, doesn’t work, the object is not altered.

Hovewer it works with functions