# Is there any way to set a map element specifically?

**URL:** <https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851>\
**Category:** Blueprint\
**Tags:** variables, unreal-engine, Array, question, UE4-27, Blueprint\
**Created:** [May 10, 2022, 4:13pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851 "2022-05-10T16:13:48Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Fallerrr](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fallerrr/32/482685_2.png) [@Fallerrr](https://forums.unrealengine.com/u/Fallerrr)\
**Post date:** [May 10, 2022, 4:13pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/1 "2022-05-10T16:13:48Z")

</div>

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/2/b/92b6313ba61ff0cbe6ddab636bbffdaef44c1c57.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/0/1/801ddedac9e3536c852cac130a10ce625737c2a3.png)

---

<div class="post-metadata">

**Author:** ![L.F.A](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/l.f.a/32/1194525_2.png) [@L.F.A](https://forums.unrealengine.com/u/L.F.A)\
**Post date:** [May 10, 2022, 4:40pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/2 "2022-05-10T16:40:31Z")

</div>

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.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/e/0/9e0944d433bb39c8ec3c1d3ee998793746ee5edd.png)

---

<div class="post-metadata">

**Author:** ![Fallerrr](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fallerrr/32/482685_2.png) [@Fallerrr](https://forums.unrealengine.com/u/Fallerrr)\
**Post date:** [May 10, 2022, 4:45pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/3 "2022-05-10T16:45:56Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Fallerrr](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fallerrr/32/482685_2.png) [@Fallerrr](https://forums.unrealengine.com/u/Fallerrr)\
**Post date:** [May 10, 2022, 4:52pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/4 "2022-05-10T16:52:29Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![L.F.A](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/l.f.a/32/1194525_2.png) [@L.F.A](https://forums.unrealengine.com/u/L.F.A)\
**Post date:** [May 10, 2022, 4:55pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/5 "2022-05-10T16:55:08Z")

</div>

> [@Fallerrr](#):
>
> in a ma

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.

---

<div class="post-metadata">

**Author:** ![Fallerrr](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fallerrr/32/482685_2.png) [@Fallerrr](https://forums.unrealengine.com/u/Fallerrr)\
**Post date:** [May 10, 2022, 5:07pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/6 "2022-05-10T17:07:31Z")

</div>

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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/5/c/f5cc33e89a3aa5d8c3296b58b86ca7ed87ae702d.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/2/a/c2a014874f7099c19a5552678e56f98de8ffe3e0.png)  
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](https://d3kjluh73b9h9o.cloudfront.net/original/4X/d/1/a/d1adbbfd62b0746713b255457ab2441bf293b374.png)  
 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/c/e/9ce90dc19dc96ea1e08914fe132bfd214d5ebf9a.png)

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [May 10, 2022, 5:15pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/7 "2022-05-10T17:15:33Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![L.F.A](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/l.f.a/32/1194525_2.png) [@L.F.A](https://forums.unrealengine.com/u/L.F.A)\
**Post date:** [May 10, 2022, 5:21pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/8 "2022-05-10T17:21:24Z")

</div>

‘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.

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/f/9/af9161bf90f8b0186e57bd4d1013a5cecd81e461.png)

---

<div class="post-metadata">

**Author:** ![Fallerrr](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/fallerrr/32/482685_2.png) [@Fallerrr](https://forums.unrealengine.com/u/Fallerrr)\
**Post date:** [May 10, 2022, 5:28pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/9 "2022-05-10T17:28:26Z")

</div>

Ohhhh. Thanks for clarifying!

---

<div class="post-metadata">

**Author:** ![zeth\_foxster](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zeth\_foxster](https://forums.unrealengine.com/u/zeth_foxster)\
**Post date:** [February 10, 2024, 1:59am UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/10 "2024-02-10T01:59:39Z")

</div>

I understood him a little better becuase im currently doing the same thing…he has a map with an array and only wants to update a single value in the array…if you used “ADD” what exactly are you adding? hes trying to target a single array member in the values…not the whole thing…the user LFA below is more correct as to what he was looking for…tho they posted exactly what the user said he already tried…FIND node pull the exact array, no need to iter through them…but set array elem does not actually update the value in the map…this is the problem both this user and i are trying to solve.

---

<div class="post-metadata">

**Author:** ![ClockworkOcean](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/clockworkocean/32/1169999_2.png) [@ClockworkOcean](https://forums.unrealengine.com/u/ClockworkOcean)\
**Post date:** [February 10, 2024, 8:22am UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/11 "2024-02-10T08:22:55Z")

</div>

It is possible, but it’s a total mess

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/d/2/4d278e9fc3a1a30e08cc9468f6fc6c151e55b4e0.png)

I know conceptually, it’s a nice idea to get all your data structures organized, but I’d either keep all these things separate ( as parallel arrays ), or use CPP.

---

<div class="post-metadata">

**Author:** ![L.F.A](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/l.f.a/32/1194525_2.png) [@L.F.A](https://forums.unrealengine.com/u/L.F.A)\
**Post date:** [February 11, 2024, 6:32pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/12 "2024-02-11T18:32:41Z")

</div>

For sure, “Add map” node is the correct way. If the entry key doesn’t exist, both key and values will be added. Else, the key will be the same and its values will be updated.

---

<div class="post-metadata">

**Author:** ![zeth\_foxster](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@zeth\_foxster](https://forums.unrealengine.com/u/zeth_foxster)\
**Post date:** [February 14, 2024, 11:14pm UTC](https://forums.unrealengine.com/t/is-there-any-way-to-set-a-map-element-specifically/553851/13 "2024-02-14T23:14:57Z")

</div>

what i ended up doing is find the key, then set the value to a local variable array, I set element by ref in THAT local array, then i add map with the original key name and the local array. sucks that we have to jump through an extra hoop to accomplish this…and that theres no warning that normal methods dont work. unfortunately even clockworks method, which at first appeared to work, did not work for me with object refs in an array. might work with vectors or standard variables, but not objects/actors.
