Blueprint Dialogue System

Hello there
The conditions field doesn’t work in UE4.23. I set IntroBot@VisitCount = 1; as a PostAction in the first dialogue, in the second dialogue i check the condition IntroBot@VisitCount == 1.
The second dialogue “WinGame” is not entered, not even on consecutive interactions. Fixing this is urgent since it basically makes the dialogue system unusable.

Best regards, Albin

Hi Albin,

Try placing it in the PreAction column. The post action may be too late to process variables for the next branch selection (it’s been too long since I’ve coded this to remember and I’m not at home at the moment to verify).

The main thing I’m stuck with is how to access a bool from outside of the dialogue stuff. Here’s my situation. - I talk to a speaker, and after directing me somewhere he becomes unusuable i.e I can no longer talk to them (I do this with the SetActive(bEnabled==False)). Once I have done what he asked I want to set him to usable again in order to continue dialogue.

How do I set him to enabled again from a separate blueprint?

You’d need to find your character’s BPC_Dialogue component in Blueprints and set its “IsActiveDialogueTopic” to true. You can also use the ScriptInterpreter’s “ExecuteScript” blueprint function and pass in the BPC_Dialogue component as the handler to handle the event with for more complex script handling.

That worked. It also worked in the postaction when I spoke to the NPC a second time. Yesterday nothing worked though… Did I maybe forget to save the datatable between playtests then?
Just happy that it works honestly, your dialogue system seems pretty robust and scaleable so I’m happy to use it now :slight_smile:

Best regards, Albin

Is there a way when a dialog choice is clicked I can make that actor drop/spawn or give an item to player?

NVM got it to work with post actions

All my dialogue is being repeated twice in conversations. I’m using all the default setups and have done nothing other then fill out the data tables as instructed in the tutorials. I also just checked the demo content. It is doing it also.

Is there an easy way to make the dialog UI on world space instead of screen space? I made an actor an I placed a widget inside it. On my Dialogue component, I have overridden the function DisplayUI. I see you update the widget by removing from the parent and creating a new one, but this does not seem to work with world space widgets. I don´t know if I should destroy the widget component and create a new one or if there a simple way to clear all fields and update the texts. Thanks in advance.

Hi Unshattered,
Which version of UE4 are you using? The demo and my other projects haven’t shown this behaviour since 4.9 so far, and I unfortunately can’t think of what could cause this from looking at the code. Is it displaying “Hello World Hello World” or “Hello Hello World World”?

There isn’t a built in way to do this, but in the “DisplayUI” function in the BPC_Dialogue is where we create the widget. You can replace this and have it either activate an existing 3d widget component or somehow spawn a new one.

How do we set the portrait? There is something wrong or not working correctly with this struct. In the datatable I can see the portrait field listed, but it doesn’t show up down below to be edited. I see in the documents that this isn’t supported in 4.9 but I’m using 4.23…have they never fixed this? If so, you should just edit that part out or change it to say "since 4.9 it’s not supported’. To me it reads like it’s only not supported in 4.9

Hi crossmr,

Oh yep, looks like UE4 still doesn’t support setting object references in data tables. To set portraits you still need to use CSVs (eg. excel sheet or google sheets exported to csv and imported as a datatable from UE4). I’ve Removed the 4.9 version mention from the documentation, thanks for letting me know :slight_smile:

EDIT: I should mention that you can also set the portrait from the “SetPortrait();” script function if you have the portrait in your asset table (which will require a csv).

Is there someway to get the dialog to pause so I can pop up a widget and enter a value? After a player makes a choice, I need it to pop up a widget and take a text input (or I’m going to use arrows to let them scroll, we’ll see) but basically I need the dialog to pause while that’s done. When they close it I want the dialog to continue.

I’m finding the documentation/examples around conditions to be somewhat…unhelpful. The documentation just has vague explanations without much detail and the example doesn’t seem to have any real conditions in it. Just one row has a condition of “FALSE” and that’s it. Is there a working example that shows how to pull a variable from somewhere to check something as a condition? You gave an example earlier of something like this working:


But with no real context as to how to call it.

After a bunch of trial and error it seems like I should set an initial branch of some kind of “randbranch” selector that will go through all the greetings and then pick one based on conditions. But then I found out further issues. For example if I set that on the post action, it never runs. I have to set it on the pre-action of the item they choose (story/system). I set up a function to print all the keys from the variables to verify it and they won’t run. I can’t find anywhere to run it on “exit” at all, since my exit just closes out the dialog. Pre-action of exit, post action of greeting, nothing. there seems to be no way to clearly run it there.


