First of all, as with all my recent Feature Requests, I would like to say “thank you” to Epic Games and the Unreal Engine team for providing me and others with such a great tool, as well as its source. I hope my feedback can help improve it.
Duplicating my AnswerHub questionhere, in case it might yield better results.
Is there any reason that the “find” node for maps in Blueprint only returns copies? It would be very helpful to have a “find” node that returns a reference to the stored value, in the same way as there are “Get (Copy)” and “Get (Ref)” for TArrays. For many use cases changing a map value directly is necessary, such as setting a member in a struct / array / any other non-atomic type stored as a value for some key in a map variable.
Let’s say for a simple example, there’s a struct called AnyStruct, which consists of an array of floats, and a child struct. Let’s make a Map called StructVariable, with key-value pairs of Integer to AnyStruct.
The example code below, which *looks like *it should add some new values to the array, and set some members of the child struct, will actually introduce no changes at all to the AnyStruct stored as the value for a key in the variable StructVariable, as it operates on the output of the “find” node, which seems to return a copy of the actual value:
In this example, changing the array or struct members in the AnyStruct stored as the value of a key-value pair, would require an entirely new AnyStruct has to be created, all the relevant values filled, and then this new struct to be added with an “add” node, to replace the old one. This is of course far from ideal. For one, it isn’t memory/instruction efficient, as the whole struct has to be constructed and saved elsewhere first. And furthermore, it makes the blueprint graph less readable by cluttering it with unnecessary nodes, variables, and sequences. It would be way better to be able to access the value directly.
Especially confusing why no such node exists since a non-const “find” exists in TMapBase.h in C++:
Would very much appreciate any input.