How do I pull a random value from an array in a blueprint into an array in a widget?

I am trying to build an object, that when interacted with will add a single entry to a List widget on my UI.

I have an array (Objectives_All) on the object blueprint with 4 items on it:
0. Red

  1. Blue
  2. Green
  3. Yellow

I have another empty array (Objectives) on a list widget.

All I want to do is go up to the object, press E to interact, then have one of the 4 colors get added to the list widget. Seems simple, but I am new to this and really struggling!

I have the “press E to interact” working and can generate a simple message so I know that part is functioning fine, but I cannot figure out how to get the array item to update the UI list. I assume I need to cast to the widget from the “exit” of the gate in the Object Blueprint and have a “Add Unique” node to pull from the full array to put something in the empty one but I cant make that work.


Try a method similar to this:

UI

Your BP obj trigger box


Thanks for the reply.

I am trying to follow along and recreate what you have done here…

I am already using the EventBeginPlay to create a “press E to Interact” prompt. How can I use that for creating the list widget as well?

Edit* Also, how do I add the “Target Text Block 48” that you have coming out of Construct Entry List Object Item node in the UI? Not sure what that is referencing?

I am already using the EventBeginPlay to create a “press E to Interact” prompt. How can I use that for creating the list widget as well?

Can send a picture, like does the prompt contain any button to proceed ?

Edit* Also, how do I add the “Target Text Block 48” that you have coming out of Construct Entry List Object Item node in the UI? Not sure what that is referencing?

Here my entry list item:


Make sure to check the IsVariable.

The prompt is just a text on canvas. I have it pop up when the player enters the box collider. The prompt doesnt have any code in it to share, but you can see in this picture where I am first using it attached to the EventBeginPlay, then sending it to the viewport in the code below. It is called W Prompt Interact Widget

I am not trying to use the E button to actually DO anything until the gate where it will add an item from the source array to the list view array. Does that make sense?

Also, I found by entry list item, but I dont know how to pull a node in that references it? Mine is called “TextBlock_55” and is variable on my W_ListViewEntry widget.

From the output pin of the construct, drag and search “get text” you should see your TextBlock_55

I am not trying to use the E button to actually DO anything until the gate where it will add an item from the source array to the list view array. Does that make sense?

I see, then you can just add a 2nd create widget for your UI_List in the event begin, and then call it event after the Exit in the gate.

OK I have figured all of that out… but I am still not populating the array when pressing E…

Pressing E triggers down the False path like you would expect since there is nothing in the array, but it never adds anything.

EDIT* Actually it is doing SOMETHING because I can press it several times and it will eventually say “already added” or whatever. so it must be populating the array (somewhere)… but the UI List never updates. and If I try to look at the array variable during runtime, it doesnt seem like anything is being added (although I am not sure if the editor will show array values during runtime).

Try to replace the Construct with Create Widget, the construct seem to have some issue.

I think I have figured this out mostly now. I added an “Add to Viewport” node with the Main UI so that it actually shows the UI list. Before I was generating the UI via the construct in the Main UI Blueprint.

It is now adding the times to the UI… although I am still getting a duplicate once in a while… but I can work on that part. More important is that I am actually seeing things get added! Thanks for your help.

1 Like