If your answer to my question (above) is “Yes”, here’s the information you require:
Update:
If you want C++ to return a value to blueprints then you just want to use the BlueprintCallable specifier.
Returning a reference is done by using standard C++ syntax (the ‘&’ token). You can search the web for more info on C++ references.
Still shaky on what you want, but if all you want to do is implement a variable in BP and the C++ base class has access to it then you should just use UPROPERTY with the appropriate (i.e. BlueprintXXX) specifier(s). You declare it in C++ and assign it the reference to an object from within the BP.
not just return a value, it must be a reference to a variable, and if you assign a new value to the reference, then the original variable also changes.
so I’m interested in how I do this function in the Blueprints …
because the function above works as it should in C ++,
but does not return the reference in the Blueprints, only the value.
just try the code from the question
these functions in the Blueprints and in C ++ work very differently.
I just want to understand if there is such an opportunity.
But how and where to apply it is an entirely separate issue.
Passing primitive types by reference is not best practice. I’m not sure it even works with UE4. You can pass objects by reference but it might not work for primitive types because there’s really no compelling reason to do it like that.
I just gave a simple example.
I agree that use can be controversial.
But at the moment I’m just interested in: Is it possible to do this in a simple way or not?
You can return references to actors and other UE4 objects. But it certainly looks as if you cannot get a reference to a primitive type. That’s the best I can do beyond the tutorials, FAQs, and examples that show how to implement UFUNCTIONs.
Not quite exactly. I met the same problem, basically Primative types and Composite types are passed by value by default in Blueprint, but if you provide custom C++ implemention it can still provide reference, see struct break node and struct set members node.