I have a function in C++ with multiple outputs for blueprints (using pointers). How to call it in C++?

Hello,

I have a question that surely must have been answered before, but I was not able to find it anywhere.
I have a function in C++, defined to show multiple outputs in blueprints:

For example (one output only):

In .h file:

UFUNCTION(BlueprintCallable, Category = "Pokus1")
static void C_TileValidity( int row, int column,int NumRows,  int NumCollums, bool & Valid);

In .cpp file:

void UOperaceSeStverci::C_TileValidity(int row, int column, int NumRows, int NumCollums, bool & Valid)
{
	bool a;
	bool b;
	bool c;
	a = (row >= 0) && (row < NumRows);
	b= (column >= 0) && (column < NumCollums);
	c = a && b;
	Valid = c;
}

It works fine when I call it in Blueprint, but I when I try to call it in C++:

a = C_TileToIndex(rows[i], cols[j], NumCollums);

I get an error about number of arguments. I understand why the error occurs but I was not able to find a way to call this function (My C++ experience is almost zero).

Is there any way to have function with multiple (custom named) outputs for blueprints, that is also callable in C++?

Thanks for the answers.

Your function is C_TileValidity, but you’re calling C_TileToIndex?

Anyway, CPP functions can have Out Parameters (marked with &), and you need to have those variables created beforehand.

For instance, if your function is void MyFunction(int32 &Index),

To have this int32 variable set by your function you need to:

int32 Index;

MyFunction(Index);

Then your Index variable will be set to whatever value that is calculated in the function body.

Thank you! As I said, I a noob in C++, so this is exactly what I needed to hear :slight_smile:
Sorry about the function names mess - I have more functions of the same kind I accidentally copied the wrong one.