Hello,
I am creating a set of targets for a game. One feature is a control computer in which you can have a map showing the targets and interact with them.
In my map widget I would like to spawn multiple interactive icons (they get values from the targets and send events when clicked). I have set up this part like this, in the EventConstruct line:
For Each of the array, it creates a widget icon, which I set its “TargetRef” variable with the Array Element from the loop. This allows the icon widget to know which actor it is assigned.
Below that (not shown, where the two blue path are going), the Array Element is used, process them and adjust for the Set Position, which is pulled from the “Space for Targets” variable Overlay. I am not sure what I am doing here with the “Slot as Canvas Slot” but as I could get a Set Position which is nice.
Further than that it’s just an Add Child.
However when I test it, only one of the widget is shown. I planted my blueprint with printstrings, tried multiple things and I can tell the following:
-each child is created (child count goes up as the loop goes)
-each instance of the ForEachLoop returns a different set of coordinates, which is normal and what I want
-everytime I add more targets, the last spawned target is the one to appear, all the others are not shown
If I don’t use “AddChild” but “AddToViewport” instead it works, however I need to create an array to contain their references to delete them when I close this widget. I’m not sure it really affects performance, however for the form and training I would like to know/learn with the child.
I’m really not sure what I’m doing wrong, and it’s probably a small problem, but I’ve been looking for hours and I can’t make progress alone. Thanks for any help on this (even if it’s just informing me I can’t use child for this)