Niagara "Map For" Can't Set Array Elements

Hello,

I am currently trying to get an Array of Vectors/Positions from Blueprint into Niagara and it seems way harder than I feel it should be. For starters the Blueprint Nodes “Niagara Set Position Array Value” and “Niagara Set Vector Array Value” crash the editor or error out respectively.

But “Niagara Set Float Array” works, so I started a workaround in which I break down the Vector array in blueprint in 3 float arrays (X,Y,Z) and send that over to Niagara. But now I struggle to recreate the vector or position arrays in Niagara for further use.

I’ve learned about the “Map For” Node inside Niagara scratch pad and am at a new roadblock. See Image below. I can iterate through the array elements from my float arrays. But when it comes to setting a new array element I can’t find a solution. The “Set Array Elem”-Node in Niagara has execution Pins, but all the “for loop” logic happens within the “Map For”-Node, right? So If I put the “Set Array Elem”-Node before the “Map For” then only index 0 will ever get set, If I set it behind, only the last index will be ever set.

Any help would be greatly appreciated!

Greets
rePete

1 Like

Hey, couple of things:

  1. You just have to connect the set array call to the map for node, e.g. by setting a dummy value (see below)
  2. You don’t have to calculate the current interation yourself, there is a node for it already
  3. You can always just pop down a custom hlsl node and write the for loop yourself. You can get the hlsl version of the data interface functions by right-clicking on the data interface pin and then go to “Data Interface Function HLSL…”

4 Likes

@Michael.Galetzka,
could you please give an example for For Loop in HLSL? Thanks =)

I am unable to get this working with setting random values. I have a Calculate Random Unit vector attached to a multiply that I tried plugging into the “Set Array Elem” Value AND I tried plugging that into the “Map For” No such luck". Is there any more info, I tried using the template you have provided.

try to find your solution from this post, maybe it will be useful: Reading from the Array in Niagara

1 Like