[Solved] Shift Items to Fill Empty Spaces

Question

How do I shift items to fill empty spaces?

What I Have

So right now, when a new item is being made, the variable ItemNum goes up by 1, and the item is created at a constant Y of 200, with an X of ItemNum*200, which means they get placed outwards to the right.

The problem is that players will be deleting items from the middle of the line, which messes things up entirely, as you can imagine.

What I’d Like

I need a way to fill the gap somehow. Every time an item gets deleted, I need all the items past that to shift Left by one to fill in the gap. It shouldn’t be too hard, but my coding knowledge is super limited and I haven’t figured out a way yet. Any ideas?

I don’t mind scrapping my current “ItemNum*200” setup, that was just the best I could think of with my limited knowledge. Thanks!

Before you delete the object, get it’s X position. Then move all the objects with an X position greater than the one you saved to variable.

Something like:

1 Like

OMG, I completely forgot to reply to this. YES, thank you! This helped a lot, cheers.