For Loop => Remove Item (or index) from array
I try to spawn actors on a grid.
So in attachment you can see my blueprint and the result in game, this is not a full line, some actors are missing. I was expected that the line be filled up because the Last Index is equal to the array length.
In the loop the item is not removed. So 2 or more actors use the same location. What have I done wrong? Is it a bug or an expected behavior?
Thanks for your help.
PS: In my game I use it as a function to execute it with different class of actor in order to partially fill my grid with differents actors. I don't wand my grid to be fully filled. But only one actor by loction. So another method can help too.
asked Jan 29 '18 at 09:34 AM in Blueprint Scripting
The issue here revolves around the way you use the random node. It is used twice, 1st time to Get and 2nd time to Remove an array element. You'd expect it to produce the same value twice but that's not the case. It is working as intended, though.
So you Get one random index and then Remove another random index - different from the 1st.
In order to work around it, store the result of the random generation in a variable and use the value to access the array. This should be the first step to take; if there are more issues, let us know.
Follow this question
Once you sign in you will be able to subscribe for any updates here