@RICK_AV
Well, I learned a lot about Niagara arrays and loops today.
It turns out that Niagara HLSL does not accept dynamic arrays as inputs, they must be hard-coded, which won’t work because you want to set the values dynamically.
I’ve come up with a solution to iterate through an array, but note that it results in particles being not quite evenly distributed (locations earlier on your array will have less particles related to the amount of locations to avoid), and comes with a few limitations. Is this an ideal way to work with arrays? No. But this was the best I could figure out working within Niagara’s limitations. If anyone else on this forum knows something that I’ve missed, please chime in.
-Your emitter must be a GPU emitter- the ingrained For Loop doesn’t work on CPU emitters.
-Your “Locations to Avoid” array values must increase- not decrease- as the array grows. Numbers can be repeated, just not be lower than the previous number.
First, assign your particles a new value of “RandInt”, which is a random range from 0 to the number of Postion array elemnts. You’ll need to set the max as a Scratch Dynamic Input
Then, you’ll need a new scratch pad module that looks like this:
I tried to label everything clearly so you understand what’s happening here, but let me know if you have any questions.
Then, we’ll direct set the particle’s position using the new RandInt value and selecting from our position array. I’m setting it outside of the previous scratch pad just to avoid any wonkiness with the for loop.
Finally, we need a module to kill particles. This will only kill particles in the event that the last position is turned off, as we have no way to reliably randomly reassign those particles to lower indexes.
I hope this helps!





