Creating a simple dialogue system in Unreal Engine 5
Get link
Facebook
X
Pinterest
Email
Other Apps
Through my early days as a gamedev, I've learned a plethora of neat techniques but there was one that I always wanted to know how to do. A dialogue system. Here is my first attempt at a rudimentary system. This will be redone very soon with more depth.
The very first step was to create a interface for Dialogue. Then a duplicated the Third Person Character blueprint and changed the meshes for both.
I made variables for this NPC, the first being an array variant of the string variable. This was give as many options for dialogue as I wanted. Then I created an index variable as an integer to determine in what order the dialogue was spoken. Then a reference to a widget was made.
For the string array, I added three elements and added three simple sentences.
The Index integer was initialized at -1. This was because the first element of the array began at 0 and the way the code works, we are incrementing the index. Starting it at -1 means we start blank, then move index 0 (the first sentence).
To start, I got the index and incremented it and attached this to a branch node. The condition was that the array needed to be less than the index. This meant that if the branch was false and it was less than the array length, the widget that displays the text is removed. If it is true, we check to see if the UI is valid and if it isn't a widget is created and the text is set this loops and constantly checks if it is valid or not. Basically, we approach the character, try to talk to them and we see if the array length is above -1 and display 0-1-2. Then we go back and run the code again.
And in the player blueprint, the code is simple. I check to see if the player is overlapping with the NPC and see if that NPC has the interface we made and if it does, we execute the talk function.
Creating the UI was simple. First, I created the visuals, which is just a text box with a blur behind it.
And under "Content" this element is bound to an event, which you will see called earlier!
And that's it! It's really rudimentary but works for simple characters in the game world. More can be done here, disabling player input, changing camera location or having the dialogue pop up like small text boxes are all simple changes that can really amplify even this basic system.
For this project, I aim to remake Mario (or at least as best as I can) in UE5. The project makes sense as, while it is simple, there are a lot of core concepts that are valuable for any newbie game dev. Here is the first part of what I've done so far, which is a lot of set up. Stay tuned for Part 2 soon! The first port of call was to get the camera in position to act as a side scroller. Here I set parameters, to allow for customization of where the camera goes in real time. This allowed me to find a sweet spot that looked good for the perspective I wanted. (This ended up looking similar to this) The next step was to set snap layers. This allowed me to set layers for placing assets for the foreground, main play layer and background. This is important because all of the interactable objects would only be in the middle of the play area and without the snap layers, if they were incorrectly placed, the player may not be able to interact with them. (The snap layer sett...
Yes, you read that right. After 2 years of threats (!), I am indeed remaking my first ever project. Addressing the elephant in the room, yes. Dreadhurst Manor is a very edgy title, don't worry, more to come on that front later. The original version was missing a few things, and one of those was a basement area. I simply didn't know how to properly implement one back then, and now I do. So there is a basement, funny how that works! While I always try to make the best level design I can, this time, I am taking time to adhere to level design principles I have picked up over the past 2 years. Basement Layout ----------------------------------------------------------------------------------- 1. The player starts here, the tunnel leading into the basement is a stair case leading down, in the tunnel the basement/manor will be loaded/unloaded. 2. An elevator used for large objects is here, it will connect to the ground floor of the manor. 3. A power station room, a large...
Comments
Post a Comment