On Friday I continued with the pick up quest, but this time with the dialogue! Following
this tutorial series I created a blueprint interface, a dialogue CSV, a dialogue structure, and a dialogue widget, then linked them all together into a maximum of 5 conversations for the 3 different NPCs. Of course, the tutorial explains how to set up the dialogue for the first conversation but not the rest, so I had to improvise that by myself. I did google what the best method to do this was, and
this answer reassured me that the method I was planning to implement would probably be fine, especially for a small scene that I have currently.
 |
Dialogue Data Table |
 |
Dialogue Structure |
 |
Text Box Widget |
After these were created, I made a Parent_NPC blueprint and reassigned it as the parent to all of the NPC characters:
 |
Event Graph: the data table row names are collected and put into an array for later, then the rows were split up by the Dialogue Structure to make sure that the NPC ID of the owner mesh (instance editable) matched the ID from the data table, so that only the child blueprint with the correct ID could say certain lines, which will be added to the MyDialogue array. Upon each event interact, the Line ID number stored in Line Current will be incremented by one and set as the new Line Current (progressing the conversation) and will be used to create the dialogue in the Dialogue Create Function. |
 |
In DialogueCreate, it checks to see if the dialogue widget is still there, if it is, it sets the text as nothing to stop overlapping text. If it's not, it goes on to add it to the viewport and gets a line to display on the widget. |
 |
In DialogueGetLine, for each loop it checks to see which rows of the data table are the same as the current conversation number, line number and NPC number, then adds it to the array of returned lines. If the length of the returned lines is not 1 (aka when the conversation ends because the line number has exceeded the number in the data table, so there aren't any lines added to the array), the widget is removed from the viewport and the line is reset to 0. This then triggers the Dialogue Tree. |
 |
This part gets a bit messier, as it's the conversation tree littered with triggers (booleans) for starting a new conversation specifically for one of the NPCs in response to a conversation ending with another, as well as triggering the pick up events after a specific conversation. It flows down the tree checking to see if any of the NPCs meet the requirements to set a new conversation or trigger the pickup event based on whether or not they have ended their conversation. It also triggers a 'halt conversation' boolean so that the character can't be spoken to while picking up an object. These booleans all communicate with the different blueprint children as well as the pickup item blueprints. |
 |
Within the pickup item blueprints is a timeline that checks to see if the actor has been destroyed, which can trigger a new conversation depending on the index number of the item. It also adds the item to the inventory widget and sets itself as destroyed after being picked up. |
 |
In the third person blueprint event graph, there's a sphere trace for destructible objects only (so that it doesn't get clogged up by other item collisions) that hits and identifies the index number of the pickup item the player is approaching. |
 |
There is also a sequence on E press that checks to see if the conversation is on hold, if not, it gets all actors assigned to the interface created at the beginning and for each loop of pressing E, if overlapping that actor, will trigger the interact event mentioned earlier. It can also check to see if the interact item is valid and if it is also interact-able, it will set it as destroyed and destroy the actor (picking up the item). |
When compiled together, it creates an interactive fetch quest involving 3 NPCs and 2 pickups!
 |
Juicy! |
 |
Saving lives one fish at a time |
No comments:
Post a Comment