How to return a c++ struct by reference in Blueprints, is it impossible?

How do i make this function output a pin by reference in Blueprints.
I need to get the Struct in blueprints, and change it.
So that means the struct must be returned by reference (diamond pin).
Instead so far all i get is circle pin, or the pin showing in the left side.


UFUNCTION(BlueprintCallable)
FCharacterStruct& GetCharacter2(const FGuid& ID) {
    return CharactersMap.FindChecked(ID);
}

Also tried:

UFUNCTION(BlueprintCallable)
void GetCharacter2(const FGuid& ID, FCharacterStruct& OutCharacter)
{
    OutCharacter = CharactersMap.FindChecked(ID);
}

And:

UFUNCTION(BlueprintCallable)
void GetCharacter2(const FGuid& ID, UPARAM(ref, meta = (OutParm)) FCharacterStruct& OutCharacter)
{
OutCharacter = CharactersMap.FindChecked(ID);
}

generally speaking i dont think its possible

but maybe look into custom k2nodes like SetMembersInStruct since that returns a ref pin

the way i do it though is to wrap a pointer to the struct in a ‘handle’ struct and then modify the struct via handle. but of course all your functions will need to be in c++ with static bp wrappers

1 Like