How can I write a C++ blueprint function with an input parameter that's pass-by-reference?

I need to be able to edit the contents of a struct that’s passed as a parameter to one of my functions I’m writing. The issue I’m running into is when I denote that I want the struct to be passed by reference (using &) in my C++ code, the blueprint editor assumes the parameter is supposed to be a function output:


How can I make the blueprint editor recognize my parameter as an input?


I don’t think it’s possible, but I may be wrong. I guess you could pass it by value and just return FAxonDevice instead of void.

I know it’s not what you want but it would work. I’ll follow this question, interested in knowing if there is a way…

The structure I’m passing around contains ten kilobytes of data, there has to be a way to pass it by reference, it will be a performance issue if I can’t.

1 Like

Thanks! It’s amazing that something so simple and useful isn’t in the programming guide…

Best way to learn how do specific pin or node apperence, is to find node that have it and search for it’s decleration in engine source code

Most common example of ref pin input is randomization nodes that use random streams:

Then you go to GitHub, paste the name of node, remove spaces and search, it should find the function you searching for. If not, which usally happens when node has custom name set, then add spaces back and put name between " ". In this case, job is easier as doc hints that function is in Kismet Math Library which is common class contain static math nodes for blueprint

In there we have this out function that we picked:

/** Return a random integer between Min and Max (>= Min and <= Max) */
UFUNCTION(BlueprintPure, Category="Math|Random")
static int32 RandomIntegerInRangeFromStream(int32 Min, int32 Max, const FRandomStream& Stream);

And as we can deduce, you need too add “const” to make input refrence, which makes sence as you can’t use that refrence as a output if you can’t modify it. But if you look below there even way to do ref input which you can modify

/** Set the seed of a random stream to a specific number */
UFUNCTION(BlueprintCallable, Category="Math|Random")
static void SetRandomStreamSeed(UPARAM(ref) FRandomStream& Stream, int32 NewSeed);

You put UPARAM(ref) before ref argument and i don’t need to lock refrence with const and i can now modify that refrence

To tell you the truth i didn’t know how to do that either, but as you can see with this method we both learned it how to do it :slight_smile:


Good to know, thanks !

Helpful! :slight_smile:

You rock. Thanks a BUNCH. One would think that info would be talked about more in the docs.

1 Like

Thank you ! …

Thanks for opening my eyes to the UPARAM() trickery - I am surprised I am finding this just now (Epic has been keeping it to themselves all these years :sweat_smile:)

For anyone interested to learn more about UPARAM() and its many usages, visit: All UPARAM Specifiers · ben🌱ui

1 Like