First of all, it should be noted that I have already found a solution to this which will be demonstrated below, but I still don’t understand why this is a problem to begin with.
I’m curious as to why this is and I’m hoping a wiser programmer than I can answer this question, so, bear with me whilst I try to explain.
I have a struct, which we will call FMyStruct.
struct FMyStruct {
UStaticMesh* Mesh;
float Speed;
}
The Server has an instance of FMyStruct, which it would like to pass to the client. In this case, it uses a Multicast method; passing FMyStruct as a parameter. But when the client receives this struct, all of the values are set to default (so, NULLs and 0s).
void MulicastSendStructToClients(FMyStruct _StructToSend); // this does not work
However, when the values of FMyStruct are extracted and stored in local variables on the server, and then passed to the client via a different multicast method which accepts all of the same data as parameters, but instead of being contained in the struct, the local variables are passed instead. This results in the desired outcome, and the data is successfully transferred to the client.
void MulicastSendDataToClients(UStaticMesh* _Mesh, float _Speed); // this works.
Why, then, does the second approach work whilst the first does not?