The main widget is just a canvas panel with that vertical box.
Let me know what you think the next step should be. To go from the input fields, save valid player names to the players array inside the third person character and then add those to the right-side?
Something to note here is that we will not be relying on "getting the children of the ‘input fields vertical box’ ". Rather, as we create the field widgets, they are saved to an array. It’s this array we will be working with if we want to add or remove, or get the current player fields. We will just tell the vertical box to update visually, based on the order of that array.
This is something I recommend doing in general since it gives better control, reduces casting (since “get child” of vertical box returns a User Widget) and generally makes coding easier.
Updated main widget:
Now for sorting the valid players and passing them to the third person character. First of all, you’re getting the controlled character and casting it to third person character. If you want to get the third person character again, you’ll have to do the same thing again. It’s not that it’s some expensive operation, it’s that it adds clutter the blueprint. There are two ways to do simplify this; if your thirdpersonchar is creating the widget, then:
Inside the widget create a new variable. Make it type third person character (reference) check the boxes “instance editable” and “expose on spawn”. Then go to the thirdpersonchar where you create the widget, and input a “self” node into the new input.
The other way, is to do the “get controlled character -> cast to thirdpersoncharacter” and save the return value to the variable, or right click it and “create variable”. This could be done on the construct event of the widget.
So, when the play button is pressed, add the valid players to the character array. Looping through the array of player fields, check their player valid and add the name to the array. But how do we get the name from the field? We could “get editable text box” from the array and “get text”. Or we can create a new function inside the field widget that returns the name. That way, if you ever want to change how the text is stored, you don’t have to go to the main widget and find all the places that you did this, but instead just update what the function returns.
As a last note, there are a lot of improvements that could be done to the above. This is really just to show some methodology. Like the “make literal string”. It works, but it may be better to replace it with a string variable so you can easily change what is displayed, rather than diving into the blueprint setup, looking for where this literal string could possibly be. (all variables can be seen in the “class defaults” tab). Or, instead of cluttering the event graph with nodes, put those nodes into functions with good names. Speaking of good names, “update vertical box” is not exactly a good name, we will probably need another vertical box. So name the functions something descriptive.