need help with making the attack selection list blueprint

so i have a child widget select_opponent_button connected with this widget and i need this blueprint to dynamically show as many butttons as there are enemies spawned,
the enemies are an actor called enemy

The enemies array is empty.

  • how, when, where do you create and add this widget to the viewport?
  • how, when, where do you spawn the enemies?

the widget is connected with this widget

and the battle_status_widget is added lioke this in the level blueprint

as for the enemies they’re spawned like so in the level blueprint

1 Like
  • the level BP spawns enemies. :+1: Got it.
  • the level BP spawns creates the widget has the other widget that needs to know about the enemies :+1: Got it.

Thanks!


Could you explain how this bit works:

You say you spawn many enemies., right? How do you do that. Is there a loop somewhere here?

Does this script run on Begin Play?

As you can see from the image it doesn’t always spawns some enemies thanks to random bool with weight. It can spawn up to three enemies to three different target points and no it runs on begin overlap with a trigger box that is placed on the level ( the widget creation and enemy spawn )

That’s fine. But if this runs in a loop:

Does it mean that you create too many widgets…?

the bp doesn’t have any loops

  • flag the widget enemy list as Instance Editable and Exposed on Spawn

  • spawn enemies, keep them in an array (you did say up to 3)
  • once the loop (or however you make it up to 3) completes → create widget → pipe in the enemy list

This way the widget Construct can use the array straight away. But you can also keep adding them as you spawn the actors.

hold on the array i have is at the widget blueprint and not at the level bp where i spawn enemies, how will i fill the array then?

As shown above, if you want to use the widget construct. You don’t need to, you can add to elements to the widget’s array instead. But then you cannot construct in the widget.

Is getting elements of the array enemylist of the widget in the level blueprint right like this?
And if it is do i do it for every SpawnActor Enemy?

in the create widget how did you make the enemies node?

Look at the first bullet point of my post.

the create widget has that enemy array node, how do i make it since the method on post 12 indeed has the issue of not being able to add it to viewport afterwards

Have a look at the 1st pic of my post, that’s how you expose it.


I must admit I do not understand why each enemy has the Enemy list:

And by setting the Array, you override it anyway with itself.

if you’re talking about expose on spawn does it not work since the array is in the select_opponent widget while my create widget has its parent battle_status_widget? like this

  • in the select opponent widget:

  • spawning enemies:

for the first imge is the add enemies a custom event in the widget?