# Issues with niagara scratch pad module : "map for" node not woking with CPUSim and "Custom HLSL" array undeclared

**URL:** <https://forums.unrealengine.com/t/issues-with-niagara-scratch-pad-module-map-for-node-not-woking-with-cpusim-and-custom-hlsl-array-undeclared/764917>\
**Category:** FX\
**Tags:** unreal-engine, question\
**Created:** [February 6, 2023, 4:29pm UTC](https://forums.unrealengine.com/t/issues-with-niagara-scratch-pad-module-map-for-node-not-woking-with-cpusim-and-custom-hlsl-array-undeclared/764917 "2023-02-06T16:29:24Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bellius](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Bellius](https://forums.unrealengine.com/u/Bellius)\
**Post date:** [February 6, 2023, 4:29pm UTC](https://forums.unrealengine.com/t/issues-with-niagara-scratch-pad-module-map-for-node-not-woking-with-cpusim-and-custom-hlsl-array-undeclared/764917/1 "2023-02-06T16:29:25Z")

</div>

Hello, I have 2 issues with niagara scratch pad module.

First :  
If if I set the emiter Sim Target to “CPUSim” the “map for” node in scrath pad modules doesn’t work, but if I set the emiter Sim Target to “GPUCompute Sim” it does.  
 ![MapFor](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/c/9/6c934896dace5a8dabd12792dca6fb9648de07ba.png)  
I have no error, it just doesn’t loop.  
I need my particles to collide with some colliders in my scene so I need to use CPU Sim…

Second :  
Since map for didn’t worked, I tryied to use the “Custom Hlsl” to loop my array.  
But if I link an array (like a float or vector array) to the “Custom Hlsl” node I have an error that say that the variable isn’t declared.

 ![HlslArray](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/7/7/e77a262dacf8067e8a3579d6532731ffc5be1859.png)  
Is it not possible to pass arrays to the “Custom Hlsl” node, or am I doing it wrong?

Does someone have a solution/explaination to either of those issues?  
Thanks.

---

<div class="post-metadata">

**Author:** ![Michael.Galetzka](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/michael.galetzka/32/924122_2.png) [@Michael.Galetzka](https://forums.unrealengine.com/u/Michael.Galetzka)\
**Post date:** [February 14, 2023, 4:54pm UTC](https://forums.unrealengine.com/t/issues-with-niagara-scratch-pad-module-map-for-node-not-woking-with-cpusim-and-custom-hlsl-array-undeclared/764917/2 "2023-02-14T16:54:37Z")

</div>

Loops are not yet supported on cpu simulations.

---

<div class="post-metadata">

**Author:** ![DesART](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DesART](https://forums.unrealengine.com/u/DesART)\
**Post date:** [April 16, 2023, 9:47pm UTC](https://forums.unrealengine.com/t/issues-with-niagara-scratch-pad-module-map-for-node-not-woking-with-cpusim-and-custom-hlsl-array-undeclared/764917/3 "2023-04-16T21:47:37Z")

</div>

hi, could you please show some examples of how to use the MAP FOR node in Niagara ScratchPad? Thank you.

---

<div class="post-metadata">

**Author:** ![Michael.Galetzka](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/michael.galetzka/32/924122_2.png) [@Michael.Galetzka](https://forums.unrealengine.com/u/Michael.Galetzka)\
**Post date:** [April 19, 2023, 12:46pm UTC](https://forums.unrealengine.com/t/issues-with-niagara-scratch-pad-module-map-for-node-not-woking-with-cpusim-and-custom-hlsl-array-undeclared/764917/4 "2023-04-19T12:46:36Z")

</div>

Here is an example setting array elements in a loop

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/8/b/e8b7bfa8a0496a7791d7c2496c70bd70e091abca.png)

---

<div class="post-metadata">

**Author:** ![DesART](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@DesART](https://forums.unrealengine.com/u/DesART)\
**Post date:** [February 26, 2024, 7:08pm UTC](https://forums.unrealengine.com/t/issues-with-niagara-scratch-pad-module-map-for-node-not-woking-with-cpusim-and-custom-hlsl-array-undeclared/764917/5 "2024-02-26T19:08:11Z")

</div>

@Michael.Galetzka , could u please show an example of adding element onto the totally empty array. Is it possible? And if it is not very hard to u, one example with HLSL … Thank u very much 😊🙏

---

<div class="post-metadata">

**Author:** ![Jake-GameSim](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Jake-GameSim](https://forums.unrealengine.com/u/Jake-GameSim)\
**Post date:** [May 22, 2024, 5:48pm UTC](https://forums.unrealengine.com/t/issues-with-niagara-scratch-pad-module-map-for-node-not-woking-with-cpusim-and-custom-hlsl-array-undeclared/764917/6 "2024-05-22T17:48:43Z")

</div>

@Michael.Galetzka, Is there a way to get the Map For node to work for a System or Emitter Module? It seems to only run through the loop once in those cases.

I did get it to work for Particle Spawn and Particle Update thanks to your help.

---

<div class="post-metadata">

**Author:** ![Michael.Galetzka](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/michael.galetzka/32/924122_2.png) [@Michael.Galetzka](https://forums.unrealengine.com/u/Michael.Galetzka)\
**Post date:** [May 31, 2024, 1:22pm UTC](https://forums.unrealengine.com/t/issues-with-niagara-scratch-pad-module-map-for-node-not-woking-with-cpusim-and-custom-hlsl-array-undeclared/764917/7 "2024-05-31T13:22:05Z")

</div>

No, the map for node does NOT work in cpu scripts. Both emitter and systems scripts always run on the cpu.

The map for node only works correctly in particle spawn/update scripts or sim stages in a gpu emitter.
