Hello. I am trying to make a maze that adds a randomly chosen child actor components with transform randomly picked from an array of eight. I set it up so that once a setting was chosen from the array, the chosen index is removed. The problem I’ve been having is that it spawns the pieces in the removed areas and in an area I didn’t have an array for, 0, 0, 0. I have ideas of why it’s doing this but I don’t know of any solutions.
Tyler,
You have a couple of things to take care.
- you need to code up an exit condition, right now you have an infinite loop set up. But you also are depleting the arrays of the elements, with the remove index (remember your not removing an index, you are removing the array element at the index). So eventually the arrays are reduced to having no elements. To get around this, get the “Last Index” for the array that you want to control how many times the loop executes, and compare that to zero, when it’s Less than or Equal, terminate the loop.
- The Max for the Random Integer in Range. Should not be hardcoded. Because each time you remove an array element from those two arrays, you are not reducing the Max value for Random Integer. To get around this, Drag off a wire from the array, then use “Last Index” and feed that into the Max value.
Hope this helps,
I haven’t gotten to try this yet but I will be able to soon. Thanks for your help!
More than welcome.
I works now! Thank you.