Here is what im trying to do:
- Create array of actors
- Loop thru it every second and check if actor is above pawn
- If it is, then delete actor
Here is my implementation in BP, but logic is wrong and it doesnt quite work as expected. I know more or less whats wrong, but dont know how to fix it. Any tips ?
Another way would be to create multibox above pawn and kill on overlap. Before I try this approach I want to know how to do this with loops and arrays.
You need to use a ForEachLoop instead of a ForLoop. It’s pretty self-explanatory and straightforward to use. It would help you get rid of all the “Get” nodes
I tried to iterate backwards this loop, to fix deletion of wrong actors. If I use ForEachLoop and iterate forward, I get similar result. Wrong one. Do you see the issue on the anim gif ?
I see the problem: it’s because you’re removing indices while within the loop. When you remove an index the entire array shifts, that’s why it’s skipping one.
Makes sense and I’ve done this plenty of times in code but how are we supposed to decrement the current index using blueprint?