Remove random integer in range from index once used

Hello,

I know my title is not clear, let’s try to explain what I want.

I spawn a number of items, in this case batteries but I would do it for more using the same array.

The probleme is I use random integer in range and if I set the number of batteries spawn to 6, even if I never have two item at the same spawn because I remove the target point, it happens that the same random integer comes twice and then I have sometimes only five batterie instead of 7, Is there a way to remove the integer used from the random integer in range?

And why I can’t once the loops are completed, reuse it for another item? Like the second pic, I ve tried to set the spawn point array before the second loop or get it directly from the make array, it don’t work.

I hope I have been clear enough.

Thank you!

instead of getting a random number between 0 and 13 try getting a random number between 0 and the length of the array.

for the second part of your question on re-using the array, the issue here is that you removed all the information from the array in the previous loop. of course this is assuming your using two loops here.

Put this in an answer dude. They just need a little more detail. By repeating your comment in an answer, I feel like I’m sniping you.

It’s not about karma per se. It’s about etiquette. And yeah, it’s not like I repeated your answer or anything. Just noticed you give the right answer in comments a lot. See you around!

Glad to hear it! Please mark this answer as correct so it gets closed out.

I’ve tried getting the lenght of the array but it is the same, I’ve set the number of loops to the max array index and I had 4 locations not filled. If it get twice the same index it don’t spawn the item.

And for the remove node, the remove index is working to keep the other target points for the next loop? I’ve tried but it don’t seems to work.

EDIT: just wrote the doc, looks like remove index is what I need but it don’t work…

Arrays are a nightmare to me, I don’t get the logic behind it.

if you were talking about me then snipe away i dont mind. i sometimes post things as comments because im not 100% sure on it (if its right or will work). im not too worried about gaining karma or things like that and if it turns out to be a correct answer and no one else came up with something better, then i can always change the comment to an answer.

You’re awesome! It works fine! I’ve been able to set my 4 pick ups random spawns.

Thank you very much!

a setup like this should work.

arrays are pretty simple, simply put its a list. so if you have a array of integers its just a list of numbers. lets do a little exercise as an example, open up a spreadsheet program (excel, openoffice calc, etc). now fill in column A with a series of numbers. if you notice the row numbers to the left of column A those would be the array index and the information in column A would be the array data. now lets say you have 10 entries in the array or 10 rows worth of data in the spreadsheet. if you delete a row then the table will shift to compensate. so if you delete row 5 then the data that existed in row 6 would shift and now occupy row 5. this is the same as how the remove index node works. so this also tells us that the length of the array is dynamic.

if you wanted to reuse the array for another loop further down the graph you could always just have another set node after the loop complete pin. this would in essence repopulate the array.

Im also half asleep right not so it may not be 100% right.

One tweak you’d want to make is to get the length of the array -1. If there are 10 actors in your array, UE4 sets them at indices 0 - 9 but the length of the array is still 10. So if you get the length you’re going to be setting your max to 10 on the random integer when it should be 9 as there is no index 10.