How to Create Widget BP from Data table and Structure?

Hi! I am developing a really simple HUD for decision making in unreal engine 4.26.2. The player will get a question and he or she can choose a good answer from A,B,C or D. It will be working on a Pico VR headset but it’s not so really important this case. I already imported datas from .JSON files to Unreal. These datas should be imported into the widget. So now I have Data Table and Structure but I’m not really sure what is the best way t fill the Widget GUI (alias HUD) from Data Table and Structure. How to connect the blueprint ‘behind it’? I never worked with these in Unreal before so I really need some help. THank you in advance! Cheers, Máté

It all depends on how the data looks like and how it’s organised. Accessing it can be done directly from within the widget if simplicity is what you’re after:

Here the button would pull next data row providing rows are numbers.

There are many ways to make the above (much) better; too numerous to list without comprehending what the flow of the app / game is, though.

2 Likes

Thank you really much for yourt answer, I really appreciate it!
So I will clarify what I need. Below I attached two pictures about my Data Table which contains yet only examples. You will see the filled datas and that every answers takes different points. On the other picture are the really basics about my Widget UI. It is about the player get a question and four choices with A,B,C and D. Basically the points shouldn’t show up in the widget menu.

So, I tried your graphs and my question is what is the method between Row name and Next Row? ANd where did you add SetText event to your BP?

Thank you in advance!


Not sure I understand what you mean by where. It’s all in the widget that displays it - something like this can be done in a single widget. Perhaps this bit is unclear:

image

Above, some widgets are not exposed by default but you can adjust it, so you can then directly set a text field like so:

image

the method between Row name and Next Row

Not really a method. Since I did not know what row names you were using, I assumed numbers. So the nodes would covert int → string → name. Not a very clasys move, I admit.


Your rows are Level00, Level01… But I’m still not sure what you really want to do here. We click an answer and then what? You must have some criteria dictating what’s right and what’s wrong and what’s next to display, surely.

Hard to advice without knowing more. As in,

  • I answer “What’s a sheep?”
  • how do we know what’s the next question - just the very next entry from the DT?

If you wanted something more advanced, I’d create a widget that represents a single question and have four of those widget added to a parent container. This way you can very easily adjust what and how each line displays its text.

When the next question gets selected, we feed those widgets relevant data.

Do tell if any this gives you a headache, I believe I could cobble something similar for you to take apart and take it from there.


edit: Thinking about it, I believe I’ve done it once or twice already, it’s somewhere on Answer Hub but I can’t find it, as per usual.

edit2: had to Google it, ‘quiz’ was the keyword AH could not handle:

Sadly the project link is no longer valid, but there’s plenty of examples about handling something very similar.

Hope it helps a little but do tell if it does not.

Thank you again, it helped a lot!

Hard to advice without knowing more. As in,

  • I answer “What’s a sheep?”
  • how do we know what’s the next question - just the very next entry from the DT?

Agree I didn’t make it clear. I make a game which has different levels. Level means here different scenes, places where the player can moving, acting or just looking etc. And all the levels will be ended up by a question panel. Only one so not a lot of question should shown up in the end. For the questions I need the Data Table because it can be updated and easy to change outside the WidgetBlueprint. For each question belongs four answers (A,B,C,D). After someone has chosen one answer by clicking the controller (because as I mentioned all the game will be played in VR) a new (second) window will pop up and it asks “Will you confirm your answer? Y/N”. Next (third) panel is about processing after clicking Y/N button. Last (fourth) panel shows your decisions points. The points are shown in the previous screenshot in Data Table as AP, BP, CP and DP. In this case probably you have right, it is more like a quiz. I hope it’s much more clear now but ask if you have further question.
I try to look at over everything what you’ve sent. If you have any additional advice according to the game description please tell me. Thank you!

Thanks again! Now it seems like it works basicly.

I have an another question may you could help me. I’m using widget switcher and after the player has chosen from the A,B,C,D answers (on the first page) then after clicking the sign on the next page will confirm your choose. On this widget page I would like to display the chosen letter A,B,C or D. Any suggestion how to solve this?
Thanks!

I have been trying to create a small quiz for each actor I have in my scene, say for instance in my scene I have a printer/mesh with an error ! symbol above the printer mesh. it is broken so in order to fix it you have to answer 5 questions, and when you answer all of them correct the printer error disappears. Exactly what he is doing here UE4 Tutorial | Simple Dialogue System with 3 Answers - YouTube but instead of images I wanted to it correctly and use datatables for the questions. But I just cannot get the data table to open in a widget. Do you all have any examples with something like this? I have tried everything with no luck. Any help from anyone is highly appreciated.

What does it mean that you cannot open the DT in a widget?

Ok sorry I am very new to unreal so forgive my ignorance on this subject. What I am trying to do is display my data table questions within a widget I created. Basically when you interact with the mesh in my scene you would enter the box collider of the mesh and click the “E” key to open the widget that has the data table questions and add to viewport. For some reason I cannot get my datatable to display within my widget. I hope I made since.

You’d still need to explain what that means. Give use the reason - as in, show us the offending script that is not working and someone will try to poke holes in it.


Since accessing and displaying DT entries is rather trivial under regular circumstances:

Perhaps you could focus on explaining what’s irregular and not covered by 100s of tutorials out there. In short: in order to help you, we need to know more about what is not working.

Ok I will put something together with code…etc and post on here. I appreciate you looking into this, The main problem is I tried to follow many different tutorials and I just cannot figure out how to add the data table with my questions inside of my widget and display it in the viewport. Just wanted to loop through about 5 questions within the widget and remove the actor when the question is answered correctly. Sounds like this is going to be more difficult than I thought.