Unreal Engine Bluerpint Basics ( For Unity Developers )

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
blueprints in unreal is a bit like a prefab and a c-sharp script combined into one single asset so let's create a blueprint if you go into window content browser and content browser 1. you can also control space to open this like a temporary content browser which disappears again when you press control space again but I like to have it docked permanently so anyways to create a blueprint you just select a folder and right click and select blueprint class and here you can select which parent class your blueprint is going to have and I'm just going to pick actor which is basically anything that exists in your scene I'm going to call it BP underscore tutorial and BP unscore is the common it's like the standard um prefix for blueprints and there's this handy page where you can see all of the common uh or recommended prefixes for each asset type that I highly recommend just copying all right so let's open our blueprint this may be a little bit confusing at first but so I mentioned that this is a combination of a prefab and a script so you have your viewport which is when you want to work a bit more with your prefab aspect of your blueprint and then in the event graph this is where your code lives so immediately you're gonna see the event begin play which is the equivalent to the start function in unity and the tick which is equivalent to the update in unity so these are events and they live in your event graph and then you also have functions so I could make a new function and call it test function and then in the begin play I can left click drag this function and then connect these two pins together so now instead of having to go and find my function here I can just double click on the Node this will take me to the function itself and we can right click and look for print print string connect this thing and compile see this is this is one of the things that I love about blueprints uh compared to C sharp in unity is that the compiling is basically instant even with more complicated blueprints I haven't really noticed any compile time whatsoever so just like in unity simply drag your prefab or your blueprint into the scene and if I press play we'll see that it says hello to make a variable you can just click the plus here and one thing that you can do in blueprints that you can't do in c-sharp or in C plus is you can do this which I know is going to make a lot of programmers screech in pain but personally I think this is more readable this is of course just a preference so you can name it in any way you want um so to change the type you can just select here so if you click this drop down over here you can see that you can change this integer into a single integer an array a hash set or a dictionary which is called a map inside unreal so one of the things I hear a programmers say about node-based programming is that it ends up being this spaghetti Nightmare and it can be but in the same way that you can create terrible terrible code in a written programming language the same way you can do terrible blueprints in unreal but you can also make organized stuff in unreal believe it or not so when you see this kind of stuff it's basically the equivalent of someone writing thousands of lines of code in one single function so this is just really really bad so this is not really the fault of using a node-based programming language this is more the fault of someone not organizing their blueprints so to address this there's several things you can do which is of course make sure to split up your functions into separate functions as you would normally do in c-sharp anyways another thing you can do is you can group your functions into categories so now I made this into a category I can just drag this function under here and now I have this category of test functions so one of the things that I typically end up having is for example I have this function here which is called deactivate there's many things that it has to do and instead of having this one gigantic mess of notes everywhere I started by making all of these functions inside this function just to figure out how this entire function was going to work out once I have something functional I start to split this function into several functions and I try to give them names so that I can basically read what this function does almost as if it's written English so most of these functions are very simple which is probably a little bit Overkill but honestly it's been helping me avoiding ending up with anything that looks remotely like this so for example this one is a little bit more complicated and a little bit more messy what can we do to make this more readable first of all I like to try to align things it just makes the whole blueprint just easier to comprehend in my and this is terrible these lines going through all your nodes you can double click on the line to create this extra node that you can then move around and pass the line through a more clean path it does feel a little bit like there's this extra puzzle that you have to solve with blueprints that you don't really have with C sharp or C plus plus once you get used to it though you start doing it completely subconsciously and while I'm thinking about what to do next in my blueprint I begin to tweak all the notes and the lines and just start to clean up what I have in front of me a bit like you're doodling on paper while you're waiting for something and it doesn't really take that long to get something that is way easier to comprehend so now that I've cleaned up this function I still feel like it's a maybe a little bit too many nodes for one function what I think I'm going to do is I'm going to move this over here because it's setting some variables that live in this function but these local variables they belong to the save schematic function and uh so if I select these and right click and collapse to function and then I'm just gonna call this uh collect data that's a really terrible name but let's just name it that for now and now this becomes a little easier to understand now these variable names are terrible so let's call it exactly where it's going here so here's something that might be better with a sequence node so if I hold s down and left click I get a sequence node and this node is really simple all it does is it executes one thing after the other and you can add more things that it has to do and you can right click and remove them again so right now we're only doing two things so I'm just gonna have two and if you're alt left click on a connection you remove the connection and now I'm going to hopefully have a cleaner graph all right so I'm not so sure that this is easier to read but at least now you know this sequence node exists and it can be quite handy to organize your stuff especially if you have a long line of notes which can be quite hard to comprehend if it just keeps going now you have this weird long graph which can be pretty confusing to look at so if that's an issue the sequence is pretty good to reorganize your code in a more vertical layout back in the tutorial blueprint let's go over the most basic notes so if you hold B and left click you get a branch so every time I mention a hotkey you don't have to remember these you can right click and then search what you're looking for so if you type Branch it's just gonna show up here but I highly recommend uh trying to memorize these broadcasts because it can really speed up your process when you're creating these nodes over and over again so obviously the branch is a basic if else condition so if I just make a test tool and change it to Boolean and throw it into the graph now when you drag into your graph it's going to ask you if you want to make it a get or a set so we want to select get and hook that up to the condition if I compile now okay so this is one thing if you made your Boolean and you don't see the default value like if I select this is a variable integer uh still don't see I guess I haven't compiled at all yet so if I compile now right so now I can set this default value for the integer and the default value for this pool is true so when you run this function it will check this variable it'll be true it'll go this way to make a variable public you simply click the eyeball over here and if you check in your outliner which is the hierarchy in unreal you can select your blueprint and you will see your your test rule is now available so remember those categories I was talking about in The Blueprint well if I put this Boolean in the test functions let me just rename this category to tutorial now we have a category desk called tutorial and I want this variable in fact I want both these variables to be in the tutorial category and I can do that by selecting here and once I have one of them I can just drag the other into the category so if I compile now I should be able to see that the category is called tutorial and I can see all the variables that are public we can see a whole bunch of other variables but that's because we made our class A Child class of the actor class which by default has a whole bunch of variables that you can tweak one thing you can do in blueprints which is pretty handy for testing is if you select one of your functions and enable call in editor compile and now you get this button so when you press this button it's going to execute this function which right now is not really doing anything so if you hover over one of the pins and you left click drag it'll automatically open up this search thing so you can look for a print and string and assist function and compile and this will only happen if this is true so let's give that a try um so this is false nothing's happening this is true nothing's happening why is that that's because right I said it's not working because we changed the another test function so terrible terrible names by the way I need to work on my tutorial function names nothing happens now but if you look at your blueprints you will see this line is animated telling you that the code but to here and didn't get any further so if we drag out uh and right print string and this is working compile and I press the button and it's working but you're not seeing any print value and that's because it's showing up in your output log the text that you see in your scene is or play mode so if you're going to play mode and we select the tutorial and press the button now you can see the text to make a for Loop you can press F and left click you can of course also create a normal for Loop and you can also create them with a break so if we do like this oh then we break we can Loop this all the way around so I'll go through this Loop 10 times and if this is true then it won't stop the loop and once it's once it breaks then I'll go here and then you can do something else here you can of course create a subclass of your class if you just right click on your class and create child blueprint class or if you create a new blueprint I should be able to write DP on the score tutorial and here it is so one Concept in blueprints which is a little bit different than prefabs is that there isn't really game objects in the same way I mean I guess the actor class is kind of a game objects but in unity you have a lot of game objects and you would typically you know Nest them and have a whole hierarchy of game objects you don't typically do that in unreal instead you would typically just have components for things that have a more complicated hierarchy like a skeleton you actually have a skeletal asset so if we open this skeletal asset this is where all the joints exist and they aren't really the same as game objects because it's its own you know asset so if I put this character in the scene you'll see there is no game objects for every joint or anything like that it's just one object so basically the point was just that the game object's in unreal they do exist in in the form of actors but it's much less a core concept of unreal than it is in unity I feel you can also make what is equivalent to c-sharp interfaces if you right click and the blueprint select blueprint interface and call it BPI underscore and I just can't think of any other name right now so it's just gonna be tutorial interface um and if you open your blueprint class and here under class defaults excuse me it's a class settings then if you go to here and type in BPI yes here it is and now you have this interface implemented now this interface doesn't have any functions yet so nothing really happened so let's open this and let's call it oh God what are we gonna call it yet another tutorial function yay back in the blueprint class if we compile I believe then under [Music] where is it interesting um what did I forget compile interfaces here we go so now we have this function implemented from the interface and if I select the interface add some kind of variable compile now it shows up here static functions is also possible with blueprints but a little bit more janky in my opinion so if you right click and blueprint and blueprint function library and I typically just call it BPF and then oh God uh sorry options great so if we open this um another function but it's I think this time all right and in the blueprint now we can right click and what do they call it great another function but it's static this time there we go so I guess in compared to C sharp where you would have a static function inside one of your classes this is kind of like a global function so any of the blueprint functions that you create in this Library asset will show up in any blueprint if you just right click it'll show up here here's some more organization tips if you select a bunch of notes you can press C this will create a comment box and write some something descriptive um and you can of course scale it and uh one handy thing is that you can move the entire thing and this will move the whole thing all of the notes inside of it you can also as you can see here you can set a comment for each node individually so if you hover above the top left area of a node you'll see these tiny dots if you click on them you can write some other stuff here some other stuff so this can also help organize your stuff you can also if you select your comment box you can select another color it's a nice in color I don't generally use these because as soon as I feel like I need to explain something I feel like it to me it means that it's too complicated and there's too many nodes I should probably put it up into more functions I would rather have a hundred smaller functions that are super easy to understand then only have 20 functions and half of them are like super confusing so generally I like to keep my functions to only fill the space I don't want to have to drag around and figure out what's going on all the way over here and then drag around and oh okay it's connected to this thing and it just becomes very confusing very fast I would recommend this approach it's been working very nicely for me at least another neat little trick is if you have for example let's say you have a bunch of nodes that are connecting the same pin and all of a sudden you realize that you maybe have another let's just say you have another ball right and you want this bolt to be the one that it's referencing instead of having to you know do this which is kind of a pain you could do that of course but if you control click on this pin you can move the entire thing and reconnect it like this you can also directly drag a variable onto a pin and this will automatically connect it you can also control click drag on a variable to get the variable and you can alt click the variable to set the variable so for debugging I've already shown you how to print on screen and this will print on screen but it will also print in your output log so it's basically the same as debug.lock in unity if you select a node and press F9 then you get this Red Dot and if you compile and run and we select the tutorial and so this was my another test function if I press this then the game pauses and this functions like a breakpoint so you can see that it got to here and stopped and even without breakpoints having the blueprint opened while you press this button you'll be able to see how the logic is going around then if I turn this off behind this why is this going over here huh all right I had to compile of course another thing you can do is if you drag this here and you press play and so you can hover your mouse over a variable to see what the value is at this moment and you can also right click on the Node and click watch this value and then you will you won't have to hover your mouse you'll just see that it's false while you you watch what's going on in the game uh so it's set to true now and if I set it to false you see that it's set to false so you'll be able to see live how your values are being manipulated you can of course see what the values are just by selecting the object in the scene and see you know what the values are set to here just like in unity I think I'm going to wrap this up now and I hope this was useful for you of course this doesn't cover every single aspect of switching from C sharp to blueprints hopefully I will find the time to make more of these and help you switch from C sharp to blueprints goodbye
Info
Channel: Dr Hippo
Views: 4,030
Rating: undefined out of 5
Keywords:
Id: cuRDrXL0CTA
Channel Id: undefined
Length: 19min 28sec (1168 seconds)
Published: Sat Sep 16 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.