How to spawn a list of weapons in a ue4 widget

Hello.

I tried few examples in the main discussion forms but none of them seem to work for me. I have a list of equipment that I need to spawn as buttons/dropdown menu. Please take a look at the attached screenshot to see my current progress.

This topic has been moved from Feedback to Programming & Scripting: Blueprint.

When posting, please review the categories to ensure your topic is posted in the most relevant space. Hopefully, this new section will get you the answers you want! :slight_smile:

2 Likes

My very first post. Thanks for moving it.

My pleasure :slight_smile:

You should set breakpoints on every node (F9) and start the game. Each time a breakpoint is hit you can read the current values per node. You will also see up til what point the method will execute and this will tell you what part is failing.
There are a few things likely to fail:

  • Is the owning player object deriving from the cheat manager class?
  • Are there any values in the Name container?
  • Remove the “cast to horizontal box” node, you are trying to cast a UserWidget to a horizontal box which is invalid.
  • Connect something to the red event node which is supposed to execute.
1 Like

I’ll try this now. Also, is there an easier way to spawn all the elements inside of the array via buttons?

Which is the last breakpoint to hit?

Now you are not adding content to the horizontal box at all on the image :stuck_out_tongue:

Apologies. I’m new. I’m trying to figure this out. The solution above was one of the solutions that worked for others.

from my understanding, the content (buttons) should be spawned inside of the horizontal area?

Fill dynamicly a box on a widget can be pretty hard if you never worked with dynamic widgets. But basicly the first thing you need is the widget (ofc) and that widget should have a vertical box (ohters like horizontal box also works but my recomendation is to use the vertical box), and you must make sure that it is editable.

Then you are going to need another widget that holds whatever you want (text, buttons, images, etc) and for each weapon create a new widget and add it to your first widget’s vertical box. Also, the widgets that you are creating for each weapon should have an exposed variable (or multiple) with whatever you want to appear on the widget. For example to display text your gidget should have a variable call weaponName (or whatever you want to call it) and make it exposed, so when you create the widget you can set directly the value.

This video is an example of what I just tell you. If you search ue4 inventory system you would find lots of tutorials explaining it

2 Likes

Thank you for sharing. I’ll take a look, and let you know how it goes.

In the button widget you should have a variable (name for exameple) and bind the text with that variable, and in the detail panel of the variable you should click expose on creation, so when you create the widget you can easily asign the variable

I think I know what’s happening but don’t know how to explain property, sorry

1 Like

you call a return node directly during the first time the name array loops. Calling return stops the loop, it will not call return multiple times. Return completely stops the execution of a function. I suggest you watch a few tutorials on youtube of the blueprint basics / programming basics because you do need a better understanding of these.

That actually worked. Thanks a lot. I think the problem I had was with binding the text using unreal stock function. I was able instead to set the text directly to my equipment variable.