 Hello there! In this video we are going to make an NPC that players can interact with, it will pop a label that will display some dialogue to the player so they know more about the word building of our game. And for that we are going to choose an interactive ARR2D, which is a recipe, a recipe is basically a design pattern that I made, that an ARR2D, an interactive ARR2D is basically an area in the game or maybe an object in the game that players can interact with and it will trigger an invade. So they are the bread and butter of most of the adventuring elements that we are going to add in this project. So without further ado, let's get to the video. Before we dive into action, I just want to say that this video is sponsored by my platform essentials cookbook. The cookbook is a 180 plus pages book all about making platform games with got an engine of course, but with a twist. Instead of going through step by step instructions that most of them you can figure out yourself, I want to present you 12 recipes. As I said, the recipes are basically design patterns that we can find in this specific case on platforming games. So they are made to solve some common problems and skyrocket the production time of your platform games. So you don't have to start from zero. You already have some problems solved. So you can basically just focus on the content creation of your game. Currently, the ebook is a three pledge tiers product. So if you want the PDF files, which is the ebook itself, you can pay 799 and you get access to one of the highest quality content out there guys. So the ebook packs what is each recipe, where you can find them on modern platforming games, how to achieve them. So this is the more tutorial part of the book. And why do they work? So what's the design behind them? What is the engineering behind them? So all of this packed on each chapter of the ebook guys, this, this is amazing. If you just want to accelerate the production time of your platform games, so you can level up the speed of your production, and you can implement stuff by yourself, you can pay five as a break. So for 1299, you can get access to the assets pack, which is what we are going to use in this very video to achieve our goal. And if you want to see things in context, so how I can use this recipe, how I can implement that, how, how do this, how does this recipe actually behave in an actual game, you can pay two extra bucks. So for 1499, you get access to the very source code of the game that we are making in this series. Guys, I hope you enjoyed it. Thank you so much for your spot. Go there, the link will be in the description so you can go straight to itch.io and get your copy of the ebook. Click there, buy the book. And without further ado, let's get to the video. So this is what we got currently. We have this big sound, which is basically a piece of the revolution. And we have a label that it should pop. Let's see. Yeah, this is the dialogues that it should have. This is another recipe that I have on my first ebook, the top seven good recipes. This is called the event player. It's basically how you can use the animation player to display a sequence of events on your game. This is a very cool recipe as well. But here we are basically changing the text so we have stored the dialogue text in sequence, right? And here we have the dialogue panel, which it will pop and display the text that is saved on the event player there. I used to be a pig sound without dreams and desires. And well, this is all here, but the player can interact with this NPC. So how sad is that, guys? The NPC can talk to the player. The player will never understand what's happening behind the gameplay story. So they don't understand the whole building of this game. We need to make it so that the player can interact with this with this NPC so they can understand the story building of our game, right? So for that, we are going to import the interactive R2D. Let's clean this up and find it. What is it interactive R2D? So let's import this to our project. Okay, the recipe itself is basically an R2D with some instructions to warn about the interactions that the player will be able to do with this area. As you can see, it requests an interactive input action, which is called, in this case, interact, but you can use whatever input action that you want. So for that, I will go to the project, project settings, input map and create the interact action. And let's say that it will be the F key, in this case, close. And let's instantiate one of these as the pixen child, as pixen child. Instance, instantiate. And let's add a collision shape. R2D. It will be a rectangle shape. What is it? Rectangle shape here. So I want to, I like to color code this shape so I know which system they refer to for interactive R2Ds. I like the purple color. So now that we have the interactive R2D setup, we can use its signals to trigger some events on the pixen. Here we have some methods. So show exclamation balloon, hide exclamation balloon and run the dialogue. And we are going to call each one of those using a signal from the interactive R2D. So connect this, connect this to the pixen on interactive R2D interacted. We are going to run the dialogue. So once the players press the interaction button, it will run the dialogue. But once the players are close to this area, so once the interaction is available, I want it to actually just pop the balloon. So show the exclamation balloon. Show exclamation balloon. And if the player is not on the area that they can interact with, if the interaction is unavailable, I want to un-pop to hide the balloon, the exclamation balloon. So let's hide it. Hide exclamation balloon. Okay. And believe it or not, probably this is all that it takes to make this happen. So let's play this scene. If I get close to the pixen, yeah, we have the balloon popped. I will press the F key and we have the dialogue running. I will press F again so we have the next dialogue. I used to be just pixen without dreams and desires, but this was before the revolution. And if we press again, it should hide or not. Yeah. So probably this is something here. So yeah, the problem is probably here. We should take rid of this and we should un-pop the label itself. So we can copy and paste this here, but instead play it backwards. So it will hide the label. And we should probably take rid of this as well, because this is not making anything useful. We can manually wrap this value. So dialogue index is equal to zero. And we are going to wait for the animation to finish duplicating this line and wait here and return from the function. Because when we enter in this test, when this is true, we will reach the end of the dialogue. So there's no reason to play all of these lines, to compute these lines as well, to process these lines here. So if we test this, I will interact with this pixen. I used to be just a pixen without dreams and desires, but this was before the revolution and it will hide the label. So we can interact with it again. So if we move away, it should hide as well. Yeah, perfect. And if we move close, yeah, there we have it. As I say, the interactive R2D is the core, the bread and butter of all of the adventure elements that we are going to add, moving forward in this project. So for instance, here I have a crate that once the player breaks, it will install a diamond. Let's open the diamond here. The diamond is basically an object that players can get close and pick it up. But first they will display, the diamond will display a dialogue saying that the players should take it with them, because they are an important precious object to take in the journey. And I did the exact same thing, the exact same process here. I used it some signals from the interactive R2D and it will display this dialogue and once the player interact with it again, it will pick it up. So here I am using the spawn R2D, which is another recipe from my first ebook. This is very versatile as well. It basically creates objects in the game world itself. So it adds objects with position rotation and scale as well. Let's test this level now. So I'll break this crate. A diamond will spawn. I can interact with the diamond. It looks precious. Gonna take that one with me and we interact with it again. And we added the diamond to the players inventory. So the interactive R2D is so versatile that this is the base of all of the recipes that we are going to use moving forward in this series. So for instance, the portal 2D is an interactive R2D that once the players interact, it will teleport the player to another area or even another level in the game. This is what we are going to use to make doors teleport the player to another level, to another scene in our game. The checkpoint 2D is but an interactive R2D that once the players interact with it, it saves the player progress in the level. So once the player dies, they will be teleported back to the last checkpoint that they interacted with. And the switch 2D is but an interactive R2D that players interact with and it will change the state of another object. So let's say if the player pulls up a lever, a lifter will lift the player to the top of the level, for instance. So the interactive R2D is really a pattern very valuable to learn. So in the next video, we are going to create a portal 2D, some portal 2Ds, so that the player can move back and forward in the game world itself. So see you there, thank you so much for watching, keep developing and we'll see you the next time.