top of page
作家相片Sheu Suki

Talking

This is the final result. I made a simple dialogue box and a hint that tells the player press “E” to talk with the NPC.

How to Make a Simple Dialogue System in Unreal Engine 5

First, I need to create the Blueprint Interface to collect the function. Only need to create and name it. (BP_CharacterTalk)

Then, make an interactive function(Press E) in Player's BP. For the “Get Overlapping Actors”, it includes the child of the character BP. Therefore, I made a NPC character BP and all of my NPC Slime are its child. Then, Get Overlapping Actors will collect all the NPC Slime, so I don't not to write the interact to all NPC Slime one by one.

When the Event Talk occurs, the Talk Index will +1 (Need to set the talk index to -1 first, as the first index is 0). When the widget is not valid, it will create the widget. If the widget is valid, just continue to change the dialogue when the Event Talk occurs (Press E). If the Event Talk occurs time bigger than the length of the total talk index (here is 3 times), the widget will be removed. Here is the end of the tutor.

Here is a problem, the dialogue only can play one if I stop here. I hope I can continue to talk with NPC whatever they only tell me same sentences. To avoid the problem, I need to set the Talk Index to -1 after Remove from Parent and set the UI. (The solution found from the comment of the tutor)


Update about the using of Child (13/1/2023)

I learnt the function of “child” is by feeling before, I was wondering why the variables can not be inherited before. Therefore, I made new variables for the above event. Actually, it is very annoying because all my NPC child characters need to make the same variable again. Today, after randomly clicking, I found that the variable can be inherited but it was hidden before. I am happy I found this function TAT.

______________________________________________________________________

Show hint button

Most of the tutor is render text in the 3D game which is ugly. After learning the logic, I can do it by myself.

I created a widget as I want to show hint in 2D. This is written on the NPC Slime BP (have many child, so I not need to write many times). Actually, here is a problem I don't understand. For end overlap, I used remove from parent which didn't work. The Widget still here after the player out of the Sphere(The Sphere shown clearly on the first picture) However, it works to use Remove All Widgets and I get the effect I hope. So, just hold it first.

__________________________________________________________________________

Interact with NPC (NPC action)

As the character will continue to move when I talk to them. Therefore, I make a function that the NPC will stop to move when the player walks near to it. So players can talk to them.

When I play a game, I feel annoyed if the NPC has many things to talk about. For most of the game I played, I couldn't move when I was talking. So, for my setting, players can talk to NPC when they are near the NPC, but we still can walk. If we walk out of the area. The talking will stop. The dialogue will refresh when we talk to them again.

The action also will change when the NPC is moving or stay at original place.

Need to change to Max Walk Speed as their animation change base on the Max Walk Speed. (Before is get current acceleration which is for player's character)



Here is a NPC called Alex who will escape from the player. Alex will not stop when we walk near it. If we try to talk to it, it will say, "Don't get close to me!" As it will run away from us, its trigger area is bigger than others. I think it is quite an interesting interaction.



Comments


bottom of page