Hello, newbie question.
I am currently trying to make a dialogue/text system but I am kinda struggling.
I don’t want a very advanced or complicated system with many options for the players to choose. I just want a normal dialogue that once you go to an object/character, you press a button to trigger the dialogue. However, I want to be able to call some dialogues in cinematic sequences/cutscenes as well (without pressing a button, but just setting a timer like 5 seconds and then make it disappear). Is there a way since I don’t think you can trigger blueprints in sequences.
What’s the simplest way to make something like that and is there any tutorial/guides for that?
You said you want the simplest way to implement, so I won’t include anything fancy like dialogue trees or animated text in the explanation.
So, initiating the dialogue is the easiest part: line trace FROM the player TO directly ahead of the player. If it hits an object, check if the object is a dialogue-capable NPC and initiate the conversation.
The dialogue system itself will, of course, be a little trickier. What I think is the best way to handle it in Unreal is to use Data Table Assets. (They’re under Miscellaneous in the add menu.)
First you make a Struct (under Blueprints in the add menu) with the following members:
String Name
String Dialogue
From there, you can make Data Tables using that Struct. When making a Data Table, it will ask for a row structure. Find the struct you made in the list. You can then have it so that each Data Table you make using that struct is a separate conversation. Then when you initiate the conversation, the NPC will have a reference to the appropriate Data Table.
Next, you’ll need to setup a widget to display the conversation. You can keep it simple and just have a text box for the speaker’s name and a multi-line text box for the dialogue currently being said. Then you keep track of which row you’re on in the Data Table and update the widget whenever the player forwards the dialogue. When you run out of rows, call “Remove from Parent” on the widget.
I would suggest making your Row Names numbers (i.e. the first row would be named 0, then 1, etc.), that way you can use an int variable to get the next row.
As for cutscenes: you can absolutely make blueprint calls from cutscenes! You’ll want to add Event Triggers in the sequencer. That will give you a blueprint editor that you can call things from. To automate the cutscene dialogue, I would make a new widget that has a timer variable along with the text boxes. You could create and set the Data Table it uses within the Event Trigger blueprint and let widget cycle through the dialogue automatically on its own. (You might have to make sure the widget has Tick Enabled so it can count down the timer on its own)