How am i supposed to copy structs?

This function is copy structs via blueprint.

When i’m trying to use:

void CopyMyStruct(MyStruct* source, MyStruct* destination);

I Get an error.

When i try:

void CopyMyStruct(MyStruct& source, MyStruct& destination);

The pins are in the output side of the node ( right side ) instead of the input side.

If i do:

void CopyMyStruct(MyStruct source, MyStruct destination);

It just won’t work right?..

So how am i supposed to do it?

I think you need to do it like:

void CopyMyStruct(const MyStruct& source, MyStruct& destination);

The use of const tells the blueprint system that it’s an input not an output. This is good C++ style as well since most C++ programmers will make the same assumption.

Haven’t tried that yet, but doesn’t it means that one of the structs will be in the input side and the other on the output side? I need both of them in the input side.

I don’t think it’s possible to do it that way. You could do a const_cast to the second input to make it not const but that’s pretty hacky and I’m not sure if it’s possible in UE4.

Can you not just use a set node for the output struct to copy it to the variable you want in your blueprint?

Yeah but i’m trying to move my project slowly to c++ and it looks weird that you can do it in blueprint but can’t do it c++ :expressionless:

Well you can do it in C++. You just can’t specify a struct to use as an input and output in Blueprint. This is something specific to the C++ to blueprint interface.