Spawn random actor class in HUD

Is there a way to spawn in a HUD window (as an inventory item) 1 actor class from range of 3 possible in random order?

I have no idea where to start from.

If you’re new to the HUD, generally called UMG in Unreal Engine, you can take a look at this video tutorial series
Inventory with UMG

It shows how to make a simple inventory, add and use items from it. It helped me a lot, hopefully it will do the same for you

I’m assuming you have an event that shows the HUD.

You can do a [Random Integer in Range][1] with min set at 0 and max set at 2, promote that random integer to a variable…
At the event where you create the widget and add it to viewport you can do a [Switch on Int][2] with 3 pins where the “selection” is the integer that you promoted to a variable.

You should get something like this:

I added the delay and remove from parent part for debugging purposes.

In this example: Whenever “F” is pressed, one out of the three widgets should be showing on the screen for 0.2 seconds.

I hope this is what you’re looking for! Good luck!


This looks very similar to the thing I’m aiming, though I can’t get the Ceate Hud Spawn 1 Widget, is it a simple “create widget node?” Is this BP in level blueprint?

Perhaps I will clarify: I have an inventory HUD with 3 windows and I have 3 objects. I want the objects to appear in random order in those windows.

Would array or enum be helpful?

And thanks Unitrix for your previous answer, I really appreciate your time.

Thanx for the clarification

Yes i used the “Create Widget” node in the ThirdPersonCharacter blueprint.
Your clarification was very helpful for me to solve your problem with an array.

What you want should look similar to this:

I Made 3 simple windows with Umg. each with an empty vertical box renamed to BoxContainer and made it a variable.

**By making the boxes variable, they show up as variables in the graph editor. **
I first created the 3 widgets and put them into an array which then got promoted to a variable.

with the shuffle function of arrays, the order of the array gets randomized.

i created an Integer variable called “IndexOfObjectArray” and set it to 0. (arrays start with 0)

I dragged them into the graph editor and made a getter. then dragged the blue pin out and got “add child to vertical box”

after i add the object as a child to one vertical box, i increment the integer by 1 and continue to the next.

I made a simple Flip-Flop to open the inventory whenever i press the “I” button.

This is the finished result! Whenever I open and close the inventory, the order is randomized!

I hope this helps mate, I wish you good luck! if this answer helped you don’t forget to upvote and mark it!

Much love,


Hi there, I was wondering if my solution worked, do you have any more questions? Please let me know! Show us what you made! :slight_smile:

Much love,

Hey, Unitrix, thanks for your concern and sorry for neglecting to answer.

Your tutorial is awesome and very detailed, thanks for your time.

I replicated your steps; however, I could not figure out what exactly are the hud spawns? Are they just another widgets created in the same way as the main HUD?

Yes, they are widgets as you can see in the content browser of the last screenshot. They are indeed created in the same way as the HUD widget but they contain no code. In those widgets I deleted the canvas panel and added the text. Ex: HudSpawn1 only contains the text “HUD 1”