Is there any way to set a map element specifically?

So like an array, is there a way to set a specific element in a map using two values of the same variable type the map contains? Because the “Set Map” node doesn’t have an option to choose an element. And unlike arrays, there’s no node that sets the array element by array reference, and you can choose the specific element you want to set depending on the variable type of the array (i’m bad at explaining). Is there any way to do the same with maps?
image
image

1 Like

So, do you want to update an existing key inside the map variable? Have you tried to use the Add Map node? It serves both ways, to add and update values. If the ‘key’ already exists, it will update it. Else, it will add a new key.

2 Likes

Thanks! I knew that was there but i didn’t know you could use it to select a map element.

1 Like

Wait… I think I’ve misunderstood
I wanted to set a specific element in a map, but in the set node there wasn’t an option to enter an element, unlike arrays. So what I didn’t notice in the image you sent was that the integer variable was part of the map. So now I’m confused.

Hi there, this is just an example. Try with your map variable. The map variable can have multiple types of variables assigned as keys or values, including struct variables with multiple elements.

Yes I am aware. However, my problem is I can’t seem to set a map element as you would do with arrays, even though in the default value section, it specifies them as “Map Elements”, and I want to choose an index to set in the map instead of choosing a whole map value to set the target map to.
image
image
As shown in these images, there is an integer value before “Map Elements” or “Array Elements”. What I’m trying to imply here is that there is a node for setting specific array elements, but not for setting map elements.
image
image

Add is the node. You can’t have two elements with the same key, so ADD is used to update.

1 Like

‘Add map’ node is the correct way, otherwise you may need to get all this done with value arrays. I have never used another way, by-the-way.

1 Like

Ohhhh. Thanks for clarifying!

1 Like