Need to Know Nodes in Unreal 5 Blueprints

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello my name is Cason Quisenberry and today I'm going to be going over the need to know nodes in unreal 5's blueprint system so unreal 5 has a blueprint based system which instead of being a traditional coding language where you type code such as C plus plus or JavaScript or python it is a node-based system that basically has the has nodes like this that connect to other nodes and what these do is basically run code so it's a visual scripting language meaning you just like can visually put your code together without having to type and so there are hundreds of nodes within Unreal Engine 5. so obviously I'm not going to be going over all of them but I am going to be covering the most important ones and to do this I'm going to basically be using two things I'm going to be using a character which is the default third person character in unreal and just going to be using a default actor where I place a static mesh of the cube um you have to follow along for this tutorial you can if you want but this is mainly a video where you can just sit back and learn the basics of unreal 5 as I go over there all right let's get into some notes so for this portion of the video I'm going to be in the actor just because it's completely blank there's no code in it unlike the third person character so this will be a little cleaner for us to work in and so to pull up the nodes what we're going to do is we're going to right click which is going to give us all these different categories of nodes now as you can see there's a bunch a bunch of categories and if we go in there there's a bunch a bunch of nodes as I said there's like hundreds of nodes in unreal5 so hypothetically you know if you know what you're looking for you could just go to these categories and do the drop down menus and just click it and then boom it'll appear in your blueprint however that's not very efficient so it's much easier just to use the search bar menu so we're going to search up the first and then we're going to learn about which is called event beginplay so here we have it so this is what's called an event node all event nodes are coded red and they have this little square right here so this is how you know if it's an event node and basically what an event node is is this the beginning of the line of code that you're going to run so at the beginning of every single different line of code you're going to have some sort of event there that is going to have some sort of condition that if the condition is met it is going to run that code you can also call events but we'll get more into that later so this event began place so the condition to meet this event is basically just to start the game so if I were to press play here it's going to run the code as soon as the game starts so here we have this and to show it off we're going to do a very simple node called print string for those that don't have any coding background a string string is basically just you know text so when we do this it should print the word hello right here is what's called compile so this is basically just going to take a look at your code and see if there's any errors that it recognizes and then just tell you and then it'll have an output log they'll say hey there's an error here please fix it um so if we get this little check mark here we're all good to go and then this is just the save button make sure you save blueprints uh frequently I like to compile and save every time before I try running code just to make sure everything's good so we go here we press play game starts and boom immediately this shows up immediately immediately because as soon as the game starts it's going to be doing this event all right so now I'm going to break this link so just to show some of some of the different things you can do so as you can see if you drag off the arrow it'll give you this line and if you go here boom this is how you connect them so these codes are connected however let's say that our thing is here and it's just not organized and we want it to be straight we can right click this go to straight straighten connection and then it's going to straighten the connection so it looks a little cleaner um you can also do what's called break this link which is going to make it toward the code no longer goes together um the last or the important thing to do is say you have like a really really long a line of code in your nodes way over here you can go what's called jump to connection it's just going to jump to the next node which can like save you some time um so the next thing we're going to do is what's called event tick so event tick basically means that it's going to do whatever you have there every single frame so every single frame that the game runs it's going to do this event so if we go and press play we can see it's doing this for every single frame of the game it's printing the string hello um so this is a very powerful tool because if you need something to be continually running in your game there's the event tick however it's very expensive on the system meaning it requires you know a lot because it's doing every single frame you know this can lead to things like lag and it can slow down your game if you're doing something super super extensive but it is a really powerful tool for certain things okay so now let's go over some different variable types in unreal I just hit this plus button on the variable it's going to give you the variable immediately you can name it so we're just going to call this one test if we do this drop down menu as you can see there's a bunch of different integers or a bunch of different variable types there's also a bunch more down here but I'm just going to show you the main one so the main one is going to be Boolean which basically means is this true or false it is a conditional variable that has one of two values it is either true or false it's in binary terms it's either 0 or 1. all right test um two next we're going to have integer so if you remember from math class and integer just means that is a whole number it is one two three it can be also zero it can be a negative number like negative one but it can't be something with a decimal like 1.5 however our next type which is a float can be so float is just going to have a it's basically just going to be a decimal so it can be 5.22 or 6.37 it can also just be 5.0 our next type is going to be called a vector so a vector is just going to basically be have information about the axis so if we go here to our detail panels of this object this right here is a vector so the information it has on the X Y and Z value this is a vector so this can be used for storing locations of different actors but it can also be used for moving actors in a certain direction and the next one we have is a rotator a rotator is just basically going to store how an object is rotated and you can use that for changing rotations and stuff like that and then the last one we're going to go over is called a transform so a transform is so as I said a vector is this but a transform is location rotation and scale so all three of these make up a transform so that means there's a lot of information as you see it even says transform right here these nodes we can drag them out once you drag them out it's going to ask you basically which one you want to do we can do git so we can do this or we can do set so this is basically just going to be a reference to your variable whatever information is stored in your variable is just basically going to have this set is going to be changing what is stored in your variable um so as you can hear see for the Boolean you know if we click this this means that this condition is met this means that it's true if we click it again it's false so this condition is not met if it's something like a vector it's going to give us you know the the X Y and Z is going to give us these informations and we can plug in our numbers and then just to show you print string a little bit better and you know just how this works Let's uh set up a little thing here so let's go to our float so we're going to get float this is a ribbon star float we plug it in here and it's basically going to create this which is basically just a connection between a float and a string so it's going to take this float and convert it into a click here as you can see we can get we have a lot of different data let's compile safe I'm going to skip most of these but we do have the default value so let's set the default value to 222.22 right and so we go here and it's going to print that value right here for us so print strings can be useful just because it can give you numbers uh say numbers are changing and you want to see what the values is you can just plug this in you can also use it if you're not sure a certain section of code is running you can put it in that section of code and just see if it goes off so you can also just like type whatever you want in here so you know if you want to change it to say we want to see if a code is true you can just put true here we also change the color of the text we can also change how long it stays on the screen that's not a number okay there we go all right so I'm gonna I still have this little thing here to show you another function of unreal so here I have the default value at 100 here I have the default value at 10. also so the default value is just basically going to be what the value of the variable is unless we change it so right now it's always going to be 10 it's always going to be 100 but say if we need to change it for something later down the line we can just pull it in put set and then set it to you know a completely different number but the default variable or the default value just is what it's going to be unless you change it so I'm going to take my 100 here and I'm going to take my 10 here and we can do basically any math that we want in the world so if you do a plus sign it's going to pull up add if you do a subtract sign it's going to pull up subtract if you do a slash you're going to pull up divide and there's a bunch of other different math functions there as well so let's just do divide real quick so as you can see here we have a hundred and then we go here and then we go here and it's basically just going to run this math equation for us right here boom 10. so 100 divided by 10 is obviously 10 plus you know multiplication oh uh multiply is going to be if you hold shift and hit 8 it's going to be this little star thing and it's going to give you multiply you can do basically any math equation that you want unreal okay so next we're going to go over what is arguably the most important node in unreal which is going to be our Branch node so unlike all of our other nodes that we've been over we've gone over so far as you can see here there are two different outputs so it's either true or false and so basically what this means is as you can see there's a condition right here so if this condition is true we're going to run this line of code if the condition is false we're going to run this line of code so if you have any sort of programming background this is basically the equivalent to our if statement you know as I said if true do this if false do this so here I have two bulls one I said the default value to always be true and the other I set the default value to always be false so with Bulls most of the time 99 of the time you're going to have them their default value to be false and so if we go here and we connect it here and we're going to connect this here just to these print strings to stay true or false and we go here this condition is going to be true so it should run this line of code so we go here and then it it printed that string and then let's go here and then it since it's not true it's going to run false right so this is obviously very powerful so if certain conditions are met you can have it to where certain things happen if they're not met you can have it to where other things happen so hypothetically what happens if we just have like a blank thing so I say hypothetically if something is not true we want nothing to happen you just leave this node blank and it's simply just going to not do anything so as you can see nothing happened which is perfectly uh normal to do and you're going to be doing this a lot all right so I have all these variables with ins and floats of various values and so if we drag this in here and then we hit equal equal it's going to give us what's called an equal node so as you can see here it is basically going to be comparing two numbers to see if they are in fact the same so it one's value is 10 and two's value is also 10 so we're going to drag that in and so if we do this and then we connect it right here we get true and so let's do the same thing with another end this one is a value of 5. we get the false okay and then we have other nodes such as um you know less than and less than equal and greater than and greater than equal I'm just going to show you you know less than so if 10 is less than 5 it'll run this code and see tell us if it's true or false and it is of course false so again there's greater than there's greater than equal there's a bunch of stuff like that you can use if you need to compare two numbers to see if code goes through so some more bold tools if we go here and we do not Bool this is going to give us what's called a not Boolean so we're going to plug that in here and basically what this is going to do is it's going to take this value say okay take this value and say we want not that so this value currently is true so it says we want not this value so if we want this value to be false for L to run this code so if we run this code even though this Boolean is true it's going to be false right false then have some others so the next big one is the and Boolean so this basically just means that if both of these booleans are true then we're going to run the code so for the sake of this I'm going to change the default value of this to true real quick so we go here boom both of those are true so it's true but let's say one of them was false is going to run false even though one of them is still true so basically both of these have to be true in order to run this code there's also a very similar one which is or which basically means if one of these are true then is going to run this code so since one of them is true it runs the code if both of them were false it would be false and so you can you know obviously you can get a lot of things from this a lot of information to see if certain variables are true or false and so those are going to be all the bull tools that we're going to go over um we are now going to go over what's called a do once foreign so this is just frankly going to run the code once which is a very very self-explanatory we're going to go to our event tick we're going to plug it in right here and then we're going to do a print string so event event tickets supposed to run every single frame but if we do this do once it's just going to do it once but let's say that we want something something to happen once but then after a certain amount of time I wanted to be able to do it again we can use what is called a delay node so delay node is simply just going to be an amount of time so this is duration um and it's just basically going to do nothing for the amount of time that is in the delay so we're going to change this to say let's to say two seconds and so for two whole seconds nothing is going to be running in this line of code other things can run in other lines of code but nothing in this line is going to run for those two seconds so if we take this and we put it into this with restart um we can basically make a tour after these two seconds to restart so as you can see this is kind of messy it's kind of hard to see you know what's going on so a cool trick is if you double click you will get what's called a reroute node which is basically just going to be a little node that connects here and it's going to help you clean up your blueprint so we're going to put in two and so as you can see a lot better organized we can see where the nodes flow and it's a lot easier so let's run that code so I'm going to hit this one two it goes again here it's a little hard to see because the duration of this is only two seconds so let's change this to five seconds then we go here and then one two one two one two is going to keep doing that so the it's not obviously not keeping up right now but every two seconds it's going to be doing that and same thing if we put it over here which let's break that so say we want to wait something at the beginning or during like a certain event we go there and then here so when we hit play one two and then bang right there so this is just you know delays are also very very important but sewer do once is it just like helps to control the structure and flow of your code so another thing that's going to help with the structure and flow of our code is what's called a sequence node so we go to this sequence here we go here so as you can see it has multiple nodes just like the Branch however this is called then zero then one and as you can see here we have this thing we're called add pin so we can do this so basically what's going to do is going to run this line of code it is then going to after this line of code finishes run this line of code after then it's going to write this line of code so you know let's just get a couple print strings in there real quick okay so we have our print strings in here and then again for people that don't have a coding background um numbers encoding and I think if not all language is 95 of languages it starts at zero so here have 0 1 2 and that's how everything every single set of numbers is going to start with zero we don't start at one encoding we start at zero so if we are simply to go in here and press play you can see it goes zero one two it's it's it looks like it went two one zero but it the the print strings go up that's also a very important thing to note as well the next thing we're going to go over is another type of event called a custom event so if we left click we go custom event we can add a custom event into our code Emily wants you to rename it because this is basically an event that you are making uh so we're going to call it test let's do uh to show off everything we've learned so far let's do a branch and then we're going to do this so if it is true which this is always going to be true we're going to print the string that says custom event so we connect that right so this line of code is right there and it's going to be connected to this event but as you can see if we play right now nothing happens because this event is not being called but if we go up here and we go over here we actually type in the word test and it's going to pull up in this call function right here so this is just going to run this line of code right here so boom custom event uh so these are where you're going to make a lot of different parts of your code is you're going to have just custom events and you're going to run these events um when they come up next thing we're going to go over is a very simple um node which we're going to keep it in the custom event we're going to go called destroy actor um so this is probably the most explanatory so if we go here you can see the actor is right there that's our actor that we've been using if we go here we press play it's gone because it immediately deleted itself so let's just get a little delay on that so it's a little easier to see what's happening here we go here you press play one boom uh very self-explanatory this can be used you know to get rid of actors if you no longer need them this can help make it look like someone has picked up something um it's just a very uh useful to Tool all right so for the next uh events the next line because we're gonna get over we're going to actually go to the components in the viewport and we're going to add a component so if we go here we click add we're going to add all we can add all these different components to our actor they all have their various different um effects so we're going to add what's called a Vox Collision now there's also sphere collisions there's a bunch of different shapes of collision but a box Collision is usually the most common and as you can see this is what it looks like it's just like a box this is basically a trigger box if we go here let's scale it up and move it and then we're going to move this up so we go here if we left click this as you can see it has add events it has a bunch of different events that we can add but we're just going to go over um two of the simple ones so we're going to go over begin overlap and we're going to go over and overlap right so as you can see these are two events so basically when something goes into the box when we overlap with the box it's going to run this code and if something is no longer overlapping with the Box we're going to get this code uh there's a bunch of different nodes here like a bunch of different uh resources here it looks a little complicated but we're just going to break it down as simply as possible so let's say that once we enter this object this actor as our character um we are going to want to then run code what we're going to do is we're going to immediately go into a branch here we're then going to get this other actor we are going to do actor has tag now what a tag is is it's basically just a very very simple um label that you can put onto an actor that just says this is what this actor is or this is a connection to an actor this is what category actor it is which is very powerful tool so let's go to our third person character let's go to class defaults which there are a bunch of bunch of settings in here but we're just going to say focus and put it in tat tags as you can see if we go down here it says tags and it has array element so if we put plus and we hit player this now has the tag of player so if we put in exactly we just put was player we're now going to say if anything has the tag player we're going to run this code and so all we're going to do is do a print string so this is the condition that goes into our branch and then if it's true we're going to print a string right here it just says overlapped and so let's do the same thing we do the exact same thing down here connect it to the other other actor okay and also these green if so this green thing is what's called a pure function so up here most nodes are going to be what are just called functions it's just basically going to be a thing that runs code a pure function is something that runs code uh but doesn't have to be connected to the node Branch because it is just going to be doing a very very usually simplistic action um so it's just going to be checking is this is there a tag in here and then it's going to go straight in here so this was called a pure function this is a regular function so if we do here and press play as you can see nothing's happened but if we as a character walk into this it's going to go overlapped and if we leave not overlapped overlapped not overlapped so this can be very important to make events and make trigger boxes for certain things so say you want a character to walk to an area and once they get into that area enemies spawn or something like that you would do it like this you would just put your spawning code right here okay so it looks like as you can see you know we're starting to have a lot more nodes in our project and it can get very very um confusing very quickly uh if you go to our third person character this is just basically just walking and jumping and as you can see there's already like four different sections of code so what we're going to want to do is we're going to want to comment our code so if you highlight everything you want to comment and then just press the C button just like the c key going to pull up a comment box now in this what we want to do is we want to type whatever is going on uh here so I'm just going to put um box Collision um interactions right there and then again we want to be super super specific with our comments so that other programmers uh will remember like can just easily read and be like okay this is what it is but comments also help you because if you're working on a project for a long time and you haven't touched a certain section of code but then you realize oh I need to actually you know uh mess with this you can easily just open a blueprint look for the comments and then see um so there's a couple other things over here you can you know change the color so you can color coordinate your comments if you want you can also change how big the label is but I recommend just keeping 18. you can also make it toward this little bubble appears um right here so it's a little easier to see I personally don't like bubbles so I just leave that here um it'll also move your um things as a group so this is easy to move around and interact with as well but you can also have comments within comments to say that I want to get even more specific I can highlight this hit C and then just do um end overlap and then I have this comment inside a comment which can help me and then you can make your comments smaller you can make them bigger um there's this little thing that can help you go directionally and so there's just comments that are going to be very very important for organization purposes okay now let's move our actors so we're going to basically create code that's going to move our actor in the world so we're going to do it within this custom event and then run it up here and the event begin play so the first thing first note that we need is called get actor location so this is just going to get the location of the actor in the world so it's basically just going to be accessing this information right here we can then do a node that's just called set actor location which is just basically going to set these numbers right here so we go here um let's do something like a plus so we just hit Plus and as you can see here we can add we can you know just add and put in individual numbers or what we can also do is if we right click we can go to convert pen and we can change this to say a float so we can change all of them by the same number I'm going to go 1000. actually let's go 500. so again the default uh unit and unreal is centimeters so this is going to move it 500 centimeters so we press play and it's immediately going to be over there so so just so you see what actually happens we're going to put in a delay now we got the delay we're going to do it and then as you can see boom it basically just is going to teleport okay now we can do a very similar thing but instead of a set active location we can do set actor rotation and again you can also just type within here you don't actually need to get that so for this I'm just going to type you know 90 let's go 50 and let's go like five and so then we're going to go here press play it rotates we can also do set actor transform which is again a transform is just location rotation and scale so as you can see here once it's transform but what we can also do in a lot of nodes like this uh this is actually especially location rotation transform as if we hit a right click we'll get this what's called split struct pin which is basically going to split the pin in the different parts we can then recombine it if we want so let's split this let's say that we want it to be something like I don't know let's plug this in actually let's plug this in let's say that we want this to be 90 um fit five and let's go 27. and then for the scale let's say we want it to be three three three then press play boom and you can also do the same thing with set actor scale uh 3D I'm not going to show up but you can do basically the same thing with that now let's say that you don't want it to just immediately teleport you actually want it to make it look like it's moving to that object we can do what is called a timeline so we're going to add a timeline and you have to name the timeline so we're just going to go test line and then this looks like a very very complicated note I show you it's not there's Play and play from start so basically play is just going to play the animation so this is basically used to animate I'm putting animate in quotation marks because it's very simplistic um your actor and play just going to play any part of that animation and play from start is going to specifically play from the start so most times you're just going to want to hit play from stop uh play from start there's also stop there's also play it from reverse and then reverse specifically from the end and there's stuff like that but let's double click into this and it's going to open this so this is going to have access to whatever called track so if we hit this plus track we're going to add a float track that's we're going to use 95 of the time these other ones are useful for certain things but we're going to add a flow track and then we have our flow track we're going to add keyframe and we're going to add this keyframe and you have time when we have value so we're going to put time to zero we're then going to put this uh value to zero as well this is going to be the link to the flow track so this is basically going to be how long the animation takes so we're just going to set this to two seconds we don't want a long animation so we're going to left click again and then we're just going to set this to the time of 2 and the value 2 1. so that basically that zero the value of 0 means okay we've just started the value of 1 means we're done and then if we hit these buttons it's going to show us all of our keyframes okay so we have that next thing we're going to do is we're going to do a lerp and as you can see there's you can do this for rotator transform and Vector you I don't believe you can do it for scale maybe you can I personally never have but we're going to get this vector and you're just going to get whatever you're going to normally use so vector so this is basically just once a start and a end right so for our start we're just going to put in this get actor location for the end we're going to get this number right here right there and it's going to give us a return value so it's basically alert basically means we're going to slowly go from this value to this value slowly adding in between and this Alpha is basically just going to be how long it takes so it's going to take uh two seconds um and so then we're going to go at our set actor location and we're going to plug this new location in we are then also going to put an update so update means it's going to be continually doing it sort of like event tick but it's not going to be doing it every frame and finish just means it's going to update it on when the timeline finishes so most of the time we're just going to want to do update all right so now we got that let's go test it so we press play as you can see it's going to slowly move from point A to point B okay now let's go into our character so the first thing that's interesting about our character is that we actually have access to inputs so we have access to like every single key and every single Mouse button so we're going to do here and if we say want to do something with the q key we do q and then you know if you do key it will help and then boom what's called keyboard events we hit Q right here um so let's you know just do a classic print string to show you this can we go here and then let me turn this on um so if I press if I press play here see nothing happens oh that is from our actor so uh just to make sense of that but if I press Q hello every time I press Q it's going to happen right and we can do this for literally every single input that our computer is made we can also do it with the controller so the thing about the controller is that it doesn't have a specific button out mapping for it so like I have an Xbox controller right here it's not going to say X it's not going to say the x button right but instead of what's going to do is it's going to call these face buttons so it's going to say the Y button or the triangle button on the PS4 5 controller is going to be the top facing button this is going to be the right facing button down facing or bottom facing button or down facing but I can't remember and then the left facing button and then this is going to be the left I believe it's called joystick right joystick and then here we have just the d-paddle directional these are going to be called triggers and then this is just called being called a bumper and then this button is just going to be cause which is normally the pause button it's going to be called the special button so just be aware of the naming for that it's not one to one with Xbox or anything like that let's go into our player do right the right face button so as you can see here it says uh game pad events Gamepad face button right and we're going to let's do a print string and we're going to call this you know Xbox as you can see I'm pressing this button because another option what we can do is if we go here and we go to edit project settings we go to input we can put in custom inputs now um unreal 5 has a new mapping system now so this is a little outdated however it is the most simple way to add inputs the other way is a little more complicated I might go over that later but we can do what's called an action mapping right here so if you hit Plus let's just call this test and what we can do here is we can add any thing that we want so as you can see has all the different kinds of controls and inputs that it can take in so we're going to go to keyboard we're going to go down to Q we're then going to press plus and then we're going to go to the right face button right and so then we have that let's go test input just to make it a little cleaner so if we go to our third tracing character and we go test input we press play and we click in and then we hit the q key it's going to run that hello and if we hit the right face button it's going to also run that hello so it does both of them even it does both of them because both the inputs are tied to the same thing there's this component here called character movement pretty self-explanatory it is just going to hold all the information about how your character moves so as you can see here if we go to the details uh the details there's a lot a lot of different settings you can change so you can change how much gravity affects them you can change how high they can step like how high they can step onto an object you can change them how fast they jump you can change how they can walk Max walk speed is how fast your character goes as you can see it's for different types of movements so there's a lot a lot of stuff in here air controls how much you move in the air a lot a lot of settings here you can do a lot a lot of things to make your character move unique so let's say hypothetically you don't want your character to move you have a cut scene or you have them picking up something or you have some animation or you just have something that means hey this character should not be moving right now we're going to go here and we're going to go deactivate so this is just going to deactivate this component basically there is a node called this able movement but personally I think deactivate works a lot better in most cases so let's uh use that so if we go here I'm going to now press Q I'm moving maybe moving Q I can no longer move you see I'm pressing all the buttons I'm pressing jump no movement right but then you might be thinking oh but I want to move later you know it's very simple so let's just put a actually let's let's do it on release um we're going to Simply take this and we're going to go activate which basically this is just doing is activating this component so this isn't specific to character movement you can do this for any other component but it's mostly just used for character movement um so all right let's move we're we're moving we're moving we're moving we're moving we're moving we hit Q we can no longer move uh I want to move so bad by we let go of cube we can move again um so again very simple very good uh you're probably going to need to use uh this at some point okay so let's say we want to do something uh with character movement again that's really simple we're going to make a Sprint so as I said there's all these settings over here but you can actually set each of them um so let's go to set max walk speed so we go here so the current Max walk speed I believe in unreal default one is around 500 600 um centimeters per second yeah 500 minutes uh meters per second so that's keep in mind that that's how the movement Works um so let's do something like twice as fast let's go one thousand and let's say that when we release the key we go back to our normal um locking speed so we go here I'm gonna go release so here we have a basic Sprint function in here so if you code this you've basically coded your first mechanic in unreal so you walk normally we're going to go our normal speed but let's say that we hit Q which really should be shift since it's Sprint but we're going to go here as you can see we're faster which is a little hard to see because the animation doesn't change but if you just look at like how the world's moving around us you can see we're a lot faster let's change to something absolutely crazy like let's add in just another zero um so maybe it shows up a little better so we're walking normally and then boom we are just absolutely you know running like a mad lad now and then when we release the key we go back to running normally um so that's how you do a very uh that's how you do a Sprint key or that's how you do a Sprint you can also change how high you jump and stuff like that with here so character movement there's a lot of potential in there um so just be aware of that okay so next thing we're going to do is we are actually going to connect two actors together so we have our our character we have our actor and we're just going to basically make them to where uh we can interact with them so let's delete all this test code that we had from before we'll keep this function so let's do this so at event begin play what we're going to do is we're going to do what's called a cast so we're going to cast to Third uh person character so what this basically does is it gets us it's going to run this code and it's going to go over to our third person character code and do certain things but we need to have a reference to it so let's do a node called git player character this is basically just going to be a reference to your character at all times but it's mainly just used um for this cast here um so we're going to left click and we're going to promote this to a variable so as you can see this makes it a variable that I'm going to call a player and so now at any point I can just drag this in and have a reference to our player this is what's called the hard reference um which normally you want to be working with soft references but that's a little bit more advanced I'm just going to go over hard references for this video so here we have our cast to our player and so let's say that when because we still have this box Collision here that when we enter this box Collision we want to stop the character movement like we did before oop I did not mean do that let's add event character begin overlap so we're going to do the same code as before real quick all right so we have this and real quick I'm going to show just another macro so you could use this a lot so theoretically it could be macro I normally don't make a macro but you could um but let's say um you know let's just call this um tag question mark but you know that we're going to need you know to change this tag thing right here right because maybe we're doing it to where we want the player maybe one other object so what do we do what we can do is we can drag here we go back and then it's going to promote it to a pin so now we go here and as you can see we can just type in player and now we have a macro that we can change values of you can do this with every single thing you do with floats integers vectors stuff like that and you can give the macro data as well however you need to also go here just so that there is an output so that we have an output right here um okay so from there we're just going to do this so we get our player so again we want to basically um and you can put multiple outputs on a macro as well so for the player what we're going to do is we want to disable the character move so we can do git character movement which you're going to scroll down and then we're just going to do what we did before we're going to deactivate so this is code that normally can only be run within the player blueprint but since we have a reference to it we can do it like this so we go here as you can see I can move around all I want I can jump but I go over to here and then boom can't jump can't move right so there we have a reference so that's one way to do it is a cast now the thing about cast is that they're slightly they're pretty expensive um so like when you're writing the code this you know takes some processing power but for important things like the character it does make sense um to you so now let's do a um let's do something a bit different we're going to do a different uh hard reference call so we're going to go up here to this event begin play so there's some other code here so again I'm going to use our handy dandy sequence I'm just going to put this here do that and then there organize that a little bit and then we are just going to put what we want down here and what we want to do is get actor of class so when you're working with hard references this is the node you're going to want to use most of the time because simply it is just getting a reference to the actor through and through so our actor is called actor then again let's promote this two variable call it actor and then we have a reference to our variable so let's go over here let's do a custom event and let's just call this um destroy and then all it's going to do is destroy actor so we can actually call other actors custom events um if we have a reference then we're just going to go to actor and then we're going to get actor and then we're going to get their custom event of destroy actor well we don't we want this one so obviously you could just destroy the actor without having to do the custom event but we're just going to do the custom event to show off that so we're going to go here we're going to hit Q it destroys the actor so again we have a hard reference now um you'll remember before we have a macro in here called tag you can't call macros um so if I do this and I do tag right nothing comes up and so this is context sensitive it just basically will show the relevant um things but if you do this it's going to show you everything related tag but this just showing you what's relevant for this blueprint so sometimes like your knee doesn't show up and you do have to do this but most of the time you're going to want positive sensitive here but if we go down we see this tag question mark which let's even put a question mark to make it more specific this tag question mark this isn't a thing we can't call that so let's say we want something like a macro where in here we want something that we can run multiple times because it's like a very common piece of code but we also want to be able to call it over here what we can do is create a function so the difference between a functionism in a macro is that macros cannot be called by other actors or as functions can be so let's do this so we have function let's just call it a test funk and then we're going to go here and we're just going to destroy actor go here and then we need to have an output because it's good to have one of those and we are just going to hit that there and we're just going to call this finish and you can again you can put in different things so this can have different inputs you have to put in like string or a vector or float and this can also return a string Vector float Boolean stuff like that um which let's actually do an example of that so let's say that we have a branch here so we're only going to basically run the rest of this code if something is met let's put an input here and let's just call this you know true something basic and we're just going to pass along this we're getting over here we're going to go test test Funk here we go call function bang it's going to have this little input here that we have to put something in so let's just um you know make a a fake Boolean and let's just always set it to true um I say it's true and then we go here and so now we can control whether or not this code gets run functions are very very powerful and very very good if you have more complicated uh functions um those are very very useful to you okay well that's going to do it for this video again this is just so much information I hope it's not too overwhelming so I hope that these have just given you some you know base tools and some base understanding of the the tools you have at the disposal when you're coding Blueprints and unreal5 so thank you so much for watching and I hope you learned more about the need to know nodes in unreal five
Info
Channel: Cason Quisenberry
Views: 69,905
Rating: undefined out of 5
Keywords:
Id: 4kezN9gr_ms
Channel Id: undefined
Length: 48min 59sec (2939 seconds)
Published: Mon Jun 05 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.