How can I bind a print string from a DataTable to a Widget Text Box?

Hi everyone, I’m building an app for architectural visualization, where the user will be able to walk around the environment with the FirstPerson Default Project.

My intention is to make the user able to see object and furniture properties on screen when they left click on it.

All data and properties I want to show for the furniture are stored in a DataTable.

The only two things are left to do are:

  • Show the properties in a widget dynamically (I mean, when I click on an object the widget would show specific properties for that clicked object from the DataTable). I need to get the text rendered and aligned on the left center of the screen.
  • On second place, I would need to scale dynamically (fited to the text I would have rendered in the previous task) a custom image I made to act as a panel for the object information.

I would love to get something like this (very preview version of what I need):

The previous image has only text boxes I manually edit to make the example. You can also see how I have the blueprint I use to read the DataTable (please someone tell me it’s possible to bind info from there to the widget :frowning: ):

Any help would be so appreciated!! Thank you so so so much!

Well, you can first assign a tag for each of your actors (tag name should be equal to its proper row name of the data table). Then by using a line trace for objects alongside with an event tick, and by checking the hit actor tag, you’ll get what you want. The pictures I have created are just to show you how to do it. I haven’t tried it, but I hope it works.

140011-tagtable.png

Inside character BP

Inside widget graph

Regards,

Thank you so much for your answer navid!

I’ve constructed what you explained but there’s no line tracing when I now play the app.
It maybe seems to not react to the event because it doesn’t guess the object type to be collided in-game?

I’ve already created the array element camilla as well, but it seems to do nothing with it. Do I maybe have to create anything else (a blueprint for the object camilla, with a collision box, for example?, no idea :frowning: ) to get this working?
I’m not sure at all of how I have to specify the different objects to get them linked to the datatable (for example, camilla as an Object will be binded to camilla RowTable and this RowTable recognized depending of the result of the TracedLinebyObject, and a chair as an Object will be binded to its specific things too).

If you can help me to solve this would be so amazing navid, or whoever take a few time to figure this out!

Thank you so much!

Now I tried to create an object array (variable Actor) to make the list of all the object and now I have it like this:

But on the right, where you can add array elements, UE doesn’t allow me to select mesh from the viewport to store it in the list, neither the blueprint I built for it as an actor:

On the image, when I select the mesh Camilla or the actor Camilla, it doesn’t work, basically it isn’t added to the array. Because of this, I tried to store all the actors by creating this function:

But even with the function it seems to not work…

Please help… Thanks

The thing is you have set the object type inside the trace to ‘vehicle’. It means the trace only collide with vehicle type actors. You need to go inside your actors blueprints (those which you want to bind their information to the widget) and set their collision type to vehicle one by one. I’m sorry I can’t debug your whole blueprints, [it takes time]. Besides, I don’t have access to all the blueprints you are engaging with, for instance the custom function you have added. I just tried to show you a possible way to do it. Debugging the details is on you ;).

Regards.

I have recreated my answer and it works perfect for me. Just follow my answer. Now check the following questions, you may are missing something;

  1. Have you attached the widget inside the HUD blueprint?

  2. Have you bound the text box inside the widget design page?

  3. Have you correctly set the widget blueprint function?

  4. Have you set the game HUD inside the world settings?

  5. Your objects are actor BPs or just simple components? IF they are
    simple components, then inside the trace hit result, plug out the hit component instead of hit actor.

  6. Have you correctly set the object’s tag names? The tag names should be equal to the table row names.

  7. Have you set the objects collision type to ‘vehicle’?

Table

140177-table.png

Object 1

140178-firsttag.png

Object 2

140179-secondtag.png

140176-secondrow.png

Hello Navid, I know it’s been a while since your response, I’m sorry! I was very busy with other thing with the app.

In the first place thank you so much for your kind and complete answer to my problem, it has been very helpful!

I have developed a more detailed DataTable to make a bigger list of objects to cast.

In response of the things your asked on your last comment, I would like to say:

  1. I only want to have one widget to show all the object properties one by one depending of the user clicks. To do that is there a need to make an specific HUD Blueprint? (I haven’t done any!)

