Thanks, I forgot that you had done something very similar in the demo.
Creating the child classes for UI_Dialogue and UI_Dialogue_TextItem was not a problem (with a little help from google). In the designer tab, I copy-pasted all the widgets from the parent classes and renamed them to avoid conflicts. Next I overrode the getter functions and referenced all the new widgets. So far, so good.
However, during game play I noticed two issues.
1)
My UI_Dialogue child does not accept gamepad input. I am unable to advance or skip dialogue. The class is set to “Gamepad” under Class Defaults > Input. Mouse input works fine.
Are there any more functions that need to be overridden for this to work?
2)
When I use my own UI_Dialogue_TextItem child class no text is displayed at all during gameplay. The dialogue window doesn’t react to anything, not even the mouse.
What could be the problem? Do I need to override any other functions inside the class beside the obvious GetTextControl?
PS: Before I forget, some of the objects (most likely some of the materials) in your demo seem to be using the Substance plugin for Unreal Engine. It’s giving me warning messages all the time. Maybe they can be replaced with something more common in the future.
Just guessing here but the Gamepad controls are handled in the tick event of the UI_Dialogue base class, so if you inherited from it, you might need to either copy that functionality or add a call to the parent tick function? Otherwise, the only setup needed is to set the input mode to gamepad, which you’ve done. The gamepad implementation is really basic though, there wasn’t much I could do from UMG to deal with action and axis mapping so it’s all hardcoded. In my own project, I place the input handling of my dialogues in ‘unmanaged’ and control it from the player controller instead for that reason.
No, the only getter that needs to be dealt with in UI_Dialogue_TextItem is GetTextControl. The text is displayed through EventTick of that class, and the rest is fed in from UI_Dialogue. Try setting some breakpoints on the base text item class’ tick and initialize event/functions to see if those are ever hit and what they’re populated with. If you’ve overridden UI_Dialogue, make sure the tick is happening on the base class again and that all the proper getters are handled (like in the demo).
Oh the substance plugin message is nonsense, I created the project with a version that had the plugin installed but I never used it, and now I can’t get rid of the message.
Wonderful! I was able to solve both problems just by adding a call for the parent tick function to my derived classes of UI_Dialogue and UI_Dialogue_TextItem.
I actually expected the events to be inherited by default, so I’m kind of surprised this was necessary. Be that as it may, at least now I can continue to work on the line-breaking fix.
Just adding a SizeBox to my TextItem like this doesn’t have the desired effect. The dialogue box starts scrolling almost immediately and all you see is empty lines. That can’t be what you meant.
“The general idea is to create a new widget inheriting from the UI_Dialogue_TextItem widget and force the control to be it’s full expected width when the initialization happens so that it can wrap around properly before starting to print out the text.”
Can you maybe put this in more idiot-proof terms for me?
Yep, I fully expected that. You’ll need to update the width from the graph just before the first letter is typed in (the initialize function), and you’ll need to detect the expected size of the text field before hand. I’ve tried to solve this one myself, but had to drop it because I ran out of time. The problem is that the desired size isn’t being reported accurately and it leaves ugly spaces:
That will get you to the ugly spaces (at least in 4.9), but using the WidgetReflector (Window->Developer Tools->Widget Reflector) I can see that the desired size reported is not the same as the desired size in the reflector
Aw dang, that’s too bad. Sounds like a problem with the Unreal Engine itself.
I hope you can solve this issue eventually. I mean if you can’t do it nobody can… And until then, I don’t see much sense in continuing work on my little project.
(I was in the middle of rewriting parts of my last post just when you posted yours, but I guess that doesn’t matter anymore. You answered all the questions I had.)
This works for me on Actors with a Static Mesh, but never on Actors with a Skeletal Mesh. Is there anything extra I need to do to get it working on Actors with Skeletal Meshes?
This has to do with the scanner’s collision channel iirc (the visibility channel). The Character collision setup disables the visibility collision channel, it should work if you set the visibility to block on the character or mesh.
Great, thanks mate! I managed to get it working in the end, but thanks for the quick reply.
I am seriously impressed with this; There’s just something about creating and seeing a conversation progress, including various insults and Mum references… Ahh, nostalgia…
I was hoping you’d be able to point me in the right direction on something I’m trying to achieve using your awesome dialogue system…
So far, I’ve got a widget that takes the user input from a text box, and stores that text as a variable “PlayerName” in the FirstPersonCharacter Blueprint. This works, and I can see the output on-screen using Print Text or a text block in the widget.
What I’m trying to achieve is using that variable to populate a Script Interpreter variable within the Variables array, so it can be used in dialogue.
Here’s what I’ve added to the Variables array:
That works, and displays the placeholder “CHANGE NAME” in dialogue:
Here’s my custom event in the FirstPersonCharacter Blueprint, which I would’ve thought should set that variable, but I always get the “CHANGE NAME” value showing in the dialogue:
Any ideas? Am I using the Set Variable function incorrectly? Do I need to run array actions on the array itself?
**EDIT: ** Don’t worry about it; I worked it out myself
For the sake of anybody else that might have the same confusion as I did when trying to achieve this, here’s what I did:
Instead of spawning the BP Script Interpreter Actor in the Game Mode’s BeginPlay event, I created a custom event on the FirstPersonCharacter BP (which is triggered by the submit button being clicked on the widget - see video below if you want to see what I mean), which sets the “PlayerName” variable, then spawns the BP Script Interpreter Actor, and creates a variable referencing it:
On the child of BPC Dialogue, override the GetScriptInterpreter function so it uses the new BP Script Interpreter reference variable
In BP_ScriptInterpreter, on the BeginPlay event (after it’s spawned by the FirstPersonCharacter BP), set the variable created on the Variables array to be the value of the PlayerName variable:
Here’s a very simple demonstration of what it looks like (not very pretty, but just testing features at the moment):
[video]https://youtu.be/H4Z2gbtcJxE[/video]
Let’s say I put a dialogue component on an NPC and the player talks to that NPC, starting the dialogue. Is there a way to check for that in the NPC’s blueprint? Suppose my NPC is walking around and I want him to stop and turn to the player when engaged in conversation – how would I go about doing that?
I could probably manage it through the dialogue’s scripting using blueprint interfaces, but it would be simpler if I could do it from inside the NPC instead.
For the tenth/hundredth time, thank you for this. Buying it was a lifesaving move for my project, and things have been going very smoothly.
Hi Cinebeast, I’m glad to hear things are working smoothly!
To answer your question, there are a few ways I can think of to do this.
One way to do this is by checking if the **ActiveUI **variable on the BPC_Dialogue is valid. If it is valid, then that specific dialogue component is active.
or
For a global solution that can tell if any dialogue is opened, you can add the BPI_DialogueAware interface on your PlayerController.
This interface adds two functions: DialogueOpened and DialogueClosed (These functions will automatically be called by the dialogue component, so there’s no need to call yourself)
When the dialogue is opened, the DialogueOpened event is called, and you can keep a reference however you want to keep track of it. DialogueClosed is, of course, called when the dialogue is finally exited.
I just purchased your dialog system and… It’s awesome ! Even with few knowledges of mine, I’m able to do some simple tasks easily…
But now, I want to do a lot more. Your first tuto on youtube was quite helpfull but insufficient. I know it’s a lot of work, but you know, when you want to learn, you’re always exigent… So ! I just see this topic and I wanted to ask you something…
Did your dialog system programmed for more advanced taks like events ?
For example : I have to talk to “A” guy who tell me to talk to “B”. Once I talked to “B”, and return to “A”, “A” has new lines. is that already in the code or do I have to had some C++… Or is it simple to add it with some blueprint, maybe ?
I apologize one milion time for all my mistakes.
Thanks by advance, and for all your work. It’s fantastic, keep going !
Hi Ednoc, I’m glad you’re enjoying the system so far!
Yep, it was built with scripting in mind. There’s a built in Blueprint-Only script interpreter that you might have noticed, and this is hooked into the dialogue system so you can achieve what you’re asking.
A has two dialogue options: 1) Hi, go talk to B; 2) Great, you’ve talked to B!
We want (1) to run when the player hasn’t spoken to B, so in the Condition column we will check to see if a variable is set: !isvalid(hasTalkedToB) || !hasTalkedToB
If the conditions fail, the dialogue doesn’t run, so in this case we only want the player to say “Hi, go talk to B” if the variable hasTalkedToB doesn’t exist (isvalid returns false if it doesn’t exist), or the variable is false.
We want (2) to run when the player HAS spoken to B, so the Condition column would be isvalid(hasTalkedToB) && hasTalkedToB
The next thing we need is a new dialogue row to act as the hub and selects the right dialogue to say. A dialogue entry with the Silent and Hub traits in the trait column (eg. Silent; Hub;) will automatically select the next valid branch from the Branch column (eg. branches TalkToB; HasTalkedToB;) to process. The first dialogue to pass the ‘conditions’ test will execute.
The last part of the example is actually talking to B and setting the variable when the player talks to NPC B. The PostAction column is a good place to set new variables or call functions, and we would set hasTalkedToB=true in that column. Once set, the player would talk to NPC A again, this NPC’s current branch would be the HUB branch we made, then the HUB would try to see if TalkToB branch is valid, the condition would fail
The following sections in the documentation should help you out with advanced functionality:
Bought and used it for some testing and is easy to learn and looks awesome. Nice work !
However, I do not use data tables, but a real database (via TCP sockets) and an external program (in Java) to create dialogues. I never know upfront what the next “line of speech” will be (and who will say this line) as it is triggered by dozens of params and not even in UE. The only thing locally packed (in UE) will be the images as I suppose no other way around is available (correct me if I’m wrong).
Do I have to do this via the scripting as well (and have a closer look at the above mentioned links you provided), or is a (BP) struct and events for this available (should be faster, no interpretation needed) ?