# Anyone know how to do for loop in Niagara?

**URL:** <https://forums.unrealengine.com/t/anyone-know-how-to-do-for-loop-in-niagara/482136>\
**Category:** FX\
**Tags:** foreachloop, unreal-engine, question\
**Created:** [April 19, 2021, 6:13am UTC](https://forums.unrealengine.com/t/anyone-know-how-to-do-for-loop-in-niagara/482136 "2021-04-19T06:13:44Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![intoxicat3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@intoxicat3](https://forums.unrealengine.com/u/intoxicat3)\
**Post date:** [April 19, 2021, 6:13am UTC](https://forums.unrealengine.com/t/anyone-know-how-to-do-for-loop-in-niagara/482136/1 "2021-04-19T06:13:44Z")

</div>

I’m trying to do simple for loop using vector array in Niagara module but can’t find a node corresponding to that. I also tried for loop using HLSL but it seems it’s always computing last index.

Anyone was able to create for loop in Niagara Module?

---

<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:** [April 19, 2021, 7:32am UTC](https://forums.unrealengine.com/t/anyone-know-how-to-do-for-loop-in-niagara/482136/2 "2021-04-19T07:32:25Z")

</div>

What do you want to have happen? ( what’s the loop for? )

---

<div class="post-metadata">

**Author:** ![intoxicat3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@intoxicat3](https://forums.unrealengine.com/u/intoxicat3)\
**Post date:** [April 19, 2021, 9:40am UTC](https://forums.unrealengine.com/t/anyone-know-how-to-do-for-loop-in-niagara/482136/3 "2021-04-19T09:40:38Z")

</div>

I have leaves that are just sitting on the ground. I’m passing characters’ velocities and locations to the module to add forces to the leaves like in Ghost of Tsushima like of particles. So basically I need to make for loop using vector array to get it working like in GoT.

Currently, the leaves are just reacting to one vector - last in the array even when used HLSL code with for loop.

(for example they are only reacting the player, not the enemies with the player as well)

---

<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:** [April 19, 2021, 10:28am UTC](https://forums.unrealengine.com/t/anyone-know-how-to-do-for-loop-in-niagara/482136/4 "2021-04-19T10:28:03Z")

</div>

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/e/7/1e7dc0d3f9f8f45d7ec187df9e1a300695ba7daf.jpeg "Unreal Engine Falling Leaves in Niagara Tutorial") ](https://www.youtube.com/watch?v=YQe47qjmClE)

---

<div class="post-metadata">

**Author:** ![intoxicat3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@intoxicat3](https://forums.unrealengine.com/u/intoxicat3)\
**Post date:** [April 19, 2021, 10:39am UTC](https://forums.unrealengine.com/t/anyone-know-how-to-do-for-loop-in-niagara/482136/5 "2021-04-19T10:39:45Z")

</div>

Thanks for trying to help but this is not what I’m asking about. Those are just falling leaves which don’t react to anything.

---

<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:** [April 19, 2021, 10:47am UTC](https://forums.unrealengine.com/t/anyone-know-how-to-do-for-loop-in-niagara/482136/6 "2021-04-19T10:47:58Z")

</div>

Ok, you want to move them again after they’ve fallen.

Possible yes, no idea though, sorry… :-/

---

<div class="post-metadata">

**Author:** ![Cghow](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/cghow/32/1212725_2.png) [@Cghow](https://forums.unrealengine.com/u/Cghow)\
**Post date:** [April 22, 2021, 6:32am UTC](https://forums.unrealengine.com/t/anyone-know-how-to-do-for-loop-in-niagara/482136/7 "2021-04-22T06:32:07Z")

</div>

you want leave the effect with character motion? you just need to make fore location parameter and link to with character. and what exactly you want o loop here? if the whole fx then loop behaviour will work.

---

<div class="post-metadata">

**Author:** ![intoxicat3](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@intoxicat3](https://forums.unrealengine.com/u/intoxicat3)\
**Post date:** [April 22, 2021, 8:13am UTC](https://forums.unrealengine.com/t/anyone-know-how-to-do-for-loop-in-niagara/482136/8 "2021-04-22T08:13:29Z")

</div>

Let me show you what I want to achieve: [2021 04 22 10 18 20 - YouTube](https://youtu.be/fk6iIhMZ1jI)

As you can see the player is affecting the leaves on the ground. BUT I want them to be affected by all of the characters (for example enemies) that’s why I’m passing arrays of velocities and locations (Niagara support arrays) BUT can’t find any for loop mechanics that will do my math for each vector.

---

<div class="post-metadata">

**Author:** ![grayback](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@grayback](https://forums.unrealengine.com/u/grayback)\
**Post date:** [August 16, 2022, 6:52pm UTC](https://forums.unrealengine.com/t/anyone-know-how-to-do-for-loop-in-niagara/482136/9 "2022-08-16T18:52:16Z")

</div>

did you ever find out a way to do this?

---

<div class="post-metadata">

**Author:** ![AngelBieliukas](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/angelbieliukas/32/88714_2.png) [@AngelBieliukas](https://forums.unrealengine.com/u/AngelBieliukas)\
**Post date:** [August 16, 2022, 9:01pm UTC](https://forums.unrealengine.com/t/anyone-know-how-to-do-for-loop-in-niagara/482136/10 "2022-08-16T21:01:55Z")

</div>

Hello!

You cand make the particle spawn a certain ammount of leaves with collision enabled, and turn off the “kill particles when life has elapsed” option under the particle state tab, and meake the mesh to have physics when the player touches them

Hope this helps!