Here’s how I set my FPC Blueprint with the traceByObject.
2. I have correctly bounded the text box with a border.
3. That’s right!
4. I need to first understand what to do with the HUD Blueprint you said :(.
5. They are blueprints. Done!
6. I just set only two row names for the moment, but I don’t know how to get what just shown on your project, where you click one actor and Hello 1 and 2 appears for each Object Type.

192244-duda12.png

Here’s how I set my Tags array names (exact name as the datatable rows)
7. Done!

My DataTable is like this right now.

What I have now is that when I click on a object, the data shown on screen is now correct, but it only works for the first table row (named FF-6230), even after setting a second tag for another object… How can I set correctly a tag for each object I need to cast?

Thank you so so much Navid!

Hi again.

  1. first of all I didn’t use mouse click to fire ‘line trace for object’. I used event tick, because it’s simpler. which means whenever I look at the objects, the widget appears on the corner left side of the view port.
  2. I said to assign a tag name equal to the name of the table row which the information of that specific object is stored. You should only use ONE tag for each of your objects which should be the exact name of the row that the object’s information is stored. You have stored tag names of two objects inside one object which is wrong.
  3. You shouldn’t use branches for each one of your objects. Just follow my graph. One branch does the job. Doesn’t matter how many objects you have in your level.
  4. Unfortunately I have deleted my sample answer and don’t have it anymore, but the information I have prepared for you is enough to solve your issue.
  5. About the HUD, You should create a ‘Game mode base’ BP and a HUD BP and a widget BP. Go to your HUD and use ‘event on begin play’ then search for ‘create widget’ node and plug the event into it. Select the widget you have created inside the drop-down menu and add it to the view port. I hope you have correctly done the setup inside your widget BP (the third photo of my answer). Now inside the world settings select the name of your game mode and choose the name of your HUD bellow it. Open up your game mode and do the same thing there (select your HUD name inside the proper drop-down menu).

Inside HUD.

Inside game mode.

World settings.

192251-world+settings.png

The concept of my approach is quite simple. You just need to understand the logic behind it. For simplicity, I suggest you to recreate a very simple model like mine (hello 1 and hello 2) then try more complex setups.

Regards,

Once again Navid, thank you so much, I appreciate your help a lot!

I have tried what you just said and I think I almost have understood everything, except the part where you explain that I have to assign one single tag for each object, because I don’t know exactly how to do it.

Do I have to assign each one of the tags on every single objects BPs? Or should I do that in my FPC BP?

In my case is necessary to do the TraceByObject just when the user left clicks because I only want to show the object data when the client clicks on it. What do I need to specify in this part of the code then? Do I have to just set the tags Array as you explained on previous answers on the FPC BP and then set every single tag on each object BP?

Sorry for doing this bunch of questions, and thanks a lot Navid!

First you need to know your objects are static mesh components or are actor BPs that you place them in the scene?

*If it’s an actor BP, there are three ways to assign a tag to it;

  1. open up the actor BP and in the component tab, select your mesh that you want to set a tag name for it. Then in the detail panel search for ‘tag’ and add a tag to it then name it equal to the row name where its information inside the table is stored (as I mentioned before).

  2. open up the actor BP and in the component tab, select your actor BP (which comes with a ‘self’ at the end of its name). Now do the same thing as method 1. (this will affect all the instances of your actor BP in your level)

  3. place your actor in your level and select it. In the detail panel, search for ‘tag’ and do the same. (this will affect only that specific instance of your actor BP in your level)

Note : If you follow the first method, then you must drag off ‘hit component’ from trace hit result not ‘hit actor’ and search for ‘get component tags’ node then plug it into it. Leave the rest of my setup unchanged.

*If it’s a static mesh component, there is only one way to assign a tag to it;

place it in your scene and in the detail panel, search for ‘tag’ and set a name for it.

Note : If your objects are components not BPs, just like first method you should drag off ‘hit component’ not ‘hit actor’.

If you plan to bring up the widget by a mouse click event for instance rather than event tick event, then you should communicate with your HUD BP and add the widget to the viewport and then remove it which is a little complicated.

Regards,

Hi Navid,

Sorry for the late answer again, I’m very busy nowadays and it’s being difficult to find time for this project.

I have tried what you said and I can assign tags to my BP actors correctly, but I still be investigating how to implement them on the FPC.

I know you said before that I’m setting two tags for one object but I don’t think so, I just have set 7 tags on tag’s array, but I don’t know how to call just one of them with the traceByObject.

If you see the screenshot, I have set the tags just on the tag’s array (ignore all the stuff down from Camilla 2 because everything is unabled), but I don’t how can I do to just call the single hit object when click on it (I think now the engine is calling all the objects from the sequence node, and that’s why this is not working properly?)

Here you have finally, an example of how is set each one of the BP Actors’s tags (I have chosen the second way to assign them from what you told me).

I want to thank you again Navid, I know I say it on every single comment but you really put your effort to help and I appreciate that a lot!

Hi,

Two things;

  1. It’s not your job to determine tag array elements inside your character BP manually. This is hit result that takes the job automatically (you should assign tags to your actors manually not inside your character BP).
  2. There is no need to use branches equal to the number of your tags (again because hit result sets your tag variable element). One branch does the job for all of them (as I have mentioned before). To remind you, take another look to one of my early images;

Note that your tag array variable should have only one element at any time, and it acquires that element from your trace hit. Once the trace hits another actor, it should replace the previous tag with the new one.

Again I suggest you to use ‘EventTick’ for your trace channel. After you could get a meaningful result, try to make it more advanced.

Regards,

Hi again Navid,

I understand now how to assign tags then, but I don’t know why this still not working. This is how I have my FPC now:

I checked it in real time and I’ve seen that the set tags appears to be not valid.

And just in case, this is how I have my Get Text function inside the Widget:

Now I just have one object to just try to get it working. That object has only one tag inside it’s BP, with name equal to one of the DataTable’s Row (just the one that I want to show for that object, of course).

Regards Navid,

and thank you very much again!.

Okay I’m sorry! This is working for now.
I’m a noob, I forgot to add the widget to the viewport…

This is finally working Navid, thanks for your awesome help, I don’t know what would I got if it wasn’t for you!! :slight_smile:

I’ve opened another question with another problem I have to solve… (necessary for the functionality of the app).
If you can help me with this also, as always, would be so much appreciated!

Here you have my question:

https://answers.unrealengine.com/questions/675769/how-to-make-an-stackable-widget-menu.html

Cheers!!