I basically have to do it like this, which is fine if you have a couple options, but if I have 10 options on the initial dialog, it needs to be set in 10 different entries.
Nothing else causes it to actually run and register. Why isn’t post-action running on my hub?

There is no built in way to store dialogue state and resume after some kind of event and there are many ways to go about this (partially why I didn’t implement it). One simple way to go about it would be to separate the ‘resumed’ dialogue in another branch, and when the dialogue pausing, it can update the ‘initial branch’ to be the resuming branch. Of course you can code your own systems using custom dialogue script functions and script variables as well.

The condition column is called automatically whenever a branch is considered for display. If the script in that column returns true (be it a binary comparison, a variable with a boolean in it, or a hard coded true/false), the branch is eligible to display. It sounds like you were using this correctly in the second part.

The post-action should always run once the branch line is complete and there shouldn’t be an exception to this. That being said, we don’t make much use of hubs in our game so it maybe an issue that I simply haven’t encountered yet. We’re in the middle of a heavy crunch period at the moment, so I won’t be able to take a look at this just now.

I’m not sure if this works for what you’re trying to achieve, but you can have a silent initial branch that sets the visit variable and then moves on to your hub branch. Silent non-hub branches can most definitely run pre and post actions.

I ended up attaching a small widget with a couple of scroll arrows that allows them to choose the amount. it displays under the portrait when they need to do it beside the text. At least for now that works fine.

As to the second issue, I’ll try moving it to the silent branch and see what happens. It definitely didn’t seem to be working correctly based on your earlier example or how I was reading the way that it should have worked.

I’m still seeing some inconsistency in behaviour.

You can see in the screenshot, two basically identical lines of dialog. The text is slightly different, but otherwise they’re called and setup the same. StartExit works fine and makes the function call without issue. Exit is displayed as a choice in the dialog, but never runs the function call. They play a sound file so I know it’s never being run (among other stuff). They’re also both calling the same function so there is no chance there is an issue with the function itself. I also added a print statement in the dialog component and the print never runs.

As A test I changed the Created branch to “StartExit” and when selected by the player, the function runs, but of course that’s the wrong line of dialog for that situation. I tried making a new row in case there was some weird hidden character or something in it, but that didn’t help. wtf…

Edit: In a stroke of genius, I’ve determined that you can’t use a branch name called “Exit”, is this some kind of protected name? If so, this should be documented somewhere. If it is, then it needs to be in large bold flashing letters because I missed that.

Oh wow, I didn’t know that! The branch I’m parsing for internally is “exit”. It sounds like somewhere within the parsing the ‘_’ characters are removed or ignored. I’ll add this to the documentation, thanks for letting us know what was happening!

Yes, this probably also explains the issue I was having in the other dialog that I was setting up as well as I had an Exit branch there for ending the conversation. I’ll update all my dialog sets and check to see if the problems I was having are cleared up

is there any way to return the current branch? Also is there a way to disable, but not hide a branch in a hub? For example, if I have a condition for branch X and it fails it, I want to display the text for Branch Y. Like this:

Do you want to buy this?

Yes
Yes (You don’t have enough money)
No

Then on condition show either the first or second branch, but if the second branch is chosen, either click on it would do nothing, or the button would be disabled.

Additional issue, I keep getting this error in 4.23. I have opened the blueprint “verified and saved” but it keeps popping back up. How can it be fixed?


LogBlueprint: Warning: [Compiler BP_ScriptInterpreter] Default value for  Start Position  on  Extract Text Between Characters  has changed and this asset is from a version that may have had incorrect default value information - verify and resave
LogBlueprint: Warning: [Compiler BP_ScriptInterpreter] Default value for  Use Case  on  Extract Text Between Characters  has changed and this asset is from a version that may have had incorrect default value information - verify and resave
LogBlueprint: Warning: [Compiler BP_ScriptInterpreter]Default value for  Use Case  on  Extract Text Between Characters  has changed and this asset is from a version that may have had incorrect default value information - verify and resave
LogBlueprint: Warning: [Compiler Lib_String] Default value for  Start Position  on  Find Substring 2  has changed and this asset is from a version that may have had incorrect default value information - verify and resave
LogBlueprint: Warning: [Compiler UI_Dialogue_TextItem] Default value for  B  on  float - float  has changed and this asset is from a version that may have had incorrect default value information - verify and resave