Getting Started with Blueprints Coding - Unreal Engine 4 Tutorial for Complete Beginners

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments

Hi

I hope you don't mind some constructive feedback, but there are some approaches here new people to Unreal shouldn't be taught.

You shouldn't ever be using Level Blueprint for this. If you wanted another 10 lights, you're going to be copying and pasting the code another 9 times. If you then wanted to change any of the logic....you need to go and do it in 10 places. Even if you used a function in Level Blueprint, it's still linked to that specific level!

You also shouldn't be using keys like "E". Use the input manager and use the appropriate node for it on the graph. You should only use hardcoded keys for debugging. It takes a matter of seconds to set inputs up correctly, and new users to unreal need to know this from day 1.

You use the Triggerbox which casts the Actor to a PlayerController? I can only assume you're trying to filter if it's the player before continuing with execution. You should be using collision channels for this on the volume (which really should be a stand-alone Actor, not a TriggerBox in the level). When you do these checks, you'd normally always want to check for the collision on the Pawn and not the PlayerController. The result from the cast isn't actually being used, as you have nothing from the output reference.

👍︎︎ 10 👤︎︎ u/KeepCalmMakeCoffee 📅︎︎ Jun 10 2020 🗫︎ replies

This post appears to be a direct link to a video.

As a reminder, please note that posting footage of a game in a standalone thread to request feedback or show off your work is against the rules of /r/gamedev. That content would be more appropriate as a comment in the next Screenshot Saturday (or a more fitting weekly thread), where you'll have the opportunity to share 2-way feedback with others.

/r/gamedev puts an emphasis on knowledge sharing. If you want to make a standalone post about your game, make sure it's informative and geared specifically towards other developers.

Please check out the following resources for more information:

Weekly Threads 101: Making Good Use of /r/gamedev

Posting about your projects on /r/gamedev (Guide)

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

