I have 5 interactable objects. They have collision triggers and when you push ‘E’ they each do something different. I’d like to display text on the HUD that describes what the interaction is (e.g. Open Door, Lift Up, etc.)
I know I can create a separate HUD widget for each interactable object, but I’d like to be as efficient as possible. Is there a way to create 1 HUD widget that pulls in variable text that is set in each interactable object blueprint?
In watching a few tutorials, I started to create a Structure BP with “DisplayText” as an variable. Then I added that Structure BP into each interactable object and set the text there…
If this is a good way to do it, how do I connect that to the text in the HUD widget? In the tutorials they did other more involved steps and I got lost in deconstructing just this simple one.
Create a Name/String variable inside A_Intractable Object called “InteractionName”
For each of your unique interactions you create a Child Blueprint Class (left click on A_Intractable Object in Content Browser and create)
Now all the Child Intractable Objects will inherit the same InteractionName Variable.
Inside HUD element create a String/Name variable called “ActiveInteractionName”
On collision you trigger an event inside the HUD element which grabs the InteractionName of the Child Intractable Object you are colliding with and set it’s value to the Text Widget which shows text to the HUD
I have mine set up so you just walk straight to the object instead to interact with it and I don’t have to press the E key at all… But I only know enough to get that working just for Static Dialog. But I didn’t set it up the right way as I used more than one
textblock widget to try to set it up.
But now I want to dump that idea. And go with the data struct table method. So This is what I’m now trying to do.
Static Dialog. For this I simply want to get the textblock widget to read in the text
from a data struct table by the row number. but I don’t know how to link up the textblock
widget into a data struct table.
Random Dialog Array lists. -
For this type of dialog which uses an Array for the A.I. I want to set up a string text array index list. And it picks a row number from the array then reads it from the data struct table using the row number for reference. Now how do I do this? I Need to see the binding code for setting up the widget.
There is no binding code. You create a string/text/struct variable (or even an object reference that contains those) in the widget, select the text block and pick the aforementioned variable from the list.
Okay, so no bind is needed. When you say create a string /text/struct variable, Are you talking about the main “IS VARIABLE name” text field that’s at the top of the details panel window with the white checkbox beside it? If I reame that, it should show up as a Blue Box object in the widget list or as a Blue node reference in the blueprints (I think)…
Now how to I get the widget textblock to read text in from a data struct table to read in a row entry? I need to know how to link this up. I have to also try to figure out how to set this up also using a text string array.
Now once the data struct has been created and the blueprint variables have been entered in. How do we access the variables in the data struct to use them as blueprint nodes?. They’re not showing up in the node list so how do we access them?
i will also need to know which blueprint graph I have to put this in, First Person Character?, or In the blueprint Graph of the textblock itself? I’m not sure which one it supposed to go in because I don’t know this engine very well.
I’ve also got alot of little minors issues plaguing me because of my lack of knowledge with the nodes.
First of all, apologies to tbensman for the thread hijack I’m about to commit.
No, the normal regular variable, in the widget graph. Go back to the Designer, select text block; in the details panel, content tab → bind → choose your variable. This text block will now display the value of bound text/string variable. Whenever you want to update the text for this widget, you simply Set this variable.
Now, this is a good question.
As a rule of thumb, try to keep the widgets themselves as clean as possible. I keep most of the widget references in the HUD, I just find it convenient. So you could do the above in the HUD.
Also, regarding this:
If I remember correctly you are planning to deal with a fairly large amount of text. You can set up multiple DataTables as you already know but you can also read, lets say lines 250 - 750 and put them in an array instead.
Yes that’s right, I have a large amount of text. But This is a great help thank you. Now I just need to know how this is done with an array string index, how do we read multiple row entries into the array from the data struct table? We need to also
get Unreal to play the audio file from the data struct table to go along with the dialog text, and we need it to also display the
portrait pic also of the speaker. Probably need widget variables for this to assign to the portraits so the game
can identity them.
Now about the normal data struct for all your other game variables., how do we access this from the blueprints
once we have created the data struct table?
As for the widget, I think I done this right, hit the Bind on the Text field that’s under the content area up in the details tab . I named the variable Diag. Now the two purple nodes Get DiagText 0 and Return node are now linked. Compiled that.
Now I’ve to figure out how also to switch the pawns, so when I bring up the minimap, I want it to switch
out of the hands and gun mode into the full 3d person view. So I don’t have the hands and guns showing on the map
no more when I’m walking around on the map. I also wish to add that as a key press option to switch the modes, at the
moment I have only 1st person mode I can toggle on or off.
Yup, you can include it in the struct. And bind it just like the text to the image in the struct. (you can just send the entire struct to your widget if you want to, the widget variable binding supports it)
You can access DataTables from pretty much everywhere as far as I know.
This would work but is unnecessary, just create simple variable and bind it directly, there’s no need to create a getter function for this. Like this:
I can’t set this up yet not until these missing nodes issues have been resolved.
Unreal dosen’t display all of the nodes in the main list to allow me to just assemble up the code like putting together a puzzle. INSTEAD It wants
me to think like a programmer does to meet certain logical conditions first and then when I meet those special conditions then it will display the missing
nodes, I think that is wrong I think it should be the other way round to show all the nodes in the list and then set all the logic conditions, as not all who
have the engine are accomplished programmers who understand its logic, and I am NOT a experienced programmer of its logic. I don’t understand half
of the logic that this engine uses because I don’t know the node structure, The only way I got things working in my game was to follow online tutorials
and not all the tutorials worked, only some of them worked.
This makes little sense, there’s no need to type anything, you choose a variable from the list. Show us some screenshots, how you create a variable in the widget and bind it to the text block.
Not sure what you mean, I did no such thing. No behind the scenes magic involved.
Of course you cannot. If you did not create your own DataTable with the appropriate struct, you can’t do this. The name of the pin reflects the name of the struct you used to construct the Data Table. Transform Str is just an example name I had laying around.
This is most likely because you never created the variable in the widget or are using incorrect widget reference. Again, show us some screenshots - how you construct and reference the widget in the instance of your HUD class.
Something not right my screenshot is totally different because I can’t seem to find the text alignment options for centering the text within the textbox
the alignment options are all missing. so it must be the wrong type of textblock I have because I used the normal plain Textblock, NOT the multi textblock
and on your screenshot i noticed it is set to GRID Panel SLOT but I got mine set instead on Canvas Panel slot.
I used the Globals Struct table so that must be why I have to use the data table csv format instead in order to get that
blue transform struct node to show. Ok I have a csv editor here so I will go back to that text example showing the row
entries screenshot and see if that gets me the blue node I need.
Now as for fixing the pink set node as to why the blue pin is not showing on it? I’m not sure how to fix that, Ive only got two pins on the set node
which means I can’t even link up my widget reference up to it not until that blue pin becomes avaliable for it to link…
And because there’s no “add extra pin option” on the set node, I can’t fix it by changing the pin type as that node won’t allow me to add
in any extra pin types on it.
So because I can’t get the blue pin to show up on that pink set node, I’ve got broken nodes as a result that can’t be linked. So at
the moment I’m screwed until someone can show me how to fix it
What’s this node that is just after the break transform string node?, i need to know what node in the list that is how to bring that node up.
its a small two pin node with a orange left pin and a pink right pin on it.
The widget is in the main Gamehud blueprint. The reason why I got the two purple nodes in the binding before is because I clicked on Create New Binding
instead of clicking on the widget variable reference that was underneath it. now fixed that, so only the Widget Variable has been selected.
It is because you are using EditableText which allows the end user to type in text; probably not the best idea for a container that just displays the text. You can use Text (a.k.a. TextBlock) from the common tab of the palette. And the binding in the screenshot looks fine.
You need to know 2 things:
the blueprint that holds a valid reference to the widget (show us how and where you create the widget, ideally in a screenshot)
the trigger that is responsible for updating the widget (the collision box the character enters?)
Nah. Let’s not have that, that would crash pretty much everything I touch, more that it already does. But seriously, the pins aren’t missing. The nodes are context sensitive and work as intended. This behaviour essentially prevents you from messing things up really badly. Dangling pointers and such. Bad karma.
This is a convert node, in this case it turns a Transform (Location, Scale, Rotation) into text. You do not need this node, not for this at least. If you create a proper struct with the text, image and so on, you will not need it. Also, convert nodes are usually added automatically by the editor and in most cases do not need to be invoked manually.
I had TEXT BLOCK selected that’s why I got editable text showing. Now I’ve selected the one reading just TEXT the next one down under it in the pallette, Now the widget name for the textblock reads now as TextBlock_118. I have now converted that into a variable. (I clicked the white checkbox beside the variable name just under the details tab. Now I can center the Text… The alignment box options are now showing up.
The Blueprint that holds the Textblock Widget’s Variable name is the main GAMEHUD blueprint graph itself is called Textblock_118.
And heere’s the Blueprint that holds the On Overlap Trigger in it, it is found inside a separate blueprint class called Philq1 but this was set up it as a separate class (the white ball object on it). to trigger off just dialog.by stringing several widgets up together, but I’ve now set the class of the widget that contains the on overlap trigger now to GAMEHUD for the class because I cannot select the Textblock_118 widget reference from the list I can only select just only the widget blueprint class with the Create Game Hud Widget node. I can’t select the
Class Component Object.
Now my dialog won’t play and the text won’t show now because I had changed the class. But that’s normal because I’m gonna read the text from a data struct table instead. I grew weary of creating all those widgets. That’s why I’m looking for a more effective way to display my text.
DATA Dialog STRUCT: in your Data Dialog structure table, the last two Flags you entered in called ConditionFlag and Cameraflag they both have dark green colour codes
on them and I think its an ENUM flag of some kind. But I don’t know what ENUM variable you picked for there’s over a hundred enum flags that are listed…
And because I don’t know the flags all that well, I don’t know which ones to pick for
Camera Angle, Animation file to play from, Quest ID and so on.
Which flags do I pick?
I now got the data struct working with the dialog text row csv data but got to get the last two flags on the columns the correct flags.
First things first. There’s been some miscommunication here regarding what HUD is. You probably think that HUD == Widget that displays text, images and so on. Not really. Unreal has some build in governing classes, like GameInstance, GameMode, HUD, Pawn, Controller and so on. This ***HUD *** class has very little to do with widgets. Before widgets were introduced to blueprints, one could create a heads-up display in the HUD class but it was *somewhat *inefficient, let’s say. UMG (widgets) are an order of magnitude more powerful (and complicated, of course). These days, you technically do not need to use the HUD class at all if you do not want to. I use it as a hub for anything widget related, to track the references, to manage and destroy widgets, handle my own debugger. The HUD class allows you to draw *neat *2d lines, additional text, efficiently show images and do some other stuff. You can definitely create a simple interface with the HUD class but we’ll stick with widgets.
You can have a quick read about setting up the *GameMode*here, this is something you cannot do without. Understanding how this stuff works is critical in UE4 and will alleviate a lot of frustration. The general idea behind it is to replace (extend) the UE4’s basic build in classes with your own which you can tailor to your game’s needs. That’s the gist. There’s a bunch of tutorials about it on YT, too.
Currently, you are creating your widget (which you happened to call Game HUD, leading to additional confusion, but that’s fine, really) in the Philq1. This means that every time this character engages in a conversation, he (gender assumed) will construct the widget and will be held responsible for managing and removing it as well. If you ever want to play as any other character, you will have to duplicate the code you currently have. That’s why I suggested you create the dialogue widget (I’ll refer to your hud widget as dialogue widget) in the HUD class I mentioned at the very beginning. This way you’d have only one dialogue widget to worry about at all times, no code duplication and a single location where widgets are handled. Any character would then send the data to that widget and kind of control it remotely. I hope this makes sense.
Let’s stick with Philq1 creating his own widget for now, you can always rework the setup later. The most important part you are missing is the Widget Reference you never create. Reference is a pointer to a location (in memory) of that object. Without the reference the engine does not know where to look for that object.
You construct the widget, add it to the viewport.
Right click the Return Value and PromoteToVariable. This will create a new reference variable of the correct type of your widget. Rename it to *DialogueWidget *for example, you should end up with something like that:
You can now use that widget reference to set the widget’s text we talked about before.
The enumerators are flow control switches that you create yourself. Right click in the content browser Blueprints → Enumeration. Give it a meaningful name. Double click and set your own flags:
I"M UNABLE TO GET THE BREAK TRANSFORM_STR DATA NODE to show up in the list so I can’t link it to the row data text table, its linking it up instead
to the data flags STRUCT table and I DON"T KNOW WHY… Its supposed to be linking up to the Data string Row Table, not the Data Struct Flags Variables table. So there should not
be the pins Speaker, Camera, and so on appearing up on the Node when I expand it… But if its showing up all these pins on it then its reading from the wrong data table.
I also ran into trouble trying to set up the array as well… For some strange reason the last node refuses to link up saying the add node I’m trying to link to is not compatible. Not Compatible???, What the hell? AND it also threw in FOUR Converter Nodes as well instead of two. My patience has just about run out with this engine and its backward ways…
Why don’t all the nodes show up in the gamehud class blueprint but only like to all show up when I swap into another blueprint? , it makes NO SENSE…I think it was was a bunch of japanese guys who created this blueprint system and Its is not very user friendly because its built on a system that works in reverse… You use the node list the most frequent so it makes sense to beable to change views to see all the nodes. but I only see this option on the content browser menu to change view type, its not on the node list menu.
We created the widget reference in the Philq blueprint so you can access it there. So Philq can enter the collision box, get the reference to the widget, fetch the appropriate DataTable line and send it to the widget through the reference. The whole idea was not to access the DataTable in the widget. Access the DataTable in the Philq blueprint, keep your widgets as light as possible.
You could do it the way you are doing it but you will need to add a CustomEvent to the widget that will extract the data from the DataTable.
You are seeing two pins because you are trying to access the widget through a reference to itself. While this would work, I guess, there’s no need to, that’s quite awkward. (if you really want to change the text variable from within the widget, why don’t you just alt-drag it from the MyBlueprint panel?)
When I created my *custom *struct for the DataTable I named it Transform_Str, you named your custom struct dialogstruct.
I see, so I have to build the code into the Philq blueprint in order to get the Data Text Table row thing to work. because it is true I only want the widget to activate only when stepping into
an on overlap trigger with an NPC when you get close up to it. There’s something called Storyline too, which I may have to look at… I also I see that the arraystruct node is linked to the ADD Node, But I don’t know how you set up the Arraystruct node elements that’s within the node because I also want it to read a certain range of rows from within the data table into the array and then shuffle them and display one up in the widget. That’s needed for the A.I dialog to give random responses back during the dialog. Once that’s working, the other thing left to do is build the decision making choices in the widget.
Yep just as I thought, I ran into Pin troubles with the array because the arraystruct variable was created in Gamehud not in Philq…
So I have to delete the array struct variable and re-created it in Philq.
Now in this FOR LOOP node, whats the 250 and 750 stand for? It can’t be the row number.
Most of it is now all linked, as I found the break node, I had to construct it myself, you didn’t tell me I had to type GET TO TEXT in order to access the conversion
nodes, so what’s not working now is just the Arraystruct001 reference node. I can’t link that up to the get array because the get node with the array
is telling me that the reference is not compatible of the same type. I don’t know what this really means, so I’m stuck on that… As I don’t know how to