Showing posts with label Pickups. Show all posts
Showing posts with label Pickups. Show all posts

Friday, May 1, 2020

FMP: Week 17 Friday

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

Thursday, April 30, 2020

FMP: Week 17 Thursday

On Thursday I started on the thing I was the most excited about adding: the fetch quest! To start with, I needed to create the pickups: a berry and a fish. I went into photoshop and I repurposed my fish texture, then painted a lingonberry for the UI. I then followed this tutorial in making the widget for them as well as a blueprint. Following this tutorial however, I came across a hitch: I didn't want to click on the actors, I wanted to press a key on the keyboard (E). To solve this, I decided to add this tutorial to the mix.

My incredibly empty looking inventory widget
The inventory widget graph that adds a texture into the box. I edited it from the original tutorial so that it wipes the previous one first though, as I wanted the player to exchange the berry for the fish, not have them both at the same time.
The item widget! Once again looking very empty
In the event graph though, the texture can be set using an index and an array of textures, so the icon shown in the UI will depend on the item being picked up.
Actor blueprint: On play, the text widget is hidden as the player cannot interact with the item immediately. When it is visible though, it will rotate towards the camera at all angles so that it can always be read. It also has a world offset so no matter what rotation the mesh is at, the text will always float a certain distance above it.
Here it gets a bit complicated, and starts to mix in with the work I did the day after. On overlap, it checks whether or not the player has already destroyed one of the items (identified by index), if so, it moves onto the next one and if not it checks to see if it can be interacted with yet. From there, it sets another boolean of interactivity and sets the visibility of the widget to on. If all of this isn't the case, the visibility of the widget and the interactivity will be set to off, which is the same for end overlap.
Widget and collision added to mesh
'Press E To Interact' widget to be displayed above the mesh