👍︎︎ 2 👤︎︎ u/AutoModerator 📅︎︎ Jun 10 2020 🗫︎ replies
Captions
[Music] what's going on guys this is your boy Ostrom sensei and welcome back to Unreal Engine 4 for complete beginners I know I haven't been uploading any of these videos and I've been very inactive on my channel but yeah I'm trying to come back and yeah it's been a while since I made one of these videos so I thought we could do a new video and today we are gonna start learning blueprints we're gonna start with the basics and we're gonna climb to become like able to make a full game but yeah before we get started the usual like the video subscribe to help me reach my goal of 10,000 subscribers and super special thanks to my patrons who are supporting this channel so for blueprints I'm actually gonna do several videos and not just one and that is because you know there is a lot to cover and I want to start with the very basics of it and you know we want to be able to do stuff by the end of learning blueprints so I'm gonna do several videos right now blueprints and we're gonna learn something else like I don't know something to get started with our first game and then we were going to get back to blueprints and you know learn more of it so they want to be like not all of the blueprints videos will be in order so there will be stuff between them but yeah let us get started so over here in our content browser we have this folder called third person VP which stands for blueprints and there is a folder inside it called blueprints now here you have to stuff which are the third person character and the third person game mode so the third person character is basically your player character and a lot of the gameplay mechanics and almost everything about the playable like everything playable in the game will be in the character in this character or otherwise it will be something like a different blueprint that is connected to this character blueprint so yeah this is basically the core of your game and I forgot to explain what a blueprint actually is a blueprint is basically a script if you've ever used unity you know what a script is it's basically a few lines of code that you know they make up your game so they are based on variables for example if something is something then you that thing and if it's not then do the other thing and yeah that's basically the basics of programming so this third person character actually comes up with the template the third person template it has a lot of pre-made stuff in it for example the movement and all of that stuff but yeah we're gonna take a look at them one by one and see how it works without them we're also going to take a look on how to create a character blueprint from scratch but we're not gonna do it I'm just gonna show you how to get started with it and if you want to do that you can check out my action RPG tutorial series but that one is very advanced like not very but it's a little bit more advanced and I wouldn't advise beginners to get started with it instead we're gonna do something based on this this you know we're making a game that's mostly about walking and jumping we want to you know use this and it's gonna be very simple so yeah we're gonna replace the character eventually and the animations and make it our own game so to create your own blueprint you can right click in the content browser or you can just click add new and there is something called a blueprint class just click it and it will give you a lot of options and I'm gonna try to explain all of them quickly an actor is it says here that it's an object that can be placed or spawned in the world but yeah that's not a good explanation an actor is basically something some type of object that you can interact with inside of your game and it's most likely not gonna be something that's alive so it's not a character basically I don't know like I health pickups or other stuff like that batteries and horror games yeah that's what an actor is then we have the pawn a pawn is an actor that can be possessed and receive input from a controller in other words it's the same as the character but it has a few differences we're gonna get into them later but I always recommend using the character instead and the character is a type of bond that includes the ability to walk around and yeah the pond can also walk around so I don't know ignore that but yeah next we have the player controller now what a player controller is is it's basically the brain of your pawn or character and that is like you can give it certain conditions and other stuff that are specific to the player like to the player player and you know if you're using the same character for the AI you're gonna give it in an AI controller instead of a player controller so yeah it's a little bit different from the AI controller it's more directed towards the player so yeah let's read this a player controller is an actor responsible for controlling a pawn used by the player next to have game-mode base game-mode base defines the game being played its rules scoring and other facets of the game type we'll get back to the store later and also these two are going to get back to them later but we're going to read them quickly and after component is a reusable component that can be added to any actor and then we have the same component which is a component that has a scene transform and can be attached to other scene components and we have other stuff here like air controllers and other things a lot of stuff here but yeah they added the most common ones above so yeah we're gonna check everything out later in this series but for now we are gonna try creating a character and we're not gonna name it because we're not gonna use it but yeah if you go into it after you created it you can see that you have a capsule component an arrow component a mesh and a character movement here you have your variables and all of the stuff we're gonna learn and if you go to this event graph this is basically where we are gonna write our code now I know a lot of people don't consider blueprints code but in fact they are its coding it's considered coding and I'm pretty sure everything you code in blueprints later gets translated into C++ if we take a look at the ready third person character blueprint we can see a few differences we have two over here the camera boom and the photo camera and basically these are the things that the player sees the game through and we also have a character inside of the mesh over here the mesh component is empty and there is no skeletal mesh inside of it and one other thing is we have variables here that you know help set up the event graph so if you go to the event graph of this one there is inputs for the walking and D turning and also the jumping so actually we are not gonna be editing this stuff in this video we're just gonna do something very simple and that is doing a lamp that you can turn off and turn on using the level blueprint that's it for the character blueprint we are gonna delete the one we created earlier so yeah now we are gonna check out the level blueprint and the level blueprint is basically a blueprint which is like a script also but it's dedicated to your level to each level each level has one and it's got its separate bits right between each two levels so each one has a clean slate for the level blueprint and with the level blueprints you can do specific things for the level for example turn on and off a light and you know destroy an object and you know sets music for each part of the level and I don't know open doors if your doors don't have aren't you know their separate blueprint actors and yeah a lot of stuff for example opening drawers a lot of that stuff so in today's video we are gonna do the light switch thing and yeah let's do that right now by going into the level blueprint so to go to the level blueprint you go over here above and there is a blueprints button click it and there should be a an option to open level blueprints if you open that you should see a an empty blueprint with no variables or and nothing it's a very clean slate so to show you how this level blueprint can affect your level we are gonna do the light thing I about earlier and to do that we are gonna choose a point light for from our level actually now I'm gonna go with this spot light and I'm gonna delete the point light I made earlier yeah this is the spot light and why is it so weak I wanna make it stronger yeah like this I increase the intensity from the details panel in case you're wondering and yeah we want to use this light and the level blueprint to create the light switch so to do that we are gonna simply with the spot light selected or any lights you want to use you keep it selected in your viewport and you right click in your in your event graph and there should be called creates reference to spot light so you want to click that and what this does it it just brings your spot light over here and you can do other a lot of stuff for example you can set intensity as you can see you have the intensity like this and you can do a lot of stuff with this reference so what we're gonna do is we are gonna create a box here that if you press the e button while you're inside of this box you're this invisible box and we're gonna pretend there's a light switch on the world or you know what let's just create one we're gonna drag in a cube and make it smaller like this and turn off snapping yeah like this this is our light switch it's way too big so I'm gonna make it smaller yeah like this and yeah if you press the e button while you are here the lights will turn on and off and to do that we need something called a trigger box so this trigger box is an asset that you can use that activates a blueprint only if you are inside it or you know if you've just touched it so we are gonna go to the recently place I think know where was it okay yeah it's in the volume so nowhere was it really here just go to search and type and trigger and you know you have a few options there is a capsule trigger there is a sphere trigger and there is a trigger volume but I'm just gonna go with the trigger box and I'm gonna make it larger so that it covers the entire thing like this and then we are gonna bring it also into this level blueprint now to do that with it selected again the same as the light it's light reference we are going to right click here and there should be a three options there is Advent for trigger box one call function on trigger box one and create a reference to trigger box now this creates reference is the one if used for the light but for the trigger box we want to use something different if you go into Advent there should be a collision collapse thing and there is an actor we can overlap on actor and overlap and on actor hit so the one we'll choose is on actor begin overlap because you know it happens when you begin touching the box and an actor and overlap happens when you end your overlap with the box so we are gonna go with an extra weekend overlap and you should see this note thing come out and yeah I forgot to explain these are nodes each one is a node and you can call other notes from it and you know basically to make it for beginners I want to say I don't know something very simple but I can't come up with words basically your game is gonna be a mess of nodes and they are gonna be very connected and that way you're gonna build a solid game in Unreal Engine 4 using only blueprints so yeah you have an actor begin overlap this is when your player such as the box the trigger box and what we want to do is we want to set this one to be either true or false based on your input so we are going to type in also input II and yeah I forgot to mention you bring out this menu by right-clicking and from here you can choose a lot of nodes that you can you know experiment with and make your game but yeah I'm gonna type in input and it's not typing of course input II and I don't know yeah it's here so this is basically the keyboard events you can choose to make a set of events based on what you press over here like one one of the keyboard buttons if you if you press it something happens based on what you choose so we're gonna go with the e button and yeah we have pressed released so now we have to make a condition for what happens when we press E and we want to connect it to when we are touching the trigger box so it only happens if we are inside of the trigger box and what happens is we basically turn on or off this one so instead of these spotlights there should be something called visible and we are gonna set the visibility of the spotlight to be true or false based on if we press this so you want to drag out from the spotlight this is where you connect your stuff this part do you have pins here that you can connect to other pins and that way your blueprint happens so I'll just drag out and you should see this menu happen when you drag out and let go of your left mouse button now you want to type in set visibility and here it is spotlight component now I'm not sure they need this yeah we do okay and the new visibility will be false so we can turn off the slides based on this and this happens only with be pressed so just drag out of pressed and connect it to the set visibility and that way when you press E it turns off or on the light so we're gonna try it out if we hit play and go into our game we can Chris E and that way it turns off the light but we for exact for starters it doesn't turn it back on if you press the e button again and the other thing is that it doesn't happen when you are in the trigger box so yeah we're gonna fix that right now and the reason it doesn't turn back on is because we only made the blueprint for it happen if it's pressed and you know you can do this if you press it or release it and the visibility will oh no it won't change okay no problem now yeah we have two options we can either copy all of this or you know just copy this one and connect the targets to the set visibility and that way you can connect it to the released and set the new visibility to be true and what happens is if you press the e button and hold it it turns off the lights but if you release it turns it back on and yeah I think it's a nice effect but it's not realistic and it's not what we want to do so to do the trigger thing for example yeah you can you want to do it like a light switch you turn it off and you turn it back on whenever you want and the way to do this is not by using the release button we can just drag out of the e and type in flip-flop and what this does is it changes it switches between these two each time so for example if the first time it's it does did this part this in this I don't know link whatever the next time it does the other one which is turn the lights back on and when we release nothing happens so yeah this is what we want we're gonna compile and give it a try so yeah if we are in the game and we press E we can turn it off and on and on and off and yeah however much we want nothing changes and you know we have shadows and it looks very good now what we're going to do is we want to turn on this trigger box thing and yeah we want to make it so that we can only turn on and off the lights next to the light switch and the only way no I mean there are there isn't only one way to do it there are so many ways to do that and I'm not gonna explain them all in this video just to make sure that you guys understand things slowly I think learning a lot of stuff very quickly is a mistake that you don't want to do because yeah it causes a lot of problems so yeah we are gonna do it only one way and we're going to learn other ways later for you can experiment with it later as you go and it makes things easier later even if I don't show you how to do it right now it's gonna happen and you're going to learn it by yourself eventually so first we want to specify the overlaps actor so we want to tell it if this specific actor touches the trigger box and presses the e button only then that this happens and yeah with the way we do this is we get the overlapped actor first and we look for the players so there are many ways to do this I'm just gonna type in player and yeah there are many ways to do it actually yeah we can just to player controller and that way it's only happens with the player controller and you know actually there are many other ways to do it yeah let's just keep this yeah we're just gonna keep trying this one and then if the player controller is touching this then we are gonna do the other thing which is make sure that this only works if the player is touching the trigger box and to do that we need something called a variable which is this part over here now a variable is basically a small condition that you can set whether it's true or false or a number we're just gonna go with the true and false for this video so here we want to create a new variable and we are gonna call it yeah we're just gonna call it something stupid and simple for the sake of this video we're gonna call let's player so to change or you know what yeah yeah we're just gonna call it next to light switch and this variable is a type boolean we are only going to learn the boolean for today and we're gonna do a video specifically for the variables boolean x' are basically variables that are either true or false so over here you have whether you can set it to true or false it's we want it to be false by default and then we want to set it to be true when only when we are touching this so the way to do this is you want to drag out of here and you should get two options get next to light switch and set next to light switch we want to set it and connect it to the after the weakest to the player controller we're gonna set the next to the light switch to be true and that way we specified that we are next to the light switch and yeah we specified that but we didn't ask this one to only do this part if the player is next to light switch so what we want to do is we want to make way for a new node and there is a node another node which is very useful and it's basically the base of programming and blueprints altogether and that is the branch node the branch node asks you a condition for example our condition a is next to the light switch we check if we are next to the light switch if it's true then we can turn on the lights and if it's false we do nothing so to do this you either drag out the next two lights which variable and get it and connect it like this or you can just drag it and drop it into the condition pen and it connects automatically and yeah now we've checked whether it's next to the light switch or not so let's give it a try and see what the problem now is and if we hit play and play the game we cannot turn on and off the light but if we go next to the light switch and turn off the light yeah it still doesn't work so I think I know what the problem is and that is that our character here is not the one we want to use I think we want it yeah let's give it a try like this I think we didn't need it altogether yeah we didn't so yeah as you can see if you hit the light button you can turn on and off the lamp or you know the world I don't know ceiling lamp or whatever and it turns it on and off and that's very cool but the problem is now is that if you get far away from the light switch and keep pressing the e button the light keeps turning on and off and you know you're very far from the light switch and I know it's very magical and yeah that's what what we're gonna fix right now so we turn we told it to set the condition for if we are next to the light switch to be true if we touch the like if we begin overlapping with the trigger box now we want to tell it if we are not overlapping with the trigger box to set this variable or condition to be false so to do that just right-click Oh first we want to select the trigger box and our level or in our viewport so with it selected you right click and add event for trigger box one collision add an actor and overlap and what this one does is it basically tells you what to do when you are not overlapping or touching the trigger box anymore and we want to set this next to lights which a variable to be false now and basically what that does is it just does it to turn the variable off and that way you can no longer edit this part if you are not touching the light switch I think now it's gonna work so yeah let's give it a try and hit play and if we do that and right now I'm gonna start pressing E we can do nothing when we are four we can get close to the light switch and turn it on and off and as you can see it works now if we get far from the or you know if we exit the trigger box we can see that it no longer works it only works if we are next to the trigger box which is very cool and yeah it's very nice to have this thing in your game so I really recommend trying it out now one last thing I want to show you about blueprints and that is that you can actually organize your blueprints by doing comments on stuff and you know making it very tidy and neat and to do that you just put your nodes next to each other and you can you know organize them then you can type like a comment to specify that this thing is specifically for the light switch so if you select them all and press the C button you can see the comment think and over here we are gonna name it so we are going to name it turn on and off light or actually no turn light switch on and off so light without so it's just turn lights on and off and even inside of the comment you can do other comments for example if we set if we select the set next to light switch and the trigger boxes and we press the C button you can add a different comment inside of the comment which is very useful for remembering what each thing is about and I really recommend it for beginners so you have this comment we are gonna call let's set the light switch variable and the other one we are gonna also comment on it to make sure that we remember what it's for so we are gonna select all of them and press the C button and then we are gonna name it I don't know what are we gonna name it set light visibility and yeah based on and but and yeah as you can see now we can actually no we can't read anything because they are colliding if we get this like this yeah now we can see you have this turn up light on and off comment and inside of it you have two comments which are set alight visibility based on input and set lights which variable and another thing you can do which I don't know if you want to use it or not but you can select them all instead of the comment and right click on them and collapse nodes into one node and we are going to name it I don't know light switch and basically you have all of your code that you've made inside of this one so if you double click on it you should see that you have the same blueprints or code inside of it now so it's very organized like this but I don't know if you want to use it or not' sometimes it's not very like you don't want to use it at all places because sometimes you might lose stuff there isn't really a definitive way to do stuff and you know programming so yeah I really recommend you know finding out what you want to do and your own methods and yeah one more thing I forgot to mention that if you've put them in a note and you want to bring them out you can just right click and you can click the expand nodes and it just brings back your code so yeah I forgot to mention something very important and you know beginner-friendly and that is you wanna press compile every time you finish editing your code and that way you know it puts it in your game and you know it makes sure it's make sure that you don't have any blueprint errors and yeah I think that's about it I really hope you guys found this video useful and that you've learned something from it I know that it's very basic and very beginner friendly and yeah that's the point of this series and young sometimes it's very important to learn the basics so yeah if you guys enjoyed this video make sure to subscribe to help me reach my goal of 10,000 subscribers and don't forget to like the video to help motivate me to make more of these and more action-rpgs tutorials and super special thanks to my super precious patrons thank you very much and yeah guys I'll see you on the next video take care and bye [Music]
Info
Channel: AstrumSensei - Game Dev
Views: 12,879
Rating: undefined out of 5
Keywords: unreal engine, unreal engine 4, blueprints unreal engine 4, unreal engine 4 blueprints, unreal, blueprints, unreal engine 4 tutorial, blueprint, unreal engine 4 blueprints tutorial, unreal engine 4 blueprint tutorial beginner, unreal engine 4 ai, unreal engine 4 inventory, unreal engine 2020, unreal engine 4 programming, learn unreal engine 4, unreal engine 4 games, unity blueprints, enemies in unreal engine 4, unreal engine 4 ai tutorial, unreal engine for beginners
Id: LtY1pFShROc
Channel Id: undefined
Length: 30min 35sec (1835 seconds)
Published: Wed Jun 10 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.