Function multiple pointer-return values

I know that I can use references to tell UE4 to make the function return multiple values for blueprints:

However, what if I need to return 2 actors? They are pointer-types and can not be passed by reference (will throw compiler error).

So:

UFUNCTION(BlueprintCallable, Category = "Foo")
bool Check(EKeyEnum KeyType, AActor &SomeActor); // Won't compile because SomeActor must be of type pointer.

But when I make it a pointer it will no longer be an out-variable for blueprints but will be an in-variable instead:
Error: Missing ā€˜*’ in Expected a pointer type

you have to return the actor by pointer not reference

UFUNCTION(BlueprintCallable, meta = (DynamicOutputParam="SomeActor" ))
 bool Check(EKeyEnum KeyType, AActor* SomeActor);

You can not (in this case) return an actor by pointer because then the blueprint will recognise it as an in-variable instead of an out-variable. I must return the actor(s) as OUT variables without using an TArray if possible.

You should create your own data structure with two pointers in it and return that

I know I can use tuples and pairs and structs (or even TArrays). But you’re saying UE4 does not support multiple pointers as return nodes in C++ functions?

I can do it in blueprints though but not in C++… That is weird. Usually it is the other way around.

I don’t like using pairs because of their names, I don’t like using custom structs because… Need a different struct for each function that has different out-variable names. Tuples are just not efficient and TArrays are even more messy. And the ā€˜real solution’ (pointers and references) are not supported in UE4 when using actors or other types that only support pointers…

Is there no Macro to tell the blueprint that my pointer-parameter is an out-variable? That would solve everything.

The other way around does exist: A new, community-hosted Unreal Engine Wiki - Announcements - Unreal Engine Forums so I’m wondering why there is no UPARAM to force a pointer to become an output variable in blueprints.

I’m also wondering why there isn’t a UPARAM to specify this. I will keep looking for another way todo this…

Hope It’s not too late to answer this question.
There Actually has a easy way to do this:

221494-0.jpg

Then You Will get this Node:

221495-1.jpg

4 Likes

Well did not expect really that this would work,
cause i though ā€œ*&ā€ signature is a little wired but it works!