Is there any reason that the “find” node for maps in Blueprint only returns copies?
For many use cases changing the value directly is necessary, such as setting a member in a struct / vector / any other non-atomic type stored as a value for some key in a map variable. In the same way as there are “Get (Copy)” and “Get (Ref)” for TArrays.
Otherwise, an entirely new struct has to be created, and added with an “add” node, which is far from ideal. For one, it isn’t memory efficient, as the whole struct has to be constructed and saved somewhere else first. Also, it makes the blueprint graph less readable by cluttering it with unnecessary nodes, variables, sequences.
For example, some code like this will introduce no changes at all to “struct variable”, as it operates on the output of the “find” node, which seems to return a copy of the actual value:
https://answers.unrealengine.com/storage/temp/293670-capture.png
It would be way better to be able to access the value directly. Is there some reason for that not to be possible?
Especially confusing why no such node exists since a non-const “find” exists in TMapBase.h in C++:
https://answers.unrealengine.com/storage/temp/293682-capture2.png
I tried to make a custom K2 Node that would do something like this by looking in BlueprintMapLibrary.h and K2Node_GetArrayItem.h, but can’t seem to figure out how the Get (ref) array element node is created at all, and how a value of a UProperty can be returned by ref in an output pin of a node.
Is there anyone here who is familiar with these topics?