Blueprint Map "find" node that gets value as reference possible? Same as "Get (ref)" for arrays

Okay, I have kind of achieved returning a struct by reference, but it is extremely hacky and not something you could make into a single K2 Node… I basically made a temporary array, used some hackery to pass it by reference into a C++ function that sets it’s ArrayNum to 1 and it’s data pointer to the data you want struct you want passed (had to use a bunch of illegal techniques to do this). Then with the hacked array I send that into the Get (a ref) array node and get the 0th index which will return the struct by reference. But now what you have to do is you actually have to re-nullify the array otherwise when the destructor is called it will crash because it will try and free the memory that was not legally allocated so you have to send the temporary array back into another function to set its ArrayNum back to 0 and set it’s data to NULL. This technically works but the fact that after you get the struct by reference and do whatever you want to do with it and then you have to nullify the array makes it so I could not compact this into a macro because you have to reset it. All the functions implemented a CustomStructureParam so this can be used on any type. This was probably a useless solution lmao. From what I have seen from the K2_Nodes Select and Get (a ref), it seems like there is pretty much no way to return a struct by reference without either some hackery like I did or changing Engine code…

1 Like