Hello, i am using a ForEachLoop to create widgets based on an array. Those widgets contain a button that removes the widget from the parent, at this point i want to also remove the specific item of the array that was responsible for its corresponding widget to be created. I do not know how to remove that item from the array. Can anyone help please?
There’s multiple way to accomplish this, up to a design choice, but the most straight forward would be to add an int variable to your ItemName widget that holds the index it corresponds to in the original array.
From here you can use that index stored in the widget to remove the item from the array when you fire your other removal logic.
I understand what you’re saying i need to do, but i dont know how. I already have the int variable inside the item name and i am incrementing it on event construct. But after that how i go about removing it? I am sorry i know its kind of a dumb questions and i’ve watched a few videos about arrays but couldn’t find one that explains what i am trying… Thanks for your time!
I was able to semi-fix it with a reverse loop and the custom Int as you suggested. It works as it should for up to 3 items within the ItemName array. The weird part is that if i add 4 or more ItemNames in that array the result comes back the max minus one every time regardless of how many i try to remove. Trying to figure this out…
Hey! It sounds like you may want to take a look into some programming fundamentals first to help all of this come together in the context of UE. For example in all languages that I’m aware of, arrays begin at index 0. An array of 4 items with have a maximum index of 3.
Sounds like you got it figured out though! The Remove Index node is the one you want to pass the stored index into in order to remove the item in the Cart array at a given index.
