Adding and Removing Widget Childs from an Array

Hi everyone,

I’m struggling with something that probably can be solved easily.
I just want to know how can I add and remove items from an Array of widgets.

In my game the user should be able to click an object to see it’s properties and adding a widget child to a parent widget inside a scroll box. This part works perfectly. But I don’t know how to create this childs as part of an Array. What I need is to add this elements to an Array because then, by pressing a key, one element of the Array (so a Widget Child) should be removed from it and consequently, from the screen as well.

Basically what I tried to do here is creating an Array of Widget in the FPC BP, then remove an index from the array when the user presses a key (triggered by a Custom Event).

I’m quite new in Blueprints and I’m not sure if this is all the needed info to help me solving this problem, so just let me know.

Thank you so much to anyone who can help me in advance!

Are you sure the custom event is actually being called from the First Person Blueprint? Depending on how you set your variable “HUDChildReference” the cast may actually be failing and as a result the custom event is never being fired. To test this you can add a Print String node to the cast failed part and one to the success path to see what is actually happenng. Also, in the widget blueprint, removing index 1 all the time? that isn’t necessarily going to be the child you chose to remove (please keep in mind I don’t know exactly how your setup works, so this is all based off what I’m guessing is happening in the rest of the blueprint). If you need more help setting this up please leave a comment below :slight_smile:

Thank you so much for your awesome answer Kit Kat! And sorry for taking so long to reply.

The Custom Event is being called from the FPC BP yeah! within the Widget casting but actually I don’t know either how to set the Cast to work properly.
I did now what you said and the print String shows that the cast is being executed.
And on the other hand, I set the Remove Index on 0 basically because it’s okay if the user just deletes the first element of the list every time he presses the key.
Hope everything’s fine already with this answer now! :slight_smile:

And seriously thank you so much!!