Understanding UE5 Blueprint Interface Basics

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey everyone in this video I'm going to be going over what a blueprint interface is how to use it in Blueprints and then just kind of give you a nice basic understanding of what you can do with it so um I recently just had somebody pop in a question within the Discord asking about it and I did like a nice little short video but then I figured hey may as well just do um a real video on YouTube so that everybody else can use it and learn from it and yeah let's get into it so going into this I just want to show us how we can communicate so I did make this little orb already it's a super simple orb um there's really nothing to it it's a mesh and a collision sphere there's nothing going on um if you really want to know how I did it in case you don't know uh just go to blueprint hit on actor and then under components add in a mesh and then also add in a collision sphere and from oop I didn't mean to add a plane and from there that's how you would make it I also one thing that I want to do is I am going to create a variable we're going to call this the name and we're going to make this a string and what this is going to be it's going to be our orb's name so we're going to call this the time orb I guess I forgot to delete that while I was looking at it but and what we want to do with the play player is we're going to be using a blueprint interface to communicate with the orb to say hey give me your name and something else that we could do is that for this orb let's make it instance editable so that when it's on the map we go to details and then under name we have time orb and then we can also duplicate this and we'll name this let's say um uh I don't know purple and from there and what we want to do is that we want to communicate with these orbs using a blueprint interface so let's create our interface under blueprints interface we're going to do bi for blueprint interface and do let's just communicate name it whatever you like so essentially what a blueprint interface is is it kind of acts like a messaging service so for example if you were I don't know let's say you were texting another person and you wanted to know when they wanted to go out next Friday then they would just text you back saying hey let's go at 6:00 p.m. whatever it may be this is going to be something similar you're going to be messaging another blueprint telling them hey I need this information and then you can get it back or you can just tell another blueprint hey um I have these variables you can use them now whatever it may be so there's different ways that you can use it but I like to phrase it as it's a messaging service because that's just like a very simple way that most people understand how texting works whatever it is calling whatever you want so with this we want to do is we want to get the orbs name so this function we're going to use is going to be get name and I'm going to show you two different ways that we can get name uh so there's going to be two functions we're going to want to do uh I'm going to do the first one which is going to be we're going to communicate to the orb saying Hey I want your name and then we're just going to get the name afterwards so for this let's go for to our character we're going to also open up this so this is just a free model that is on Epic that I just snagged up and I use it for everything now okay so now we go to class settings we want to implement the interface type in whatever it is it's bi communicate for me and then we're going to go back to our orb and then we're going to add the interface now the key thing to remember is this interface is only going to work with those that have the interface if it doesn't have an interface it's going to completely ignore them whenever you try to do a message so for example if you did get controller and from here you did get name this would not work because uh our controller doesn't actually have the interface so therefore this is is going to fail and one thing to note that when you are calling any functions from an interface when you want to message to the other blueprint it ends up giving you um this message and it has an envelope at the top right corner so if I was to delete this go back over here and do get name you'll also notice the word message this tells you that you are going to communicate with whatever blueprint you're currently dragging off another thing to note is that let me get game or let me get any type of let's begin play and let's say you dragged off here and typed get name one thing you'll notice is that you don't see the message here so if we type there you'll notice that their target is south and what that would do is it's going to call this function so if I double click over on interface on the right side I'll go into that in a second it's going to call this event so you could technically call the interface event on your own blueprint it's absolutely possible but also just keep in mind that when you want to call like for player controller and you'll notice how you can't connect that because it's not the same thing so just remember you have to pull off on whatever blueprint you're wanting to communicate with do message um obviously if you just type in the word message you'll notice that they have all these messages and nothing works here so got to remember the name of the function which is get name also try to also make sure that your names for These Blueprints kind of make sense and they don't overlap with the same thing because for example if we made another function and said get display name and we went back over to our orb with our player controller and said get display name you also notice we have all these other display names now we have the blueprint interface which is at the top so we know it's right there but if you start naming everything exactly the same you're going to eventually confuse yourself it's pretty easy to kind of tell the difference because it will show you what interface is as well as um the event you also see this nice little symbol right here uh which is referring to the blueprint interface and then you can also click to add this item to your favorites in case you never knew uh so yeah just keep in mind with that I also just try not to repeat names because that'll get confusing over time all right so let me delete that delete that so going back to our original idea we want to communicate with the player hey this is our name so we want the orb to give the player and name so this is why I added a sphere for this sphere I'm going to add a was it actor overlap uh actor begin overlap and from here what we'll drag off is you can do different things so we there's such a thing of does implement interface and this will check if the character has the interface so we could do um bi communicate and from here we could do something like branch and then we could just do like print string hello or let's not hello let's put our name don't worry I'll show you other ways to use it but let's go into here and when we walk up it prints time orb and then this one prints purple so we're printing the name now of course we're not really utilizing the communication that we can use but this is also something that is useful for let's say if you have uh combat enemies if you want to damage something you can do does implement interface and then if you they do have the interface apply damage uh which is the built-in function that um Unreal Engine has so you could do like apply damage to whatever this actor is and then proceed to go about doing that that's also something that's very helpful of course we want to actually utilize the messaging service so what we want to do is instead let's do the messaging service to the player and let's do it's get name and message but you also notice right now now our get name doesn't have anything and just like every other function you can add inputs and you can also add outputs now I'm not going to do the output right now I'll get into that after but for the input if we hit here what we want to do is we want to get orb name and then we'll add in a string and this will allow us to pass along the string so now if we were to hit compile if you didn't see it yet now we'll see orb name is available we'll plug in this so let me show you something let's go into the game and we'll go in here all right so unreal crashed on me but just to show you if I walked up to this orb we'll notice that nothing happens so we ended up did doing the message saying hey here's our name but nothing happened and to kind of show you the whole thing is that hey we told this actor hey we want to get the name but we ended up not telling the player what to do once we get that information and that's what's key to make sure that you set up both sides of communication so the orb can say here I'm giving you the variable but the player right now is not doing anything so on the left side you'll be able to populate whether they're going to pop up on the event graph or they're going to be a function and to kind of tell the difference between what is going to appear as um an event on the event graph and what's going to be a function depends on whether you have an output so with this new function let's just name it test and let's give it an output and the moment you do that you'll notice that this output is a return node so once I compile we'll notice that hey I have a green one and then now I have a gray and if you hover on top of it it tells you whether it's a function or it's an event so if I double click on this scroll back in we have the event and then under test it'll take take me over here so that's really how you can differentiate between whether it is going to be a function or an event so I'm going to delete that we don't need that we're going to go back to here and what this is is that when we tell the player here's our name the player needs to do something with it so for us we're just going to print it we're not doing anything fancy in this uh tutorial so we'll go through here and we'll plug that in and now when we overlap when we look at the top left we have time orb and we have purple so now we're communicating so that's how you can utilize a blueprint interface whether it is on a another blueprint and you're wanting to communicate with another one now I'll show you the second direction that we could do this and this is what's going to be um what I'm going to use as a function so we're going to do um we'll just do get orb amount and what we want is let's say we want to get how however many orbs the orb contains I don't know if that makes sense anyways the orb is going to have an integer on it and we're going to pass that along so we're just going to be amount and integer and now if we were to either compile if you don't see it yet but you should be able to and then hit this and what this is is for the player you're not really going to get an orb amount because you don't actually know what it is but what we could do is that let's go with um we're just going to use actor overlap again can overlap and let's say when we overlap let's send a message um get orb amount and then from here we'll be able to get an output and then we'll be able to print oh sorry print and we can plug that in another thing you could do is that when you overlap you can actually promote this to a variable so if you wanted to take this amount and store it you would be able to I'm using the print strings a lot just because it's really easy to demonstrate what I'm doing however uh you can use this for many things so if you wanted to get a variable from something else or maybe you wanted something to um do an entire function and then tell you afterwards um if it worked such as like maybe you have an inventory system and you want to communicate with the container saying hey um I have all these items I want to drop it into the Container do all of them drop and then you could return like a boene saying true or false anyways that's like something you could do not saying that's necessarily the route you should take with inventory system but hopefully that gives you an image in mind uh but for here what we'll do is with this actor we're going to call this to get the orbit Mount and then we're going to print the orbit Mount but of course what we need to do is on the orb we need to set that up and as of right now we need to be able to pass along the amount so let's create another variable and let's just call this amount put it in integer or that's the wrong integer plug that in let's also make this instance editable just so that we can demonstrate that it's working for the two different ones go into details I'm going to put seven and I'm going put 20 or 34 and actually for here what I'm going to do instead of print print we're going to do a pen and total amount and what I'm going to do is we're going to grab the set amount we're going to get the current amount add and we're going to plug that in that way we can show you that it's working we're communicating with the two and we are increasing the value of our amount so let's go into here we walk up we have the total amount of seven now we have the total amount of 41 and just like that we're communicating back and forth obviously it's just going to keep going endlessly and you may want to do other type of checks when you're doing such a thing just because you can just communicate with begin overlap doesn't mean you should probably leave it like that you should do other things um maybe like branches to make sure it does have the interface whatever you want to do um don't check every character for everything uh it's not really necessary but nonetheless that is how blueprint interfaces work this is how you can use it for events this is how you can use it for functions you can pass along information by calling it in one blueprint and then just getting the amount back you can also have another blueprint tell another blueprint to do something hope that's really helpful to you I tried to give you as much information as I can and keep it as simple as possibly could all right so uh if you enjoyed that feel free to hit the like subscribe join the Discord all the self promo stuff it's great having you talk soon
Info
Channel: MrButier
Views: 563
Rating: undefined out of 5
Keywords: blueprint, blueprint interface, ue5, tutorial, basics, bi basics, unreal engine 5, blueprints, power bi tutorial for beginners, blueprint tutorial, interfaces, interface
Id: MPmJ5v6-eps
Channel Id: undefined
Length: 17min 52sec (1072 seconds)
Published: Wed Mar 20 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.