Hello guys and welcome to the Unreal
Engine 5 Blueprint Beginner Tutorial. In this beginner tutorial, I will
explain what are blueprints, why you should learn blueprints, and how to use
blueprints inside of Unreal Engine 5. Blueprint is the visual scripting
system of Unreal Engine, and you can use blueprint to create things like
complete games, tools, and so much more. Now, if you aren't going to be
creating games inside of Unreal Engine, Blueprints still can be a very useful
tool to learn, whether you are using Unreal Engine for creating things like
short films, or maybe creating even some sort of interactive product for
a client, you can still use Blueprint to create tools or interactability. So it is very useful to learn
for all aspects of Unreal Engine. Now in this video, we will be
going over all of the Blueprint basics inside of Unreal Engine 5. I will explain how to create Blueprints,
all of the user interface in the Blueprint editor, What are blueprint
variables and how you can use them. And we'll apply all of the
things we learn by creating these five different blueprints. So we have things like a door
that we can open and close. We have this health and damage boxes. When our character runs into the damage
box, it will decrease their health. If we run back into the health
box, it will heal our character. We have things like this hat
pickup that we can equip. We also have this soccer goal that
we can score and the ball will respawn and just so much more. So this video was designed for
complete beginners with no experience. However, this is the second video in
my Unreal Engine 5 beginner series. So if you don't have Unreal Engine 5
installed, Or if you are a complete beginner with Unreal Engine 5, I
recommend you watch the previous video where I show you how to get started
inside of Unreal Engine 5 as it teaches you the bare basics of the Unreal
Editor and all the basic controls. Now, if you reach to the end of this
video, and if you end up enjoying this free tutorial, you can check out some
of my premium courses on smartpoly. teachable. com. If you are interested in making games
inside of Unreal Engine, luckily for you, I have a complete Multiplayer
survival game course where we create a complete multiplayer survival
game from scratch and we'll be adding more courses in the future. So chances are, if you're watching
this video in the future, you can check out my website, smartpoly. teachable. com to check and see if
there's any new courses. Now, this is the first video in
my blueprint series, so I will be making a follow up video. To this called blueprint
for intermediate users. So this will be the second
blueprint video in the series. And then after that video, I'll
be making a final video called blueprint for advanced users. So make sure you hit that subscribe
button because you don't want to miss out on the followup tutorial. And also I'm trying to hit a
hundred thousand subscribers before the end of the year. And so without further ado,
let's get right into the video. All right, so the first thing that
we're going to do is we're going to create a brand new project for
this video So you want to go ahead and launch unroll engine 5 now i'm
going to be using unroll engine 5. 3 So now we're in the
unreal project browser. So we're going to create a brand new
project I'm going to select the games tab and then i'm going to choose the third
person template Now down here on the bottom for our project defaults, you can
see we have Blueprint or C We're going to talk a little bit more about how Blueprint
and C go hand in hand, and how you can use either one or the other, or even both. Now we're going to leave this as
Blueprint, and we're going to leave all the settings as the defaults except We're
going to make sure that we hit this little checkbox so we include a starter content. Because we're going to use some of
the assets in the starter content. Then for our project name, I'm going
to name this to Blueprint Beginner. Okay, and we'll just click create. Okay, so here we are in the engine. Now we have this new plugins available,
so I'm going to click dismiss on that. That should be all good. So first things first, let's go ahead
and explain what are blueprints. So blueprints are the visual
scripting system of unreligion, and it can be used to create anything. So for example, you can use blueprints
to create full complete games, things like characters, cars, weapons,
user interface, AI, all of that stuff can be created with blueprint. Now, if you aren't going to be creating
games inside of Unreal Engine, blueprints still can be very useful to learn. because you can create
really anything with it. You can create things like tools,
interactive experiences, and so much more. So let's go ahead and
cover a basic blueprint. So this is the third person template,
which is a simple games template. And this is a great template that
explains the basics of blueprint. So since this is a games template, we can
actually click this little play button. So we can click that
little green play icon. And now you can see we have this
third person character in our scene. We can actually move our mouse around. And that will move the camera around
our character, and we also can move our WASD keys to move our character around. You can see that makes
our character run around. And if we press the space
bar on our keyboard... That will make our character jump. So this is a very simple character, and
this is all made entirely with Blueprint. So how does that all work? So if we press escape, that will go
ahead and escape out of the play mode. Let's go ahead and check
out the character Blueprint. So if we go to our content drawer, I'm
actually going to dock this in layout. So click the little dock and layout. Let's go ahead and browse to
that character blueprint that we were just playing in our scene. So if you go to content, we
have this third person folder. So let's double click, open that up. And then in the blueprints, we have that
third person character blueprint class. So in my previous beginner
tutorial, I talked about the different types of assets. So we know that this is a blueprint. Because it says blueprint class here
at the bottom and also every asset inside of Unreal Engine is color coded. So blueprints are color
coded by this dark blue. So this is our third
person character blueprint. Let's go ahead and double
click and open this up. And here we're going to
see the blueprint window. So let's go ahead and take this window
and dock it up here at the top so we can see it here in full screen. Now I'm going to go ahead and explain
everything that we see here because I know there's a lot going on. So let's just go ahead and break it down. So the first three things I'm going
to focus on are these three tabs right here in the center, okay? So first let's go over and
start from left to right. So we'll go over to the viewport. So the viewport is very similar
to the viewport that we have. Inside of our third person map here. So just like the normal viewport,
we can actually use our right mouse button to look around. And we can use our WASD keys
to move around the viewport. So it's very similar to the
regular viewport that we have. You can see we have all of
the basic viewport controls. Things like our move tool, our rotate,
scale, world space, local space. All of our snapping tools, and we can
even change things like the camera speed. Okay, so very important because sometimes
you want to maybe look really closely at the character and inspect it You
can adjust your camera speed now in the viewport itself You notice you can
actually left click on objects So I can actually click on this character
and select it and click on this camera as well And you can see we also have
that gizmo tool So if I press W that will bring up our movement tool so
I can actually move this character around In this viewport, okay? I can also press E, that will
give us a rotation gizmo. I could even rotate our character around. And then when you press R, that will
give me my scale tools, and I could even scale the character however I wanted to. You know, I can make
it super big, whatnot. So we get all the same basic controls. I can do Ctrl Z to undo all
those actions and all that stuff. Okay, so very similar. Now to the right of it, we
have the construction script. So in here, this is essentially a
blueprint graph now inside of here to actually move around you will use your
scroll wheel So you'll scroll in and out To zoom in and out, and then you use
your right mouse button to pan around. Okay, so scroll in and out, and
right mouse button to pan around. Now inside of the construction script,
this is where you'll store blueprint logic that happens before the game starts. And we'll talk more in
depth about that later on. Then to the right of it,
we have this event graph. Now here in the event graph, Similar
to our construction script, we can zoom in and out using our mouse wheel, and
we can also pan around, so same thing. The event graph is basically where you'll
store all of the blueprint logic that will run either when the game starts
or when the game is currently running. And you'll notice that there are already
a couple of different things on here. Now if you look really closely at
these different things, these are simply all of the different blueprints
that allow our character to move. Things like the input events, jump... movement, et cetera. So for example, we have camera input. So this is our input for
moving our mouse around. So basically all that does is
get the input from our mouse. So when I move my mouse,
it will move our camera. Then down below it, we have
things like movement input. So when I press W A S D on my keyboard,
it will move our character around. Then below that, you can
actually see our jump input. So when I press the space bar on our
keyboard, It will call this jump event. And then once I let go of the
keyboard, it will stop jumping. So these are some very simple inputs. And this is everything that we saw. In our third person map. So when I hit play here, the movement
of our camera around our character, the WASD, the spacebar, all of that
is all of this logic right here, okay? Inside of this event graph. Okay, so that is the event graph. So let's go ahead and continue
talking about the user interface. I want to actually go ahead and
head back over to the viewport. Now, in the viewport itself... We're going to start talking about
all the different panels that are on the sides of the viewport, okay? So let's talk about first
this components window. So you can see this window
is called the components. Now what you might already have noticed
is when I select on any of these different things, so if I select on this little
camera right here, or on the character, you're going to notice that we have these
different components being selected. So I select this camera, you can see
it's highlighting the follow camera, because that's what we have selected. If I select the character,
you can see it's selecting the mesh or the character mesh. And this is very similar to, to
the outliner window, where if I select a cube, you can see it has
the cube selected right there. So just like in the blueprint editor,
I can select this character and you can see that is comprised of this mesh. So this is the character mesh. We have things like this capsule. So basically what the capsule does is
sort of like the for the character. We have this arrow. This kind of just shows us which
direction is forward for our character. Then we have this camera boom, which
has this camera attached to it. And what the camera allows us to do
is obviously see our character and the camera boom sort of allows us to
rotate the camera around the character. Okay. So really all this character
blueprint is made of are these different types of components put
together, things like the capsule. The character mesh, and the camera. Now, also when you select
different objects in the viewport, or in the components, you're
gonna notice this window to our right, called the details panel. So similar to the details panel
down here in our main window, it does the same exact thing. So for example, if I select the character
mesh in here, it's going to show various details about that character mesh. So we have things like the transform,
The location, rotation, and scale. So if I were to change things like
the location of our character, if I were to move it back, you can see that
it updates the location right here. So as I move the character, if I scale
it, if I press R, I can scale it. You can see we're updating the scale. I could reset this back to the default,
like so, if I wanted to reset it back. Then below that we have
things like our mesh. So this is the actual character mesh. So you can see we have this. mannequin 3d model. We also have things like materials,
so the materials for our character and then other various details. Okay. Now you're going to notice when we select
different objects in our components or in our viewports, you're going
to see different details depending on the component you have selected. So if I have this camera selected, you
can see it has a name, follow camera, location, rotation, And all that stuff. Okay, so that is the details panel. Now let's head back over to
the event graph and let's start talking about this top bar up here. Okay, so first up we have the save button. So this will go ahead and save
any changes that we've made. So if I were to scale things and move
stuff around, it will save those changes. We have this little browse icon. So if I click on this,
this will browse and find. The blueprint that we're just
in, in our content browser. Okay, so it's a quick
way to navigate to it. So you just click the browse
icon, and we'll pull it up. Now to the right of this,
we have this compile button. Now what the compile button does is,
whenever we make any changes, whether that be to the blueprint logic, or to things
in the viewport, again, if I were to scale things or move stuff around, it's gonna
ask us to compile the blueprint, just to check and see if we have any errors, okay? So right now... It wants us to compile because
it has that yellow question mark. So when I hit the compile, it's
going to look through everything, check and see if there's any errors. If there are errors, it will
tell us, but if there aren't, if everything's good to go, it will
show us that green checkbox, okay? Now to the right of this, this is
for things like version control. So for example, if you were using
something like GitHub, this button would show certain revisions of that. Then to the right of
that, we have this find. magnifying glass. So if you go to your event graph, if
we click on that, find, you're going to see it pulls up this fine results. Now, for example, if I were trying to
find this jump function right here, I could type in jump, press enter. Now we'll go ahead and
find it here on the graph. Okay. So that is the fine button. And then to the right of
it, we have hide unrelated. So that will hide unrelated nodes. We have class settings. So if you click on this, this
will bring up various settings. In our blueprint class. I'm not going to go too in depth
about that, I will explain it later on in the advanced blueprint video. Then we also have class defaults, now
the class defaults are essentially sort of like an all details panel. So basically it sort of shows us
all the details on all the different components in our components list. Okay, so you can see it has things
like our character mesh, the materials. And a lot of other different, uh, details. Okay. Now to the right of that, we have
simulation so we can simulate everything that's going on. And then we have these
play button options. So similar to what we
have here in the viewport. If I were to actually click this
little play button, what it'll do is it'll pop open a window
of our game that we can play. It's just a quick way to go ahead and
play your game without having to go back to the window and clicking play here. Okay, we'll pop open a new window. Now to the right of this, this option
will actually come in handy again later on in an advanced tutorial, but that
is basically the top ribbon, okay? Okay, and so last two things really to
cover are this My Blueprints window, and then this bottom part right here. Okay, because we went over the viewport,
construction script, the event graph, we've gone over components, details. This top ribbon. Let's go ahead and move
on to this blueprint tab. So in this My Blueprint tab, you're
going to see we have this Event Graph. This Event Graph is this Event
Graph window that we have open. So if I double click this, it will
expand out and show us all of the input events that we can see here on our graph. So you can see this Input
Action Jump is right here. Enhanced Input Action Jump, okay? So if I double click it, it
will show it on our graph. So it's kind of just showing us all the
different nodes that we have on our graph. Now if for whatever reason you
accidentally close this event graph, so for example if I click the X right here,
you can always navigate back to it by double clicking this event graph, and that
will go ahead and re add it right here. Now you can see we don't have our
construction script, so to get to that... If you go down here under
the functions, you can see we have our construction script. So we can double click that and that
will bring up our construction script. So if for whatever reason you were
accidentally closing some of these windows, you can get back to them here. You could also additionally go to the
window tab right here and that will list all of the windows that you need. So for example, if I were to accidentally
close this viewport, I can go to window. Okay, now we'll get it back. Now our blueprints tab, we have
the graphs here, so you can even have multiple event graphs. So for example, if I have a lot of logic,
I can actually add an additional graph. And that's why we have that
little plus icon right there. Now functions, we have
the construction script. We're not going to really
cover functions in this video. So we're gonna go ahead
and skip over that. Same thing with macros. And then down below we have variables. So variables are essentially a way
that you can store data in your game. And I will be covering all the
different variable types in this video. But essentially this is where
we're going to be adding them. Now again, event dispatchers, that will
be something for an advanced tutorial. But basically this is our Blueprint tab. Now down below it we
have compiler results. So you can see whenever we actually
compile this third person character, when we click this compile button,
again what it's doing is it's checking to see if there's any errors. In our blueprint if there are
errors that will tell us right here. Okay, so this will come in handy later
on now Let's go ahead and create our very first blueprint So the first thing that
we want to do is we want to go to our event graph So in our event graph again,
the controls are the middle mouse button to scroll in and out So user mouse scroll
wheel and then the right mouse button to move around so we're going to go ahead
and add our first blueprint node inside of this graph and really all that blueprint
is is are a series of nodes and wires. So this input jump, so when I
press space on the keyboard, is hooked up to this jump function. And all this is, is two different
nodes connected by a wire. Okay? And really that's all that blueprint is. Is a series of nodes connected
by a series of different wires. So let's go ahead and create
our very first blueprint node. So we're going to go ahead
and add our very own node. So we want to right click. And whenever you right click on the
event graph, you're going to see that we have this little drop down menu. Okay, and you're going to see it says
here all actions for this blueprint. And you can see there's a
ton of different categories. Okay, you have things like actor. Add event, animation, audio, all
sorts of different stuff, okay? So there's a lot of different
things you can do in Blueprints. Now what we want to do is we want
to search for the Event Begin Play. Okay, so you want to type in here
Event Begin Play, and you can see we have this Add Event, Event Begin Play. So let's go ahead and click on it. Now what this is going to do is it's going
to take us all the way up here at the very top of our Blueprint graph, and it's
going to show us this Event Begin Play. Okay, so this EventBeginPlay is
a node that gets called whenever play begins for this actor. So for example, when I hit this play
button, when our actor is spawned in the level, that's when this
EventBeginPlay is fired off, okay? So this node gets called
whenever we hit this play button. So we're gonna go ahead and actually
take this node, and you can select it by using the left mouse button. So if you select anything... It will be highlighted
in this yellow color. So currently we have this
event begin play selected. And we can disconnect certain wires by
right clicking and doing break this link. Okay, so we're going to disconnect
this event begin play and we're going to take this and move this up here. So this event gets called
when we play the game. Now what we want to do is we want
to print to our screen, hello world. Just a very simple blueprint logic. So off of this event begin play
we can drag off of this pin. And when you drag off this pin, you're
going to notice that it creates this wire. Okay. Now, if I let go of it, you can see
that it pops open our little menu. Okay. The same menu that I can
access if I right click it. Okay. So I'm going to drag off this and drop it. And then in here, we can
actually search for different. Types of nodes now the node
that we want to search for to print something to our screen. It's called a print String so it's
under the development category and it's called print string Let's go ahead
and select that and now you can see that it added this print string node
You can see that basically it prints this string and the current string
says hello Now the execution flow goes from left to right So basically this
white line represents the execution So from the left, the event begin play. This is the first node
that gets fired off. And then this white line with
this pin is the execution. So it flows to the right where it fires
off the next node called the print string. Okay. So if I actually click into there, I can
actually type in this little text box. So I could type a little message in here. I could do a space. Hello world. Okay, and then click enter. I will go ahead and save that. So now we have this event begin play
node That gets fired off when I click this play button and you can see
it's connected by this wire to our print string, which basically should
print hello world to our screen. Now to actually go ahead and
test this out, we need to first compile our blueprint. Okay. Cause we just added these two different
nodes and we plugged them together. So what you're going to notice up here
is on the compile button, it says. It shows this yellow question mark icon. So we need to go ahead and
compile and save our blueprint. That way we can go ahead
and playtest this out. So let's go ahead and
click this compile button. So what that does is it
again runs through our code. So we made these two different changes. by hooking these two nodes together. Then we want to hit the save button. Now we can go ahead
and play test this out. So if I hit play, you're going to see
in the top left we have this hello world message printed to our screen. Okay, so let me do this again
because it disappears very quickly. So if I hit play you can see hello
world is printed to our screen. Okay, so that is a very
simple blueprint setup. We just have this node event begin play. Which is fired off when
the game is played. And then we have this print
string, which prints to our screen, this text, hello world. Now we can even go ahead and
change this text, so if I were to do hello world, and delete this. Instead do, this is a test of
our string, of our print string. We can go ahead and set it like that. Then also, if we hit this little drop
down, this will give us a couple of different options on our print string. We can change things like the
text color, and the duration. What we want to change is the duration. We just want to make this
last a little bit longer. I'm going to click in here
and change this to 10. And basically this will
change it to 10 seconds. Okay? So we can go ahead and hit that up arrow. And hide those settings. And then now that we made those
two different changes, we need to go back into here and click
compile and just save our blueprint. So whenever we make any sort of changes,
we just need to quickly compile and save it, and then we can go ahead
and play test and check this out. So now we have, this is a test of
our print string and you can see that it lasts for a total of 10 seconds. Before it disappears from our screen. So really that is the basics of Blueprint. You have different nodes
connected by wires, okay? That's really all that Blueprint
logic consists of, are just nodes connected by wires. Now really quickly, one thing you might
notice is when I hit play, I can't actually move my character around anymore. And if I press escape to exit out
of there, That's because we unhooked this event beginPlay from our
addInputMapping, which is actually what allows us to control our character. So we don't really need to worry
about that right now, because we're just testing things out. But just a little side note, okay? So now let's go ahead
and talk about variables. Let's go ahead and explain what
are variables, and how we're going to be using variables. In our blueprint. So, first of all, variables are ways that
we can store data inside of blueprint. There are many different types of
variables inside of Unreal Engine. And we will go over all of the main
variables that you will likely be using. And so to create our very first
variable, let's go ahead and click this little plus icon. Okay. So under the variables tab right here,
we can click this little plus icon. And what that does is it adds a
new variable in our variables tab. Okay, so what you can see here is it
added this new var that's the name of the variable and then it added the
variable type Which is called boolean. Okay, and it's color coded by this red
color Okay So all of the variables are going to be color coded and as time
goes on you will be more familiar with all the different colors and variable
types now for this boolean we're going to go ahead and just Select this
text right here and rename this to is dead question mark and press enter. And this is our boolean variable. So what a boolean variable is, is once
you have this variable selected in the details panel, you're going to notice we
have some details about this variable. So you can see things like the name. So if you wanted to change
the name, you can come in here and delete this, rename it. And then down below here, we can see
the variable type, which is a boolean. If you actually click this drop down,
there are more different variable types. We'll get into in a second. But then here at the very bottom, you
can see we have this default value. Please compile the blueprint. In order to set the value of
this variable, it's asking us to compile the blueprint first. So let's go ahead and do that. So we want to go up here
to the compile button. Hit the compile and now you can see
we have this default value is dead question mark, and then we have this
little checkbox Okay, so basically what a boolean is is a true or false
statement So right now if I hover over this checkbox, you can see it's
false It's set to false if I click on it, it will add a little checkbox. And now you can see it's set to
true Okay, so all a boolean is is a true or false statement. So is dead is our character dead? Question mark false Now if
I hit this checkbox, our is dead boolean is set to true. Okay, so that's all that a boolean
is, a true or false statement. Or this little checkbox where
you can set it to true or false. Okay, now to actually use this
variable, what you can do is you can actually drag it onto your graph. Okay, so for example, if I were
to take this is dead boolean. I can actually select it and drag
it, and then you can see I can actually drop it onto our event
graph or our blueprint graph. And we have these two different options. So first we have getIsDead,
and then we have setIsDead. So basically we can get
the isDead variable. Let's go ahead and do that first. So if I click on that... You can now see that we
have this is dead variable. It's color coded in red to represent
our Boolean and the default value is currently set to true. So let's go ahead and take our event,
begin play and our print string. And as you can see, if I left click
and hold it down, you can see I can select multiple different nodes. Let's go ahead and select all
three of these nodes and just move it up a little bit further. And. Just recenter our
blueprint graph right here. So let's go ahead and actually
unhook our print string. So we can either right click
this and you break this link. Or you can use the hotkey by
pressing alt on your keyboard. So hold down the alt key and left click. That will go ahead and break that link. So I'm going to go ahead
and move this over. So use this is dead boolean. Which is a true or false statement. So off of this is dead, you can
see that it also creates a wire. So I can drag off this pin. And you can see we have that menu again. So what we want to add is called a branch. So type in branch and
select it right here. So this is the branch right here. And this is going to add this branch,
which has a couple of different pins and is hooked up to this is dead Boolean. Okay. And it's hooked up to this condition. So basically what the branch
does is it checks this Boolean. You can see that it's hooked
up and that is the condition. So depending on this Boolean, if it's
set to true or false, if it's set to true, this true will get called. If it's set to false, this
false will get called. So what we want to do is hook up
this true to our print string. And then in the string here, we can
go ahead and select this and delete this and type in character is dead. Okay. So if this is dead is set to true,
we're going to call this print string that will print to our screen. That the character is dead, okay? Then we're going to go ahead and
move this up and copy this node. So copy our print string,
so you can select it. Ctrl C, Ctrl V. We'll have another node. Or you can right click and
add another print string. Either way will work. And then we want to hook
this up for the false. Now we want to go ahead and
change this text in here. And we're going to name this
to character is not dead, okay? So if this boolean is set to false,
like this, if this is unchecked, then it will check this boolean. If it's set to false, it
will call this print string. Character is not dead. Okay. So depending on this value,
whether it's set to true or false, either one will get called. The character is dead or
the character is not dead. Now, all we have to do to see this in
action is hook this up to our event. Begin play. So hook up the pin like so and then
hit our compile and save so now if I hit play What this is going to do is
it's going to check this variable this boolean variable is it's going to check
and see the default value whether it's set to true or false and Based on if
it's set to true it will print the character is dead If it is set to false,
it will print the character is not dead. Okay, so currently it's set to false. So if I hover over it, you can say false. It's not checked. So if I hit play, it should
print character is not dead. Okay, now if I close out of this and
select this variable, or is dead variable, and in the default value, I hit that
little checkbox, set that to true. Now what we should see
is the character is dead. So I hit this little compile,
you always want to compile. Hit save and then if I hit
the play button, you're gonna see that it's printing off. The character is dead Okay So really all
a boolean is is a true or false statement and then hooked up to a branch node all
of the branch node Does is it checks against that boolean variable to see if
it's true or false and whether or not it's true or false It will execute the
node that's hooked up to the true or the node that's hooked up to the false
depending on what we set this variable to. Okay. So that is the Boolean variable. Let's go ahead and talk about some of
the other different variable types. So let's go ahead and
add our second variable. So under the variables tab, let's
click this little plus icon. And you can see that it added again, new
variable, and it's of this Boolean type. Okay. So we want to go ahead and click
on this drop down and we can either change the variable type by hitting. This little drop down menu right here
or we can select the variable and over here on the details panel We can also
hit this little drop down and change the variable type Okay, so we're gonna go
down the list and we're actually gonna skip over the byte We're only gonna
cover over the common variable types. So first we covered Boolean. The next thing we're to cover
is integer So let's go ahead and select the integer variable type. Let's go ahead and rename
this variable name. So we can go ahead and
select the variable name. And rename this to myInteger. Okay. So compile, save. So really all an integer
is, is a numerical value. So in the default value
it's showing myInteger. And you can see we have this as zero. Okay. So if I click in here, I can actually
set this to any number, so I can set this to 1, 25, 9, 999, I can set it
even further, 10, 000, basically I can set this to any whole number, so that
means I can set it to any number as long as it's a whole number, so I can
do 45, 90, 54, what a integer is not, It's not a decimal, so I can't do 54. 55, you can see that it won't
let us type in 01, it won't let us type in any decimal number. So really all an integer
is, is a whole number, okay? So you could use integers for keeping
track of things like levels, so my character could be level 1, level 44. You could use this to store
any numerical value, okay? So just like our boolean, Any
variable can be fetched here on the graph, so I could take my
integer, drag it here on the graph. You can see we have those two
options, we have the get and the set. So let's go ahead and get my integer. And now you can see we can
get that value of my integer. And what we're gonna do is, let's go ahead
and actually delete all of this up here. So, to delete stuff on your event
graph, you left click and select. I'm just gonna select this
boolean and click delete. Or you can click on it and click delete. I'm going to delete everything
other than one of these print strings and the myInteger variable. So we can actually print off
the value of our integer if we hook it up to this print string. So one thing you may notice by now
is that we have different color codes for different variables. And you see this is an
integer and this is a string. So you can see they're represented
by these two different colors. Now how do we actually convert an integer? Number into a string which is this text? So if you actually drag off this pin, you
can see it creates sort of this green wire If I drop it on this you can see it says
convert integer to string So if I drop it on there, you can see it automatically
It takes this green Integer value and converts it to this pink string value. So now we should be able to print this,
the value of our integer to our screen. So let's go ahead and hook this
up to our event begin play node. Okay. So now what it should do is it
should print the value of my integer, which is set to 44. So if I hit compile, save, hit
play, you can see it prints 44. Okay. So that's basically an integer. It's just a whole number value. So let's go ahead and delete
that, compile, save that. Let's create another variable, and
let's just keep going down the list. So let's add a new variable, and
this one will be called myFloat. Now I want to change this
from an integer to a float. So we have the isDead boolean,
myInteger, integer variable. And the myFloat. Float variable so with this selected we
can go over to the details and you're going to see that it says please compile
the blueprint To set the default value. So let's go ahead and compile real quick. And now we can see the my float variable
default value So in here you can see 0. 0. So basically what a float is,
is a decimal value number. So what that means is I can type in 1. 5, 1. 99, 0. 01, 99. 99. And basically it can be any decimal value. It can even be a whole number like one. And what the float is useful
for is for things like health. Or percentages, okay? Where you might need
that decimal point, okay? Because unlike the integer, the
integer can only do whole numbers, it can't be decimal points. Whereas the float variable can allow
us to do things like type in 1. 5, okay? Compile, save that. Same thing with all the other variables. We can actually drag it
and get it on our graph. Click the get my float. And we can even print it to our screen
by just dragging and dropping it. On the onString, you can see that it
automatically converts it to a string. We hit the compile and save button
and hit play, and it will print off the value of our float, which is 1. 5. Okay, so that is the float
variable used for any, you know, decimal points or decimal numbers. Let's go ahead and continue down
the list, add a new variable, and this one will be called myString. And we're going to change this
from a float to a string variable. So let's go ahead and compile this. And now in the default value you
can see we have this text entry box. So the string is essentially the
same thing that we have here. Or we can type in any sort of text. Hello world. We can use exclamation mark. Bunch of random numbers. You can pretty much type in anything
you want into the string, okay? So it's a series of letters,
numbers, characters, whatnot. So if I hit compile, save, we can again
get this onto our graph by dragging and dropping it and clicking get. And you can see it's the same
color as a string because it's the same variable type. So I can just drag it onto there and
it doesn't need to convert anything. So now if I hit compile and
save, it's going to print off the default value of my string, which
is hello world exclamation mark. A bunch of random numbers and
a bunch of random letters. So if I hit play, you can see
that it printed out our stream. Okay. Now, one thing to note is you can
actually hit play from here, or you can actually go back into the third
person map and click play right here. So either way you can
test out your blueprint. By hitting play through here,
or play on the third person map. Okay, so that is basically
the string variable. It's just a string of random
letters, numbers, or characters. Okay, let's go ahead and delete
that and add our next variable. Which is going to be called myVector. Okay. And hit this little drop down,
you can see we cover the boolean, integer, the float, we skipped over
the name, and we covered the string. Some of these other variables I will
cover later on in future videos. But right after the string we
have text, which is basically similar to the string, but this
is mainly used for things like UI. But below that we're going
to add this vector, okay? So, select the vector,
which is this yellow color. And now you can see my vector is
set to the vector variable type. So what is a vector? So if I hit compile, you can
see in the default value we have this myVector, and basically it
is three of these float values. Okay, 0. 0, this is a float. So if you go back to your float, if we
set this to 0, you can see it's set to 0. 0. So this is a float, and if you select
the vector, you can see that the vector consists of three different floats. Okay, so a vector is simply three
different floats now vectors are used in all sorts of games for 3d
spaces So for example, if I go to my viewport and if I select my character
under the transform You're gonna notice that we have this location. So in a location we have these
three different values and this is essentially a vector Okay, we have the
location on the X Y and Z and these three different values that basically
determine the location of the character. This is essentially what a vector is
Okay, so we go back to our event graph and select our vector In here, we could set
this to again a bunch of random numbers. We do like 0. 01 99. 5 and 44. 3 So you could set it to a bunch of
random numbers and again, it's just three different floats Okay, so what you'd
use a vector for is You could use it for storing things like the player's location. So, for example, if I wanted to store the
location of our character in the world, I could get things like the location
and store it in this myVector variable. And let's actually go ahead and do that. So to do this, we're actually going
to unhook this EventBeginPlay. So unhook this, and we're
going to re hook this back up. To our add input mapping, let's
go ahead and take this and move this down back to our add input
mapping and hook this back up. That way, if we compile, save
and hit play, we should be able to run our character around. Okay, so that's all good. Now let's go ahead and play
around with our vector. Okay, so basically we're going to set
up a very simple node so that when I press a key on my keyboard, it will
get our player's location and we'll set this my vector to our player's location. So we want to right click on a graph
and we're going to get a input key. That way, when I press say the R key on
my keyboard, it will go ahead and do this. So if I type in R key, I want to scroll
down till you see keyboard events. You can see all the different
keys and we should have a key for the R key on our keyboard. So you can see we have R. So go ahead and select that. Now you can see when we
press it, we have this pin. Okay, so what we want to do is we
want to first get our location, and then set it to this variable. So first things first, let's go
ahead and actually get our location. So we want to right click, and
we're going to search for the node called Get Actor Location. So it's called Get Actor Location. So go ahead and select this
one down here at the bottom. And you can see we have this node. Where it gets the location and it returns
this yellow return value, which is, if you hover over it, it says a vector. Okay, so now we're getting
the location of our player. So now we just need to set it, or
set this variable, to that location. So to set a variable, you want
to drag this onto the graph. And we have those two different
options, we can get it or set it. So instead of getting the variable,
we want to go ahead and do set. So we can do set. And now what you're going to see
is we can actually set the variable value so I can take this return
value and plug it into my vector. And now we are setting the
value rather than getting it. So now if I hook this up to
our pressed, we are now setting the, my vector, the values here. To our characters location now to
actually see this happen in real time What we're gonna do is take our print
string plug in the plug in the execution pin like so Okay, and then we're gonna
hook up this my vector value into this end string Okay So now it should
convert our vector to a string and it should print our my vector value which
is our player location To our screen. So we just have to hit compile
save Hit play now if I press that key which we have it set to the
R key I press R on my keyboard. You can see that it prints out the
location of our character So if I move around and keep clicking it, you
can see that it prints the location of our character So if I run over
here, you can see that it prints the X Y and Z, which is the my vector
value Okay, so it's that variable. We're getting our players location
We're setting the myVector variable and then we're printing it to our screen. So again, vectors can be very
useful for storing things like the player's location and all that stuff. So that is the vector variable type. Now let's go ahead and add
another variable type here. This one will be called myRotator. And we're going to change
this from a vector... Now the rotator, let's go ahead and first
compile this, is, you're going to see that it's very similar to this vector. But you can see that it
says different color. Okay? So a good example of this rotator,
is if you go to your viewport and select the character, you can see
we have the location, which is a vector, and we have this rotation. So basically this is a rotator. Okay, so again, these are decimal points,
but basically they are rotation values. Okay, so I can rotate this negative 90
on the x axis You can see it rotates our character if I set this back to
zero who rotates it back Basically a rotator is three different floats for
the rotation Okay, so very similar to vector where we have these three
different float values, but rather than a location it's storing a rotation. Okay, so that is the rotator. Let's go ahead and move
on to the last variable. So add a new variable and
this is called my transform. So now we're going to change this
from a rotator to a transformation or a transform variable. So hit that and it's
this little orange color. So now if I hit compile and
save, you can see we have this default value my transform. So if I hit this little drop
down, You can see that we have these three different values. We have the location, rotation, and scale. So really all this consists
of are vectors and rotators. Okay, we have the location, which is a
vector, rotation, which is a rotator, and then again another vector for our scale. So this variable type is very similar
to what we have in our viewport. Again, when we select our character,
you can see that this is a transform. So it's a collection of a
location, rotation, and scale. So that's essentially what
a transform variable is. Just a location,
rotation, and scale, okay? So this is useful for storing all
three of these values, vectors or two vectors in a rotator. Again, this can be useful for
storing things like the player's location, rotation, or scale. So those are all the basic variable types. We went over booleans, which
are true or false statements. They can either be set to true or false,
whether you hit that checkbox or not. We have integers, which are whole numbers. We have floats, which are decimal numbers. We have strings, which are just a bunch
of random characters, numbers, or letters. Vectors, which are three different floats. You can use this for player locations. Rotator, which are rotation values, and
then a transform, which is a combination of vectors and rotators, things like
the location, rotation, and scale, okay? Now, we've primarily gone over how to get
variables on the graph, so again, we can drag all these variables, and you can see
we have those two options, we can get it. Or is dead or my integer, my
float, my string, my vector, my rotator, and then my transform. Okay. So we have all those different
variables that we just covered over. Now let's go ahead and actually
talk a little bit more about setting the variable so we can actually
set any of these variables just like we are getting them here. So if I drag, this is dead, I can,
instead of viewing the git, I can do set. So I can set. The value of our is dead. And now you can see we have this little
check box so I can set it through here. I can set it to true or
I can set it to false. Now this is very useful because you
can build out logic by this, by setting these variables rather than just
sending it here in this default value. Okay. Because as you saw with this key, when I
press this key, we're getting our player's location and we're setting this vector. Value to our players location. Okay, so that is the set for boolean
We can also set our integer by clicking set you can set the value You can set
the value of our float by clicking the set float We can set our string
by doing the set string you can type in there a random string And we can
also do things like set our vector set our rotator and then finally set our
transform Okay So I can go ahead and select all of these, move them up here,
so now we can see all of the different... Variable types that we went over. So basically the get the variables
and then setting those variables. Okay? So let's go ahead and move on to the next
part of this video where we're going to use the information that we've learned
All the different variable types and we're going to create a very simple door
Blueprint that we can open or close when our character runs up to this door Okay
Let's go ahead and go to our third person map and go to our content browser over
here now back in Out of this folder, I'm going to go back to our content folder. So let's go ahead and create a new folder. So right click anywhere in your content
browser and select this new folder. And we're going to name
this to Blueprints. And then inside of this Blueprints
folder, let's double click and open it up. And we're going to right
click, create another folder. And we'll name this to 01
underscore door blueprint. Just so we keep everything organized. And then let's go ahead
and go into that folder. So double click open that up and we're
going to create our door blueprint inside of here So to create a brand new blueprint
you want to right click and under the create basic asset We have this blueprint
class Okay So we can select that and it's going to give us this pick a parent
class now Let's actually talk about the different Blueprint classes here. I'm going to cover the most common types
of blueprint classes So the most common type are the ones that we see here and
the first one is called an actor So an actor is an object that can be placed
or spawn in the world So really you can use this for things like doors that
you can open up Interactable objects any sort of blueprint tool really this
blueprint actor is a generic sort of class Okay, now you have a more specific
class a pawn So this is a blueprint class that can be possessed or receive
input from a controller or a player. So you could use this for creating
things like vehicles, cars, even things like NPCs actually. And then you also below
it have a character. So this is a character blueprint. So a character is a type of pawn that
includes the ability to walk around. So this is what our third person character
was made of, this character blueprint. Okay, below that you
have a player controller. A player controller is an actor
responsible for controlling a pawn used by the player. Okay, and then below that we have a
couple of other different blueprint classes I'm not going to cover over what
some of these other things do in this particular video I'll probably cover
over them in the advanced blueprint video, but these are basically all of
the common Blueprint classes now there are additional classes So if you hit
this drop down you can see all classes and if you scroll through here You can
see there are a lot more different types of blueprint classes Okay, so what we
want to choose is we want to choose this actor For our door, because this actor
can be placed or spawned in the world. And this is exactly what we want. So we're gonna go ahead
and select this actor. That's going to add our blueprint
class or blueprint actor right here. Okay, so let's go ahead
and give this name. We're gonna name this
to BP underscore door. So whenever you're naming blueprints,
you want to have BP and then underscore. And then the name of the blueprint. Okay, just so we know
that this is a blueprint. You can do a file, save all. And let's go ahead and double
click and open this up. Let's go ahead and take this window
and dock it up here at the top. And the first thing that we can
see is our viewport in here. So let's go ahead and add our door mesh. So the door frame and then the
actual door that will open and close. So the way that we add stuff
in our viewport here is through the components tab. So in here you can see we
have this add plus icon. So I click on that. It will have a drop down of different
types of assets that we can add inside of our blueprint now We want
to add a mesh or a static mesh. So let's go ahead and select this static
mesh component Okay, so if I select that I'll add a static mesh component and
we can rename this to our door frame Now with this selected, in the details,
we can set the static mesh right here. So if you hit this little drop down, we
should be able to find a door frame mesh. Or we can even open up our content
drawer, right here at the bottom. So if you hit this, this will pop it open. And we should have starter
content inside of here, okay? If you forgot to enable starter content... You can always come back
and add this later on. And the way that you would do that is
you just come over here to this add plus icon, click on it and click add feature or
content pack and head over to the content and add to project this starter content. Okay. So in our starter content folder,
let's double click, open that up. We want to look for props. So open up the props folder. We have this door frame,
static mesh door frame. So we can drag and drop
this into our static mesh. Component and it will set our door
frame to that doorframe static mesh. Okay. So now if we scroll out here,
we can see the actual doorframe. Now we just want to add a
door inside of our doorframe. So again, we just go ahead and
select our doorframe here, click add and add another static mesh. So right now, if we hover over the static
mesh, you can see it's says SM doorframe. So if I click on this, what I'll
actually do is I'll add another static mesh named doorframe. Let's go ahead and
rename this right click. Rename and we'll rename this to door. Now let's go ahead and
change this door right now. It's a door frame. Let's actually change it to our door. So hit those dropdown and you can
see we have our static mesh door. So let's select that. Now you could see we have
this door and the door frame. So let's select our door and
right now it's off centered. So let's go ahead and move it over. So if you press W on the keyboard that
will give us a little move gizmo and we can move this back into the door frame. Now you can see it doesn't let us snap it. Exactly where we want it so we can
actually turn off the grid snapping So let's uncheck grid snapping
there and now we should be able to position it And line it up perfectly. Okay. So that should work. Let's go ahead and compile save that. Now what we want to do is we want
to add a collision box so that when the player overlaps with it, we
can go ahead and open up the door. Okay. So in our components, before we add it,
an important thing to note is, whatever you have selected in here, that is
where the component will be added to. So for example, if I select my door,
right here, my door static mesh component, If I click add, let's go
ahead and add that collision box. So if you scroll down, we should
have collision box collision. Okay. So let's select that. You can see that it added
this box onto our door. So if I select my door, Now if I press
E to rotate it, you can see that the box is attached to our door, and whenever I
rotate the door, the box rotates with it. Okay, I actually don't want it
to rotate with it, so I'm going to take this box and drag it and
drop it on the default scene root. And you can see we have two
different options, we can do attach, which is what we're going to do. And what that will do
is it will take it... From being below the door to being
out here in the default scene root. So now if I were to take the door and
rotate it, press E, rotate it, you can see that it doesn't move with the door. So it's important where you add components
because depending on the hierarchy of where you add it, it will either affect
things like the rotation or scaling. Okay, so just keep that in mind. So now we have our door frame,
our door, and our collision box. Let's actually reshape
this or scale this up. So if we press R, Let's go ahead and
scale this like so, scale this up in the Z and then press W to move this up. I'm actually going to scale this
a little bit down and basically have it sort of like this. Actually scale this a little bit
more wider so that our player can run up to the door right here. And once they overlap with this box,
we'll be able to press a key on our keyboard to open or close the door. So now if we hit compile and save,
let's head over to our event graph to actually add the blueprint logic. For opening or closing the door. So in here we have some
pre existing nodes. The event begin play and
some other different nodes. And we can actually go
ahead and just delete these. So just select and delete them. Compile, save. And what we want to add is,
whenever our character overlaps with this collision box. We want to go ahead and enable inputs. So that the player can press
a key on their keyboard. To open or close the door. So with this collision box
selected in the details panel, if we scroll all the way down. You're going to notice
we have this events. Okay, so this events category shows
us different events that we can track. So in our case, we want to use this
event on component to begin overlap. So when our character begins
overlapping, so we want to go ahead and click this plus icon. Okay, and what that will do is we'll add. onComponentBeginOverlap for our box. So basically when something overlaps
our collision box, right here, this event will get fired off. Now what we want to do is we want to check
and see if Whatever overlaps this box. Is it our character? Okay, and the way that we're gonna do
that is we're gonna use this other actor Okay, because our character is an actor. It's not a component Components are like
these different components over here. Our character blueprint is an actor
So we're gonna use this other actor to check and see if it's our character. So off of here We're going to use the node
called cast to Third person character. So we have this cast to third person
character and go ahead and select that. Now we'll go ahead and plug
that in for us already. And basically what this node does
is it checks and sees if this actor that overlaps this box, is
it our third person character? Okay. Or our character blueprint if it is
this will be fired off if it is not it will call this cast failed Okay, so what
we want to do is we want to go ahead and enable input for our character So
the way that we'll do that is we're gonna right click and call the node
get player Controller and down here. We should have get player controller
So let's go ahead and select that and then off of this return value. We're going to drag off of here And drop
it on the graph and type in enable input. So we have this inputs enable input node. So I'll select that and we actually
want to unhook this target. So click alt and unhook that and
take the return value and plug this into the player controller. So we want this get player controller
plugged in to the player controller. So then if. Our character overlaps with this box. If it is actually our third person
character, we're going to take this pin and plug it into our enable input node. So now we just want to
add our end overlap. So basically if our character leaves
this box, we want to disable input. So in our event graph, you
want to select the box. And in the events, we also
have an event end overlap. So let's click the little
plus icon right there. I will go ahead and add a event and
overlap similar to this event up here. So again, the same thing we want
to take off of our other actor and check and see if it's our
character that is leaving the box. So we're going to do a cast
to third person character and go ahead and select that. And then we're going to use the same
thing that we have up here, but instead we're actually going to disable input. So off of this return value. We can do a Disable Input,
so Input, Disable Input. In this case, we're going to have this
return value plugged into the target rather than the player controller. So if we end overlap with our box, if
it is our character that is leaving that box, we want to go ahead and
plug this into our Disable Input. So when we overlap with
the box, Enable Input. When we end overlap with the box
or leave the box, Disable Input. Now we have to add our Input Key. That will... Open or close a door. So down below this we're going to right
click and type in the E key So if you scroll down we should have our keyboard
events and we should have our E key So let's go ahead and select that. So when I press E on my keyboard, we're
gonna open or close the door So to do that, we're going to use the flip
flop node so we have flow control flip flop and basically what this does is
When I press this, it will call A. When I press this again, it will call B. Okay, so we'll just flip, flop back
and forth the two execution pins. So now we just need to take
this door mesh and rotate it basically 90 degrees like this. to open it or 90 degrees back to close it. So the way that we'll do that is in the
event graph, we're going to take this door component, and you can actually drag
any of these components onto the graph. So if I want to get a reference
to this door component, I can just take it and drag it on the
graph, and we can get it, okay? And now what I want to do is I want
to set this rotation to basically 90 degrees, so I can open it up. So if I drag off here,
I can do a set rotation. And we have this Set
Relative Rotation node. Okay, so I'm going to go
ahead and select that. And now we can hook this up to the A. And then for the rotation we
can specify a rotation value. Now we want to rotate this 90 degrees. So if I press E, you can see on the Z
axis, or this blue rotator gizmo, we want to rotate it 90 degrees like that. So we know we want to type in 90 for
the Z right here, so type in 90 degrees. Now to reset this back, we want to get our
door mesh and do a set relative rotation. So transformation, set relative
rotation, and hook this up for the B. And instead of rotating it 90 degrees,
we're rotating it or resetting it back to the default value, which is 0. So if we press E, it will rotate
it 90 degrees to open it up. If we press E again, it will
set it back to zero, or back to the closed position, okay? So now we should be able to test this
out, so let's hit compile and save. And let's go ahead and drag
this blueprint into our scene. So if we go back to our third person
map, let's take our door blueprint and drag it out into our level. And now we should be
able to playtest this. So let's hit play, and if I actually go
ahead and run up to this door, I press E. You can see that it now opens up, and
if I press E again, it will close, okay? Now one thing that you might notice is... This door mesh actually doesn't
have any collision on it. See, I can walk straight through the door. Now that actually has to do
with the collision on the mesh. And currently there really isn't
any collision on this door. So let's go ahead and fix that real quick. So whenever you're playing around with
collisions, you always want to go... To that mesh that's having issues. So in our case, I'm going
to dock this in layout. And I'm going to go to
our starter contents. Props, because that's where
our door mesh is stored. And I'm going to open up
that static mesh door prop. So double click, open that up. This will bring up the static mesh editor. To actually show the collision,
you can go over here to show. And do simple collision. And as you can see, there's
no collision on this mesh. So to add a very simple collision, we
can go up to this collision button. And you can see down here, the
third option, we're going to choose this add box simplified collision. So now what that will do is it will
add this simple box around our door. That will act as a very
simple collision box. So let's hit save, and now if
we head back to our third person map, we can go ahead and hit play. And if I run up to the door, you can
see that we can't move through it. But now if I press E... We can open it up. If I press E again, that will close it. Okay, so very simple collision setting. Now, I actually want to go ahead
and modify this door blueprint because I don't really like the
way that it snaps open instantly. Let's go ahead and modify it so
that it rotates nice and smooth and opens naturally like how a
door would rotate on a hinge. So let's go back to our blueprint door. So over here, when we press E, instead
of setting the relative rotation, let's actually go ahead and unhook this. So press Alt and unhook both of that. Let's go ahead and take
this and move this over. So to add that smooth... Rotation, we're going to add
what's called a Timeline Node. So right click on the graph
and search for Timeline. And we should have at the
very bottom, Add Timeline. Okay, so let's go ahead and select that. Now for this Timeline, it's
going to ask us to name it. So let's just go ahead and
name this Door Rotate Timeline. Like so. And you can see we have a lot
of different pins in here. So we have play, play
from start, stop, reverse. So in here, let's actually
double click and open this up. You can actually open up the node. So double click will open
up the actual timeline. And in here we can add a track. So I'm going to hit this add a track. And we want to add a float track, okay? So let's click on that. Now what this will add
is an actual timeline. So basically you have sort of like
a graph and the way that this works is I'm going to right click on this
graph and I'm going to add a key. Okay, so I'm going to
add key to curve float. So click on that and you can see this
key that we currently have selected has two different values, a time and a value. So I'm going to set this
to zero for the time. And then zero for the value, and
that will put our key at zero zero. Now anywhere else in the graph, I'm
going to right click and add another key. So add key to curve float, and with this
selected we can set the time and value. Okay, for this time I
want to set this to two. Or two seconds, and then for the
value I want to set this to ninety. Or ninety degrees. So now we can't see where that point went. So to focus it in, what you want to
do is hit the zoom to fit horizontal. Zoom to fit vertical. And now we can see those
two different points. Okay? So we have a 0, 0. And we have a 2, 90. Okay? So basically, the x axis
on here is the time. So this starts at 0 seconds
all the way up to 2 seconds. And then the value up here
on the y is our degrees. So let's go ahead and we actually want to
adjust the length of this timeline cause After two seconds, it still continues on. So the length is right here. Let's actually change this
from five down to two. So now we can see that at time zero, our
value is zero, but as time goes on, the value goes up from 30, 40, 50, 60, 70,
80, all the way up to 90 at two seconds. So that will give us that smooth value. Now let's actually take and
select both of these points. So if you do shift, select and drag. We're going to right click and add a
auto, so add auto, that will add this smooth curve to those two points. And what that will do is that when our
time is zero, the value will slowly go all the way up to 90 and it will give us
this really smooth result or transition. So now if I head back to the
event graph, you can see on our timeline we have this new output. This new track is zero float value. So what we're going to use is we're going
to use this to modify the rotation of our door, because when this timeline is
playing, it will output that rotation value, which will rotate our door for us. So we're actually going to delete
this relative rotation node down here. We just need one of them. We're going to plug the updates. Into this set relative rotation and
then for our float, the way that we're going to update just the Z value is
we're going to take off of this rotation and we're going to do a make rotator. So select this make rotator and if
you remember earlier in the video. A rotator is just three
different floats, okay? So to make a rotator, we're going
to have a X, Y, and Z float. And basically we're going to take
our new track and just plug it into the Z, because that's the
only axis that we want to rotate. So now we should be able to
hook this up to our timeline. So for our flip flop, we're actually
going to plug this A into the play from start and for our B, what we're
going to do is reverse this from end. Okay. And so now what we should see is
when I press E, this timeline will be fired off and it will output a
value of zero, zero at zero time. And that here at 0. 5 seconds, it'll be 12. And then here at one second,
the value will be 40. And so it will give us this nice,
smooth rotation to rotate our door open. So now let's hit compile
and save and play test this. Let's head over to our third person map. If we hit play, let's run
up to the door and press E. Now you can see that it
rotates nice and smooth. Now press E again. You can see that it rotates
back to being closed, okay? Because it's playing from the start. Now press E, it's reversing from the end. So now we have our very
simple door blueprint. That open and closes and has
this nice smooth rotation. So that is our very simple door blueprint. We covered over how to add different
components and then how we can program those components to have functionality
by using things like overlap events. Okay, so let's go ahead
and close out of these. Let's go back to our third person
map into our content drawer. When I dock this in our layout. And I'm going to head back
to our blueprints folder. Now, the next thing that we're going
to create is a hat pickup item. So basically when our character runs up
to this pickup, if we press E, it's going to equip a hat to our player's head. So for this, we're actually going to
need to import some project files. So you want to go ahead and head
over to the description of this video and download the free project files. I'll have a link to it
in the description below. And basically you should have this
blueprint beginner dot zip file. So you just want to right click and
do extract all and click extract. I'll go ahead and extract
the contents of the file. And in here we just have a
couple of different files, this static mesh ball hat. Uh, soccer goal and all that stuff. So let's go back to our
Blueprint Beginner Project. And if I go back to the content
folder, I'm going to right click and create a new folder in here. I'm just going to name
this to Project Files. Double click, open that up. And then with our Blueprint Beginner
folder open, We can just select all of the files inside of there and drag and
drop it into our project files folder. It's going to ask us
some FBX import options. Now I'm going to leave this
all as the defaults and I'm just going to click import all. Okay, so now it should import everything. We're going to get this message log. No smoothing group information was found. We can go ahead and just ignore this
so you can just click the X on that. We don't have to worry about that. But now you can see that we have
all of these new assets imported. Into our project files folder. So first of all, let's
go ahead and save this. So let's do a file, save all. And now that should be all saved. And now we can start working
on our hat pick up, okay? Because we have this hat mesh. So I'm going to head over
to our blueprints folder. And in here I'm going to right
click and create a new folder. And this will be called 02
underscore hat pick up blueprint. Okay, so double click open that up. And we're going to right click
and add a new blueprint class. of the type actor. So I'm going to select
the actor blueprint. Then I'm going to rename this
to our BP underscore hat pickup. Okay? And then just double
click and open that up. Let's take this window and
dock it up here at the top. And so in here this is
going to be our hat pickup. So first of all let's go
ahead and add our hat mesh. So in the components, let's go
ahead and click this drop down and add a static mesh component. And we can just rename
this to our hat mesh. And with that selected, in the details
panel we can change the static mesh. Hit this drop down and search
for our sm underscore hat mesh. Okay, so our static mesh. So now we have our hat mesh. And now we just want to do the same
thing that we did in our door blueprint. We added a collision box, but in our
case, I'm going to add a collision sphere. Okay, so it can go under the add
components, scroll all the way down and we should have collision sphere collision. Okay, so I'm going to select that. So it gives us sort of this
sphere collision around our hat. I'm going to go ahead and scale this up. So I press R. Go ahead and scale that up. Okay, something like that. Then compile, save that. And then we could even also add a text
so that we know which key to pick up. So if you select in the add
components, we can search for text and we have this text render. Select that. And you can see it adds sort of this
text component, so I can actually take this and rotate it, so if I
press E I can rotate this 90 degrees. So in the details we can actually
rename the text, so in this little text box here we can rename this to press
and then in brackets E to pick up. And let's actually scale
this down a little bit. And we can actually center this, so under
the alignment we can set this to center. So we can align that in the center
there, just move this up like so. Okay, so that should be good. Compile, save that. So now we just need to add the logic for
our character to actually pick this up. So let's head over to the event graph. So again, we have our event be
in play and other events in here. So we can just select and delete these. Compile, save. We just want to add the event
overlaps for our collision sphere. So select it. And in the details, let's scroll all
the way down so we see those events. So we have the event begin overlap. Let's add a event for that. And I'm going to select the sphere
and add a event end overlap. Okay. So now we should be able to set this up. So again, we're going to check
and see if whatever overlaps this, is it our character? So off of the other actor, we're going to
do that cast to third person character. And then we're going to right click
and get our Git Player Controller. So we should have Game,
Git Player Controller. And off of this return value,
we can call that Enable Input. Select that. And again, we're going to
unhook this from the target. And hook up our return value
to the Player Controller. Okay, so make sure that this is hooked up
into Player Controller rather than Target. So let's hook up our execution pin. So if this is our character,
we'll enable input. Then, if we overlap with the sphere,
we want to do the opposite, so we want to do cast to third person
character, and disable our input. So off of our player controller,
we can call that disable input. Okay, and then just plug in the execution. Okay, so compile, save that. Now, we want to add the E key. So, actually up here we're going
to add it, so right click E key, scroll all the way down,
should have our E key right here. Now when we press the E Key,
what we wanna do is we want to attach a hat to our character. So basically you wanna sort
of pick up this hat and attach it to our character's head. So the way that we're gonna do that is
we're going to actually create an event inside of our third person character
blueprint that will go ahead and attach that hat to our character's head. So you wanna open up your third person
character, and that is in our content. Third person blueprints open up your
third person blueprint character head over to the event graph maybe down
here at the bottom We're gonna add that hat logic first things first. We want to actually add the hat component. So in our components, let's add a Static
mesh component in type in here hat mesh. I'll say if we're gonna leave
this as empty for now We're not gonna set anything to it. And then let's head
over to the event graph. And so here we're gonna add an event Where
we can go ahead and attach that to our character's head, so I'm gonna right click
and we're going to search for add Custom event and what this allows us to do is
it allows us to add our own custom event So if I select this you can see we can
name this to whatever to whatever name we want So I'm gonna name this to equip hat. Okay or equip hat event So first of
all, whenever you create an event like this, you just want to compile and
save it That way it's all good to go. And then when this event gets
called, we want to go ahead and set the mesh or this hat mesh, because
right now it's set to nothing. So I'm going to get our
hat mesh components. I'm going to do a set static mesh. So we have static mesh set static mesh. So I'm going to select that
and hook up the execution pin. And now you can see, we can
set this new mesh right here. To whatever we want, so I could set
it to the hat mesh, but what I'm going to do instead is I'm going to actually
take this, and if you take this pin, you can actually drop it onto your
custom event, and what that will do is it will add that as a input that we can
pass the value over to this node, okay? So compile, save that. Lastly, we want to go
ahead and attach this. To our player's head. So the way that we're going to
do that is going to take our hat mesh and do a attach component
So attach component to component. So what this allows us to do is
it takes a target component and attaches it to a parent component. So for the parent we want to
plug in our character mesh. So take our mesh and plug
that in for our parent. Let's plug in the execution. Now under this socket name, I'm
going to name this to Hat Socket. And then for the settings, I'm
going to change this from Keep Relative to Snap to Target. Okay, so Snap to Target,
and Snap to Target. Now let's hit Compile and Save. And now we should be able
to call this Equip Hat. Okay, so if we head back over to the Hat
Pickup, off of our E key, We actually need to somehow get a reference to our
character so that we can call that event. So how is it possible where we
can actually call this event from our hat pickup blueprint? So one way that we can do that
is off of this other actor. We can take this and we can do a
cast to third person character and then plug this in for our character
is overlapping with the sphere, that means that we enable input. And if they press E, we can cast
to the third person character. And this little blue pin allows us
to retrieve any variables or call any events inside of our character. So if I drag and drop this, I can
now search for that Equip Hat event. So Equip Hat. And now you can see we're calling
this event inside of our character. So if I double click this, this will take
us to that event inside of our character. It's calling that Equip Hat custom event. So back in the hat pickup, all we
have to do is set the hat mesh. So we hit the little dropdown
and we can search for that hat. Static mesh hat. Okay, so let's hit compile and save now. We should be able to test this out So if
I go back to my content browser go to our content blueprints hat pickup I'm gonna
take this hat pickup and drag it right over here Maybe we'll rotate it just so
the text is facing the player So now if I hit play I'm gonna go ahead and run up to
the hat pickup and press E and now you can see that the hat Isn't on our characters
head But it is attached to our character. So let's go ahead and fix that. It's not actually attached
to the player's head. So the way that we're going to
do that is by adding a socket. So if we press escape, we want to
head back to our content drawer. Dock this in layout. Now if we go to the third person
character in the viewport, we're going to select our character mesh. So this character mesh. And I'm going to click the browse
icon over here in the mesh. So we have this magnifying
glass or the browse icon. So I browse to that. We'll pull up our character
mesh and our content browser. I'm going to double
click and open this up. Now this shows us our character
mesh, but we want to head over to this skeleton icon. Okay. You can see the skeleton icon right here. And so what this is is a skeletal mesh. And really all that is skeletal mesh
is, is rather than a static mesh, you know, a static mesh is something
that is static or doesn't move. The skeletal mesh has
these different bones. So you can see I can select all these
different bones and these bones allow this skeletal mesh to actually move So
think of it sort of like a skeleton. Okay, so what we want to add is we want
to add a Attachment socket so that we can attach the hat to our players head
So we're going to find the head bone so you can scroll through here to look
through the different bones You can see we have things like the hand the spine
you can actually search up here for head We should have this bone For our head,
so you want to right click and down here. We want to select add a socket Okay. Now for this head socket, we actually
want to rename this So I'm going to double click and rename this to hat socket. Okay, so you want to have the same? Capitalization as what we have in
our third person character and the event graph over here on our attached
component to component Under the socket name you want to have hat socket. Okay, so you want to have
the same capitalization? Same spelling that's what you set over
here for the hat socket now What you'll notice is the hat socket if we press W We
can actually move this around and let's go ahead and just leave that there for
now So if I hit save go back into our level and hit play if I press E You see
that the hat is now attached to our head, but it's actually not rotated the right
way Okay, see it's rotated sideways. So let's go back into our Skeletal mesh
or SK mannequin and I'm going to select this hat socket and what we could do
is we could even rotate this But you can see it's not really great way. We don't know which way to rotate it or to
move it So what I'm going to do is right click this hat socket at the very bottom. You're going to see this
add a preview asset. So it could even add a
preview asset to this. So I'm going to search for that hat,
static mesh hat, and then select it. So now you can see, we actually
have a preview mesh of our hat. So if I go and click the X there and. Scroll all the way down
until we find our hat socket. I'm going to take this and press
E so we can get the rotate tool. And now I can actually rotate
this in negative 90 degrees. And if I press W, I can actually
go ahead and move this up. And position this where I want it to. Okay, and you can turn on
or off the grid snapping. Okay, so I think this is
a good spot right here. So now if I go ahead and hit save. Now we should see that
position be updated like this. So if I go back into our level, hit play. I can run up to the hat and press E. Now you can see that our hat is
attached to our character's head, okay? So it's just using those sockets. Now this is the same method that you
use for attaching things like armor or weapons to your character's hands. You would do that all through the
same method or by using sockets. Now the last thing I want to do is,
whenever I go up to this hat and press E, I actually want to delete this hat pickup. Because we already equipped it so the
way that we'll do that is if we go into our hat pickup So when we press e we
equip the hat after this we're going to basically delete this hat pickup
from our level So the way that we'll do that is through the node Destroy actor. So if you drag off of here, we're
going to do a destroy actor. So we have this actor destroy actor
So let's select that What this will do is it will destroy this actor or
this hat pickup So if I hit compile save and go back to our third person
map hit play Run up to the hat pickup. If I press e to pick it up, you can
see that it now deletes That hat actor from our level and you can see we have
our hat equipped To our player's head. Okay. So that is our hat pickup blueprints. Very similar to our door blueprints
and the fact that we can press E and it will call some logic, but in
our case, it calls a custom event in our character that attaches
this hat mesh to our player's head. So let's go ahead and move on to the
next blueprint that we'll be making. So let's head over to our content
drawer and dock this in layout. Let's go back to our blueprints folder. So head to our content blueprints. When I right click, create a new folder. This will be called zero
three underscore damage box. So double click and open this
up and in here, we're going to right click and add another. So let's go ahead and select that. And this is, again, going
to be of the type Actor. So let's go ahead and select that. So let's rename this to
BP underscore Damage Box. Okay? So basically what this Damage Box will
do, is when our character overlaps with this box, it will apply some damage
to our player, or our player's health. So let's double click and open this up. So in here, we're just going
to add a simple box collision. So click the add under the components
and scroll down until we have this box collision and select that. And actually I'm going to rename
this to damage box pile save. Then in our event graph, we can go
ahead and delete all these nodes. Let's select our damage box and we're
going to add that event be an overlap. Let's go ahead and add that. And basically, we're going to go
ahead and apply some damage if the player overlaps with this box, okay? So this damage box could represent
things like, you know, a fire, really anything that would damage the player. So off of this other actor,
again, we're going to do a cast to third person character. And in our case, we want to add a
health variable for our character. That way we can apply some damage to it. So the way that we would do that
is you want to head over to our third person character blueprint. So let's head back over there And
over here, in our variables, we're going to add a new variable, and
we're going to name this to health. Now for our health variable, we
want to change this from a boolean to a float, compile, save that,
and now we should be able to set the default value of our health. So I'm gonna go ahead and set
this to a hundred or a hundred HP. Okay, so compile save Let's head back
over to our blueprint and damage box And now we should be able to get that
health variable from our character So if you remember we can drag off of
this character reference and we can get any of the variables Or call any
of the events inside of our character. So if I drag and drop this,
I can search for that health. And you can see we can get or set the
health variable from our character. So I want to get the health, and then
what I want to do is I want to subtract that health to basically apply damage. So I'm going to do a subtract. And say we want to subtract this by 10. Okay, or 10 damage. Then we want to set that
health, so I'm going to take... This reference again and do a set health
then we can do a variable set health Okay So when I go ahead and hook up the
execution and then for our health we can plug in the health Minus 10 and plug
that into our new health then to just visualize this we're gonna print this
to our screen So I'm going to use the print string node So drag off here and
do a print string Select print string and we just want to plug in our health
float into the string Now we'll go ahead and print it off on our screen. So now if we overlap with this box,
we should start taking some damage and printing that damage to our screen. So let's go ahead and
drag this into our scene. So take our damage box
and drag it over here. Let's actually scale this up. Scale it up like that. If I hit play. Now we can't actually see where it's at. So we don't know where it's located. So what I'm going to do is
go back to our damage box. Go to the viewport and select
our damage box component. And in the details we can
search for hidden in game. And we can just uncheck that. So now if we compile and
save this we should be able to see it here on our level. So I can see the box right there. So now if I overlap with this
box we should see we have 90. 80, 70, 60, and you can see our health is
decreasing every time I run into this box. Okay, 40, 30, 20, 10, and so on. Okay, even goes into the negatives. Now what I actually want to create
is a damage box that continues to damage our character for
however long that we stand in it. Okay, so that we don't have to keep
running over and over for it to damage. Okay, so I kind of want to
create sort of a looping. Event that will continuously damage
our character standing in this box. So let's go back to our blueprint damage
box and head over to the event graph. And so what we're going to do instead
of this is I'm actually going to delete all of this right here, I'll
save, and I'm going to take this third person character, and I'm actually
going to promote this to a variable. So I'm going to take this, drop it. And you can see, we have
this promote to variable. Okay, so what that does is it takes
our character, the reference to it, and saves it as this variable right
here, so we can use it later on. Now to create that looping event,
what we want to do is off of this, we want to use the node setTimerByEvent. So we have time, setTimerByEvent. So off of here we have an
event that we can bind this to. So if I drag off of this event,
I can drop it on the graph. And then I can type in add custom event. And for this event name, I'm going
to name this to damage player. Now to apply damage to our
player, we're going to get the reference to our character. So I'm going to drag this variable,
our BP third person character variable. And then I'm going to actually use
the apply damage function or node. So if you drag up here, we're
going to search for apply damage. Okay? So rather than subtracting
the health there. We're just going to use
this apply damage node. Okay, so this is all
built into the engine. I'm going to click the apply damage,
select that, hook up the execution. And for our base damage, we could
put in, you know, 10 damage. The same thing that we had it there. I'll save this. And we want this to be looping so
that we'll apply damage continuously. So I want to set the
time to every one second. And then we want to obviously
hit this checkbox for looping. That way every one second, this will. Loop and it will continuously
fire off this damage player event, which will apply 10 damage to our
player now to actually see this We want to again do a print string. So let's do a print String and let's hook
up our return value into the string Okay So now if our character overlaps we'll
call this this looping timer event Which will continuously apply 10 damage to
our player Standing in this damage box. Let's go ahead and hit play. So I run up to the damage box You can
see that it's doing 10 10 and basically 10 damage how we're long we stand in
this box now It's not actually showing our health like our health isn't 10. It's just showing the damage So if we
head back to our damage box We actually need to add the other half of this
because right now we're just applying damage we're not actually receiving
that damage that we're applying. So let's actually delete
this print string. So to implement that other half, we want
to go into our third person character. And in the event graph, we want to right
click and search for event any damage. And so we have this damage event,
any damage, which basically. is another built in event. So whenever we call this apply
damage to our character, this event, any damage will be called. Okay. So now in our character, we can
take this damage and subtract our health by that damage. So we're going to get our health variable. So get our health and do a subtract. So we have subtract here, and we can
subtract the health by that amount of damage that we're receiving. And then we can go ahead and set
our health variable by grabbing it, drag it on the graph, and do set. Plug in the execution, and plug in
the subtract into our health, okay? And then to visualize this,
let's just do our print string. And plug this health into the string. Okay, so compile, save that. So now if I hit play, we should
be able to see our health decrease from 100 all the way down. So now we can see 90 HP, 80,
70, 60, 50, and it goes and continuously drains our health. And it can even go into the negatives,
negative 20 and all that stuff. So what we want to add is instead
of printing it to our screen. Let's actually add a visual
health bar to our character. So we're going to add a health bar
widget to our screen so that we can actually see our character's health. So in our blueprints damage box
folder, I'm going to right click and add a user interface or a widget. So under the advanced assets over
here at the very bottom, you're going to see user interface. And we have what's called
this Widget Blueprint. So this allows you to create things
like user interface, whether that be things like mini maps, player inventory,
health bars, all of that stuff. This is basically what you use to
create that, a Widget Blueprint. So I'm going to select that. It's going to ask us to pick a parent
class for our Widget Blueprint. We're just going to use the
default one, the User Widget. And it's going to add it here. In our content browser, so I'm
going to go ahead and select this and rename this to WBP for Widget
Blueprint underscore health bar. Okay, and now we're going to
double click and open this up. So this is a completely new window
that you're probably unfamiliar with. But basically, this is where you'd
create things like user interface or things like health bars, inventory,
settings, and stuff like that. I'm going to briefly explain this
widget window, but I will make a separate video diving more in depth
about how to create a user interface and more in depth about widgets, okay? But basically, all you need to
know is that this center part... is basically our screen. Down here on the left
we have this palette. So we have different things
that we can add to our screen. Stuff like buttons, images,
progress bars, text. We have the hierarchy. And then we have this details panel. Okay? So in the center part we can scroll
in and out and pan just like any of the other graphs and all that stuff. Now we want to add a simple health
bar to our screen and we want to also add a Canvas panel that way
we can start working on our canvas. Okay, so under this palette we
can actually search for canvas So add this canvas panel. Okay. So you want to take this and you want
to drag this onto our health bar. So under this hierarchy and what
this adds is sort of this canvas. So think of this as like
the player's screen. This is where we can add
things like user interface. Okay. So we could add things like a mini map
if we wanted to up here, player chat down here, you know, if they had a weapon, we
could put like how much ammo they have. Down here in the bottom right. This is basically like the user
interface or the player's HUD. Okay. So now that we have a canvas panel, we can
start adding more different things to it. So I press this X. I'm gonna add down here this progress bar. Okay. So if we take this progress
bar, we can either drag it onto this canvas panel here. Or we can also drag it onto the
canvas panel here on our screen. So if we drag it on there like so. We can actually take
this and scale it around. So I'm going to scale it like that. And I'm going to take this
and move it down here in the bottom left part of our screen. Okay. Now with this progress bar selected,
you're going to notice we have sort of this flower icon up here. Now this is called an anchor. And basically we want to Change this
anchor to this bottom left part. Okay. So with this selected over here in
the details, we have this anchors. I'm gonna click this dropdown
and I want to select this bottom left anchor right here. Okay. So basically what the anchor does is, you
can think of it sort of like the anchor of a ship, but with user interface,
what it's doing is it's anchoring. This UI element or this user interface
to the bottom left part of our screen. So say if our player were to resize
their game window, this anchor is going to try and keep this health bar to
this bottom left part of our screen. Now what this progress bar does is if you
go to the details, if you look all the way halfway down here, we have this progress
percent and we have this float value. So if I take this float value and move
it up or down, you can see that we have sort of this health bar effect. Okay, so I've put this all
the way to a value of 1. You can see that our health bar is full. If I decrease this... About halfway. You can see our health bar is
halfway full, or we can put it all the way down to zero. And that means our health
is decreased all the way. So we could just set this to
whatever doesn't really matter. But what we want to do is we
want to actually bind this value to our player's health. Okay. So how we would actually do that is
under this percent, we can actually bind this to our player's health by
clicking this little bind button. So under this bind, We hit the
drop down, we can create a binding. I'm going to go ahead
and click create binding. And what that does is it takes us
from this designer, which is where we were at, where we can design our user
interface, over to the graph, okay? So there's a designer part, where
you design it by adding different buttons, text, all that stuff. And there's a blueprint graph part. Where you can actually program in what
all the buttons and UI elements do. So in our case, we're creating this
binding event, this getPercent. And we're setting that value right here. So what I want to do is I want
to get our player's health. And set the percentage of this
bar to our player's health, okay? So the way that I'm going to do
that is I'm going to take this return node and move this over. And I'm going to right click
here on the graph and search for Get Owning Player Pawn. Because we want to get
our character blueprint. So we're going to use this
Get Owning Player pawn. So this gets the player pawn
associated with this UI. I'm going to select that and
then off this return value. We can do a cast to
third person Character. Okay. So now we can cast to our character Let's
hook up the execution and then from our character we can actually get our health
variable So we can do a get health and that will give us that health variable. Okay, so So casting is a very useful
method because you can do things like communicate from one blueprint to another,
where you can call certain events, or you can retrieve certain info, like variables. Now we could plug this into this
return value, but the problem with that is our health is a value from 0
to 100, whereas this return value... Or this percentage is a
value from zero to one. So what we need to do is we
need to convert this over to a value of zero to one. So when I take this health into a multiply
operator, multiply and multiply this by 0. 01 and plug that in for the return value. So what that will do is it will
take our health variable and it will shift over the decimal point. That way our health will be on a
scale of 0 to 1 which will be plugged into our percentage Okay, so it's
sort of like converting it to a percent So now we're going to take
this execution and plug that into the return node and compile save that Okay. So now all we have to do is if we head
back over the designer just want to add this this widget To our screen. So to do that, we want to head back
over to our character blueprints, and we're going to add an event inside of
here to add our widget to our screen. So I'm going to right click
and type in, add custom event. So add custom event. I'm going to rename this to
create health bar events. Now we want to hit compile and save,
and we want to go ahead and create that widget and add it to our screen. So the way that we'll do that
is we're going to drive up here and call the create widget. So we have a user interface create widget. So I'm going to select that. It's going to ask us which
widget we want to create. So if you hit the dropdown, we should
be able to see at the very bottom, our widget blueprint underscore health bar. So I'm going to select that. And then we want to specify a player. So we want to drag off here
and do a get player controller. So we have get player controller. And then lastly, we just want
to add this to our viewport. So off of this return value,
we want to do add to viewport. Okay? So this is a very simple setup
to add a widget to your screen. And again, I'll have a separate video
going more in depth about UI and widgets. Okay? So compile, save this. Now we just need to call
this create health bar event. When the game starts. Okay, so if we scroll out we have
that event begin play all the way up here for our add input mapping. Now we could call our create health
bar event all the way here at the end. But the problem with that is say this
cast over here failed for whatever reason. It's not going to call
our event over here. If something fails in this logic, okay,
so we're going to use a node called a sequence that we can call multiple
things off of our event begin play. So I'm actually going to move all this
stuff up, so just select all this, move this up, and I'm going to take
my event begin play and do a sequence. So we have this sequence node. So select that. What that does is it adds extra
pins off of our event being play. So it's then zero. So we'll, the first thing that
we'll do is all of this stuff. So execute all that. And then the second thing that
we'll do is everything that's under here and we couldn't even
add extra pins if we wanted to. Okay. So off the second pin, we're going to drag
off here and call that create health bar. Event. Okay. So the first thing that we'll do
is add this input mapping and then the second thing it'll do when the
game starts is create our health bar event, create our health bar
widget and add it to our screen. So now we should be able to test this out. So if I hit compile and save, let's
head back to our third person map. If I hit play, you can now see we have our
health bar at the bottom of our screen. Basically it's creating
that widget and adding it. To our player's viewport. So we can now see that little widget. So now if I go to our damage box. You're going to see that it
starts damaging our health bar. And it's starting to decrease. As long as we stay in this box. Okay. Now one thing you may notice. Is this still decreases our health. Even if I run out of this box. Okay. So if I hit play. And run over to this box. And then run out. You can still see. It's decreasing our health bar. Even if we're outside of the box. So we need to add a way for this
damage box to stop damaging our player. So let's head to our damage
blueprint damage box. And in here we set up the event,
begin overlap for our damage box. Now we just need to set the event
and overlap for our damage box so that we'll stop this timer. That's applying damage to
our character every second. So I'm going to select this damage
box, scroll all the way down and add that event and overlap. Okay. So now what I'm going to do is
I'm going to check and see if the other actor is a character. So I'm going to do a cast
to third person character. And then how do we actually
stop this timer over here? So the way that we would stop this
timer is off of this return value. You take this. We can actually promote this to a
variable, and what that will do is it will give us a reference to that timer. So I'm going to rename this
to our timer reference. And so with this timer reference, if
I compile and save this, we can now stop the timer with that reference. So down here I can get that
timer reference variable. Get it on the graph and I can stop it. So I want to do a clear and
invalidate timer by handle. Okay, so this basically stops the timer. So if I select that, all I have
to do is plug this in like so. So now if our player leaves
the damage box, we're going to stop this timer from looping. Okay. Which will stop the damage
being applied to our character. So if I hit compile and save,
I can go ahead and hit play. Run up to the damage box, let
it damage us a couple times. And if I run out of the box
you can see that it stops. Damaging our player and our health
just stays there at the same position. Okay, so that is our simple damage
box Let's actually add some visual effects or particle effects for our
damage box Because right now this is just sort of this invisible box
that we run into And it damages our character, but we're going to add some
fire particle effects just as a visual. So I'm going to go ahead and open up
the Epic games launcher and head over to the Unreal Engine marketplace. And in here, I'm going to search
for FX variety, FX variety pack. And so if you search for FX variety
pack and filter by free, you should see this FX variety pack, which
is completely free to download. So you select that and you
want to click free here. Or checkout so that you can
actually claim the asset. And then once you've actually done
that, we can click this add to project button and we can search
for our blueprint beginner project. And click add to project, okay? So we'll go ahead and download
and add it to our project. So now in our content drawer, if I
dock this in layout, we should see a new folder for our FX Variety Pack. And then in our particles
we have a bunch of different particles that we can use, okay? So I want to use this,
uh, PKY Magic Circle. So it sort of has like this fire
effect right here, as you can see. So I'm going to use that
particle effect for our... Damage box. Okay, so we can head over to our
blueprint damage box And there's two different ways that we can actually add
this particle effect Okay, we can either add it as a component inside of here or
we can spawn the particle effect Okay. Now what I'm gonna do is I'm just gonna
add it as a component so I'm gonna go ahead and honor the components click
add and we should be able to search for a particle and Under here we have
cascade particle system So currently a cascade particle system are basically
these particles so you can see it says cascade particle Now this is actually
the older particle system So these are legacy particles and the new particle
system and on religion is called Niagara. So just note that this is
the older Particle system. Okay. It's been up to dated with Niagara. Okay, so I'm gonna select this
Magic particle and if I have this selected I can go back to our damage
box and click add Search for that particle cascade particle system. And since I have it selected in our
content browser, if I click on it, you can see I can actually add it and it
will assign that particle right here. You can also add it and then
assign it over here in the details. That also works. Now if I compile and save,
you can see that's a little bit too big in our viewport. So I'm going to take that particle
and actually scale it down. So I'm going to go ahead
and scale this down. Like so. I'll save. And now we can see it's a
little bit of scale down. So now if I hit play, we
have that little fire effect. So if I run into it, it starts
damaging our player's health. Okay. So just a nice little particle effect. And we could even hide that
little, uh, box collision. So we head back into our, uh, damage box. We can select the damage box, box
collision, go over into the details and search for hide or hidden in game. Check that so that it's actually hidden. Okay, so now we created our damage box The
next thing I want to create is a health box Which actually do the opposite of
our damage box and heal our character. Okay, so rather than damage our character
I want to have another box that will actually heal our character And regenerate
our health on our health bar So the way that we'll do that is we want to
go back to our blueprints folder Go to our damage box and in here we can
right click and add another blueprint class Of the type actor and we can
name this to BP underscore health box. Okay, so we can double click and
open this up Do a file Save all i'm actually going to close all these other
different windows that we have open. So i'm going to close this
hat pickup mannequin windows Damage box and our health bar. So we just have our third person
character in our health box So in here, this is going to be the same exact
setup as our damage box But rather than damage the player, we're going
to regenerate the player's health. So the way that we'll do
that is we're going to add, again, another box collision. So we can add a box collision. This will be our heal box. And then in the event graph, you can go
ahead and delete all of these events. Compile, save. Select our heal box, box collision. Scroll all the way down and
add a event begin overlap. Select it again and add a
event end overlap, okay? So for our big event, begin overlap. We want to do a cast to third person
character, and then we're going to go ahead and promote that to a
variable so we have a reference to it. So we're gonna take our third person
character and do promote to variable. Now we'll save that as a little
reference and then we're going to do that start timer by event. So drag off here and do
that set timer by event. So set timer by event. And for the event we just drag
off here and do add custom event. Select that and we're going
to name this to heal player. So compile save. We want to set this to
every one second looping. We'll call this heal player event. So now to restore health to our
player, we want to get a reference to our third person character. We want to get that on the graph
and we're going to get our health. So when it gets health variable, so
we can get any of the variables from our character through this reference,
things like the health, and we're going to do a little bit of a check. Okay. Cause we only want to heal our player
up to a hundred HP because if they reach a hundred HP, that basically
means that they are maxed out on health. So I'm going to drag off here and do a. Equal, so two equal signs, and this,
under the operators, we're going to check and see if that is equal. Okay, select that, basically, we're going
to check and see if this is equal to a hundred, and that will give us a boolean. Okay, so off of the boolean we
can do a branch, so flow control branch, and if this is equal to
a hundred, then that means that our player is already full health. If it is not, that means
that our character... Has not reached our max
health or a hundred HP. So let's hook up the execution for
the true we could jog up here and do a print string and we could just name
this to player has Healed up a hundred percent of their health and for the
false What we could do is we want to go ahead and actually heal our player
Okay so we want to get our third person character and then get our health get
health get our health variable and And actually add 10 HP to our health. So off the health we want to do a add. So we have operators add. And we want to go ahead and add 10 HP. Okay? So now we just need to set our health. So off our third person character we
can drag off there and do a set health. So then we can set that health variable. So plug that execution pin for the false. And then for our health we can plug in
our health plus 10 to our health variable. Okay? So compile and save that. Now we just need to add
the event and overlap. So when the player stops
overlapping with this, we want to stop this timer from looping. So again, the way that we'll do that
is first we're going to cast to third person character, check and see if
it's the character that leaves the box. If so, we want to stop this timer. So to get a reference to that timer,
we want to take that return value and promote that to a variable. This will be our timer reference
and then we can compile, save that, get that timer reference down here. And call that Clear and Invalidate
Timer by Handle, okay, which basically stops the timer. So the last thing that we want to do
before we test this out is we want to add a little particle effect again for this. That way we can actually see it. So I'm going to add a particle,
Cascade Particle System component, our particle system. And in our details, we can click the
dropdown and I'm going to search for Heal. We have this Heal Aura, okay. So I select that. We have sort of like this heel effect. I'm gonna go ahead and
actually scale this down. So if I go ahead and scale this
down, I think I set this scale over here to 0.25 by 0.25 by 0.25. So I set the scale like so,
so hit, compile and save. And then let's go ahead
and drag in our health box. And let's actually scale this up and move
this right next to our, uh, damage box. Okay, so we have our health
box and our damage box. So let's go ahead and hit play. So first things first,
let's damage our character. So if we run over to the damage box,
it'll lose a little bit of our HP. Okay, if we run out, it
stops damaging our character. Let's go run into our health box,
and now it should start healing our character all the way up to 100 HP. And now it's already healed up, so
you can see player has healed up a hundred percent of their health. It's showing on the top left of our
screen, and if I run out of there, I can run back into our damage box and
start damaging our player, and we can run back and start healing our player. So, very simple blueprints, this is
all set up with just a collision box. And some looping events that are
applying some damage to our health variable and showing it updated on our
widget or our user interface, okay? So that is our health and damage
blueprint, we're gonna go ahead and move on to our next blueprint that
we're going to be creating, which is going to be our little soccer game. So let's go ahead and move on,
so let's go to our content drawer and dock this in layout, let's
go back to our blueprints folder. And in here, I'm going to right click and
create a new folder, and rename this to 04 underscore soccer blueprints, okay? So save that, and double
click open that up. Okay, so let's go ahead and create
our soccer goal and our soccer ball. So I'm going to right click and create
a new blueprint class of the type actor. And this will be our BP
underscore soccer goal, okay? So double click and open that up. And in here we're just going
to add a Static Mesh, so add a Static Mesh Component. And this will be our Soccer Goal. And under the Static Mesh you
want to hit the dropdown and search for our Soccer Goal. So our SM Soccer Goal. Okay. Now, you're going to notice that
this is just a white material and in fact if I look on this other side. We can't actually see this material. It's all weird. You can only see the material
from a certain angle. So we actually need to go ahead and set
up this net material for our soccer goal. So if we head back to our content
folder, let's go all the way back out and go to our project files. And we should have this mask
material that we imported, okay? So we actually want to open up this
net material, this white material, just double click and open that up. Then we want to take that mask
material, Drag it and drop that texture over on a material tab and
then drop it here on the graph, okay? So we're going to use this as sort of
like a mask to mask our material to be sort of like this Transparent net so we
actually want to select this main node in this material and we're going to change
this to be masked So over here and this blend mode I'm going to change this from
opaque to masked, and then I'm going to take this texture mask, take this RGB, and
plug this into this opacity mask, okay? So that will sort of
create this net material. Now we also want to select this
main node right here and also click this two sided, that way we
can see it from both sides, okay? So now if we hit save, It should
apply that for our soccer goal and now we have this net material
that we can see from both sides Okay, so that is our soccer goal. We also want to add a
collision box Inside of here. So I'm going to add a box collision. So box collision and this would
be the actual goal So I'm going to take this box collision and
we're going to scale this up. So this actually fits inside of the soccer
goal We'll just position this Like so, so that it sort of covers the entire area. Okay, so this should be good like this. Okay So that is good for
our soccer goal for now. Let's go ahead and actually
drag this into our scene. So let's take Go to our blueprints,
soccer blueprints, and take our goal and drag this into our scene. You can see it's a massive So if we
rotate this 90 degrees, let's actually go ahead and scale this down So if we open
up our soccer goal blueprints and drag this window like so we can go ahead and
put this side by side Then I want to take this soccer goal mesh and scale this down. So I'm gonna R to scale And I think
we can just set the scale to 0. 5 by 0. 5 by 0. 5. Pile, save. And then now in our viewport
I think this should be a good scale for our soccer goal. Now let's add our soccer ball. So in our folder, our soccer blueprints,
we're going to right click and add a... A new blueprint class of the type actor. I'm going to rename this to
BP underscore soccer ball. And double click and open this up. So in here I want to add a mesh. So I'm going to add a
static mesh component. And this will be our ball mesh. And select that component. And in the details we're
going to set that to our ball. Or our SM underscore ball. Okay, so we scroll out here. I think this is a little bit too big. So if I actually, uh, drag this
in our scene, yeah, as you can see, it's a little bit massive. So in our BP soccer ball,
I'm going to select the mesh and set the scale here to 0. 1 by 0. 1, 1 all the way around. So it's a little bit
smaller pile and save that. And now in our scene, you
can see that's a lot smaller. Okay. So that is our ball mesh. So now let's go ahead and play test this. So if I hit play, you can
see right now, our ball. It's just a static object. Okay. It doesn't actually move
when I try and run into it. Okay. So the way that we want to fix that is
we need to go ahead and add simulation to this ball so that it actually
rolled around and pushed around. So if we go into our soccer ball
blueprint, if we select the static mesh in the details panel, we can scroll down. We have this section called physics. Okay. So I'm going to click this simulate
physics and click that little check box to set it to true. And then I'm also going to change the mass
of this ball and change this down to 20. So compile and save that. Now let's go ahead and hit play. Now you can see the ball
falls to the ground. I can actually hit it around and what
you're going to notice is I can't actually hit the ball into this goal. It's getting blocked when I
try and push it into the goal. And also the ball is rolling
a little bit strange. You can see it doesn't really
roll smooth on the ground. Okay, so that has to do with collision So
let's first check out the ball collision. So if we head back to our content
drawer click dock and layout Let's go back to our project files and
open up that static mesh ball asset. So double click open that up In here,
let's actually check out the collision. So if you click show, we want
to show the simple collision. So as you can see, the simple collision
is sort of this boxy geometry. And it's not a perfect
round sphere collision. So let's go ahead and fix that. So to remove this collision, we
can go up to the collision button. And down here we can
click remove collision. Okay, that will go ahead and delete that. So now we don't have any collision on it. So we want to go ahead and
add a simple sphere collision. So under collision, we
can hit the drop down. And select add sphere
simplified collision. What that will add is a nice
sphere around our soccer ball. And now it should roll on
the ground nice and smooth. So if we hit save, hit play. Now if I run to our soccer ball. You can see that it rolls nice
and smoothly on the ground. Now the other issue I want
to fix is with our goal. We can't actually push the soccer ball
into the goal, it's getting blocked. So again that has to do with collision. So if we go to our SM soccer
goal, double click open that up. We want to go ahead and check
out the collision on this. So if I go to show a simple collision,
you can see that the collision is basically, uh, what's blocking the
ball from actually going into the goal. So instead of adding a collision
through here, none of the collisions are actually going to work that great. So what I'm going to do is I'm
going to go into the collision and do remove collision. And then I'm going to use what's
called Complex Collision, okay? So you can use Complex Collision sometimes
when you have sort of this complex mesh, or you have sort of this cavity where
you want objects to move freely in. So down here in the details, if you go to
the Collision, we have Collision Presets, Block All, and then Collision Complexity. I'm going to change this
from Project Default. And use complex collision as simple. And so what that is going to do is
it's going to use the collision of this mesh as our actual collision. So now if I hit save, I can go back
into our third person map and hit play. Now, if I run up to my soccer ball and
push it into the goal, you can see that I can actually go into the goal now. Okay. It's not being blocked by the collision. Okay, so now we can actually go ahead
and set up our soccer goal blueprint. So let's go ahead and
go into our soccer goal. And basically what we set up here
is our mesh and our collision box. So essentially, when the soccer
ball is scored into this goal, when it overlaps with this box, we want
to go ahead and set up an event. So we can do a little particle effect
to show that we scored the goal And then we want to reset the ball back to the
original spot So the way that we'll do that is we'll go into the event graph. We can actually go ahead and delete all
these nodes I'll save let's select our collision box and Scroll all the way
down and add a event begin overlap for our collision box So off of our other
actor we want to go ahead and check and see If the actor that is overlapping
with this box, is it our soccer ball? So off of this other actor, we
can do a cast to BP soccer ball. Basically, we're doing that check to
check and see if it's the soccer ball that is overlapping our collision box. So if so, we can go ahead and
spawn a particle effect to sort of celebrate that you scored a goal. So the way that we'll do that is we'll
do a spawn emitter at a location. Okay, so we use the spawn emitter at
a location This will allow us to spawn sort of a particle effect wherever we
want So use this emitter template if we hit the drop down we can add any
sort of particle effect I'm going to add this PKY hit one and then for the
location we want to specify a location So I'm just going to right click and
get actor location, get the location of this, uh, soccer goal in level and
plug that in for the location of where we should spawn this particle effect. Okay. So let's go ahead and test this out. If I hit compile and save, go
back to our level and hit play. If I run it and score the ball, we saw
there was a little particle effect. We actually didn't
really see it that well. So let's go ahead and redo it again. Okay, so you can see that it
scored right there, a little particle effect played right there. I'm going to move the particle
effect a little bit higher because it's sort of in the ground. So if we head back over to our soccer
goal, the way that we can modify that location is if we move this
over, we can unhook this location. If you remember, the location is simply
just three different float variables. So we can actually make this
location by dragging off of here and doing a make vector. So we have make a vector
here at the bottom. And what that will do is it will split
that location into three different float variables that we can modify. So we want to do the same
for our get actor location. We want to drag off here
and do a break vector. So we're breaking the vector
from our location and we're making it to make our location. So I'm going to plug in
the X and the Y location. Now for the Z I'm basically going to add. The Z value. Okay. I'm going to take our current Z value
into a add operator and whatever our Z value is, I'm going to add 300 on top of
it and plug that into our new Z value. Okay. So that should move our particle effect. to be 300 units above our goal. Okay. So it's just a little bit above our
goal and we can sort of see it as like a confetti celebration and particle effect. Okay. So if I hit play and score the ball and
you can see, we have a little particle effect to show us that we scored
the ball and to sort of celebrate. Okay. Now the next thing I want to
do is You can see the ball just rolls out of the goal like that. Instead of having to manually try and
grab the ball back out of the goal, what I want to do is I want to have the
ball automatically spawn out here so that the player can continue to kick
the ball over and over into the goal. So after the ball is scored, we're
going to delete it and then respawn it in front of the character. So let's head back over to
the soccer goal blueprint. And so first, let's go
ahead and destroy the ball. So once the ball is scored, or once it
overlaps with this box, we're playing that particle effect, then we want
to go ahead and destroy the ball. So we're going to take the soccer ball
reference right here, and drag it all the way over here and do a destroy actor. So that will go ahead and
delete it, so hook that up. Then after that we're going to do a
delay, so do a delay node right here. So what that will do is it'll
wait for a certain amount of time. In our case, we can change
this to two seconds. So I'm going to delete the
ball, wait for two seconds. And then after that's done, we can call
off the next event right here, which is we want to go ahead and respawn the ball. So to respawn the ball, we can use the
spawn node or the spawn actor from class. Now it'll allow us to spawn
any sort of blueprint class. So in our case, we want to search
for BP underscore soccer ball. And that will allow us
to spawn the soccer ball. Now, if I just compile this,
what you're going to notice is we have our first error here, okay? I think it's probably useful to
actually show you what an error looks like inside of Blueprints. So whenever you have an error,
in particular, it's going to show you error here on the node
where it's giving you that issue. Also, the compile button is going
to show that red error icon. And then also in the compiler results,
it's going to show you Uh, the warning or the error icon right down here. Now, the useful thing about this
compiler results is say I have a big graph, I have a lot of nodes in here. To actually find where you're
having that error message, you can click on this little browse icon. So if you click on that, it
will take you to the exact node that's giving you that error. This is super helpful because later on,
you might be hitting the compile button, and you randomly get an error, and you
might be wondering, where did I mess up? Where is that error located? Well, if you look down in the compiler
results, you can browse exactly to where it's giving you that error message. Now, if you actually look at the
error message, you can see what it's actually complaining about, okay? So read the message down here. It says the current
value of spawn transform. So where is spawn transform? So it's this pin right
here, spawn transform. The current value of spawn
transform is invalid. So basically it must have
a input wired into it. So it's telling you exactly
what's the error with this node. So in our case, the spawn node,
it must have a spawn transform hooked up to this transform. Okay. If there's no transform hooked up, then
it will not know where to spawn this at. So there's actually two
different ways you can fix this. You can plug in a transform
variable, or you can even right click this and do split structure pin. Usually I just right click
and do split structure pin. And that will split that transform
into the three different variables, the location, the rotation, and the scale. So now if I hit compile and save, you
can see that that error went away. Okay, so it's very useful to read
this compiler results whenever you get an error, because it will tell you
exactly which node is giving you the error and what exactly is going on. Most people just kind of gloss over that
and don't normally pay attention to it. So now we're actually setting
the location of this ball of where we want to spawn it at. Now what we want to do is take this spawn
transform location and drag off here, and we can promote this to a variable, okay? So we can use a variable to
store the location of where we want to spawn our soccer ball. So if I hit compile and save,
that will give us the actual, uh, value or default value of our
spawn location that we can set. So we could go back to our
viewport and find a location of where we want to spawn the ball. Let's say we want to
spawn it, uh, right here. So I could go into the location,
right click this location, copy it. And go back into our soccer goal
blueprints, select our transform, and just paste it in there. Now this will work. So if I hit compile and save, I go
back into our level and hit play. I can run up and move this soccer ball. And now, we should see after two seconds,
it will respawn at that location. Okay? So if I score it, it will
delete the soccer ball. And then it will respawn it like so. Now this is great and all, but there's
actually a better way of doing this. Or at least spawning the
ball at this location. So for example, if I wanted to move
this ball to a different location. So say if I deleted all of this. All the meshes over here. Just make a little bit of room for this. Say if I took my soccer goal
and I moved it over here. And I moved my soccer ball over here. I have to actually update this location. I have to copy this again and paste it
into this location variable right here. To update the location. I have to do that manually, okay,
which might be a little bit tedious. Now, another way I could get the
location of this ball is by using a couple of other different nodes. So what I'm going to do is I'm going
to actually add a new variable. So add a new variable. This is going to be our
soccer ball reference. Okay. Now I'm going to change this
variable type from Boolean. I'm going to search for
BP underscore soccer. And we should see that BP soccer
ball, our soccer ball blueprint, I'm going to select our object reference. Okay. So now we have this blue
variable right here, which is our BP soccer ball reference. So what I'm going to do is I'm going to
right click and add event, begin play. So I'm going to add the
event, event, begin play. So basically when the game starts, I'm
going to get that soccer ball reference. Get it on our graph and
check and see if it's valid. Okay. So I'm going to do a is
valid utilities is valid. This is white question mark node. Okay. So basically what this does is
it checks and sees does this soccer ball actually exists? Is this a legitimate reference? If it is valid, then we can fire it off. If it is not valid, we won't do anything. Okay. So if it is valid, we want to take. And get that soccer ball reference. We want to get the location. So we want to do get actor location. So get the location of the ball. And we're going to set our spawn
transform to that location. So we want to set our spawn
transform location to that actor location or to the ball's location. So now I can hook that up like so. Hit compile and save. And now I just want to select this
soccer ball reference variable. And I want to set this
to instance editable. And expose on spawn. Okay. So now that I've hit those two check
boxes, instance, edible, and expose on spawn, if I compile and save and head
back over to the third person map, if I select this goal right here, down
in the details panel, we're going to see this a new variable reference. So under this default, we have this
soccer ball reference, and you can see it's currently set to none. But what I can do is I
can actually hit on this. A little selection on
this little picker tool. If I click on it, it allows us to
select a reference to our soccer ball. So you can see it's currently sort of this
red cancel icon, but if I hover over the soccer ball, we can actually select it. And now it's set a reference to our
BP soccer ball that's in our level. So now what it's going to do is it's
going to take the location of this ball, no matter where I move it. And that's going to be the location
of where it's going to spawn. For example, if I were to rotate it like
this and move our soccer ball position over here, if I hit play, I can run up
to the goal and score the soccer ball, and then it's going to respond at that
exact location of where the ball was at. So I could even move the goal
and the soccer ball again, and it will update that location. So no matter where I
move this in the level. If I hit play, I can move the soccer
ball into the goal and it will respawn automatically at that spawn point. Okay, and that's really
the power of blueprints. The fact that you can take things
like these variables and you can expose them, make them instance
editable and expose on spawn. And that will allow you to
actually select a reference to that variable and use that reference. In things like the blueprint graph, okay? There's just a lot more different
things you can do with blueprint. And this is just one of those things. So now we've made our simple soccer goal. So I can actually score the ball. Play a little particle effect
and then it will respawn. Now let's actually go ahead and
move on to the next blueprint. Or the last blueprint that
we'll be creating in this video. So the very last blueprint that we'll
be creating is a simple hit actor. Sort of like what you'd see in Fall Guys,
where you have sort of those different obstacles that you have to avoid. If it hits your character,
it'll send it flying. That's basically what
we're going to create. So in our content drawer, we're going
to open this up and dock this in the layout and go to our blueprints and
right click and add a new folder. And we're just going to rename this
to 05 underscore hit actor blueprints. So double click and open that up and
we're going to right click and add a new blueprint class of the type actor. I'm going to rename this to BP
underscore hit actor and then we can double click and open that up. So inside of this hit actor I'm
going to add a new component, a new static mesh component. And I'm going to select this
and hit the little drop down and search for our hit actor. So we should have this little yellow. SM hit actor. So let's go ahead and select that Now you
can see we have sort of this a little hit actor and basically how this will work Is
this thing will go ahead and spin around? Over and over and if the player
runs into it or gets hit by this part right here It will send them
flying in the opposite direction. Okay, so let's add a couple of
different things in here first things first, let's add a capsule Component
for our little hit actor part. So I'm going to add a capsule component. So scroll down we should have under
the collision Capsule collision, so select that and if we move this
out we can move this up right here. I want to rotate this Sideways, so 90
degrees and I can move it and scale this up So let's go ahead and scale
this up like so And basically just position this So that it covers this
entire, uh, hit actor part, okay? I'm just going to move it over like that. So it should sort of
cover this entire part. I think this should be good for now. So I'll just go ahead
and compile save that. Also I'm going to add an arrow. That way I know which way
this should move forward. I'm going to add an arrow component. And that should add an arrow component. I'm going to take this
and move this like so. And then rotate this 90 degrees so that
it's sort of in the front like this. Okay, so that should be good. And compile save. The last thing I want to
add is a rotating movement. So in Unreal Engine there's a
rotating movement component. So you just click on this little add. You can search for rotating movement. We have this movement,
rotating movement component. So if I select this, in the
details we have this rotation rate. And it's set to 180. So I think this should be good for now. So let's go ahead and compile, save that. Head back over to our third person map. And let's drag and drop
this into our level. And hit play. So now you can see we have
this very simple hit actor. If we run up to it, nothing is
actually going to happen right now. But you can see it's just
continuously spinning over and over. Okay? So basically what we want to set up is,
once we actually run up to this hit actor, if we get hit by it, we want to send
our character flying, do sort of like a ragdoll event, and have our character,
you know, fly off in the distance. So let's head back over
to our BP hit actor. Head over to the event graph. And we can actually delete
all of this real quick. Compile, save. We're going to take our capsule collision,
so this, uh, collision box right here, and we're going to add a on event overlap. So on the event graph, we're going to
select that capsule, scroll down, and add a on component to begin overlap. So basically when this hits
our player, we're going to go ahead and send them flying. So first, let's go ahead and check and
see if the other actor is our character. So we're going to do a cast
to third person character. And then if it is our character,
we want to go ahead and call an event inside of our character
that will go ahead and ragdoll the character and send them flying. So let's actually go ahead and go to our
third person character to add that event. And also, real quickly, I'm going to close
all these other windows that we have open. So we should only have the third
person character and our BP hit actor. So in our third person character, down
here we can right click and add an event. So I'm going to right click and
add custom event here on our event graph called hit by hit actor. So if we get hit by the hit actor,
okay, so basically if we get hit by our hit actor, we want to go ahead
and simulate physics on our character. So the way that we're going to
do that is we're going to get our character mesh, drag it onto the
graph so we get a reference to it. We want to do a set simulate physics,
okay, so hook this up like so. And click simulate. And then we also want to add an impulse. So that will, uh, send our
character flying a little bit. So again, we're going to get our mesh. Our character mesh. And do a add impulse. So we have add impulse. So select that and hook this up. For our impulse, we're
going to modify this value. So we want to do that make vector. So drag off here, we're
going to do a make vector. So we have make vector, okay, and we're
going to multiply this by a value. So we're actually going
to select this event. And if you remember, we can actually drag
values onto this custom event and that will add a sort of inputs or variables
that we can pass through this event. Now we can also under the inputs,
add variables in here as inputs that we can pass information through. So if I click this plus icon here. You can see I can add a variable that
I want to pass information through. So in our case, I want to change this
actually to a vector, and I'm going to rename this to hit a location. Okay. So wherever we hit our character,
the location of that, then I'm going to take this location and do
a multiply operator, multiply, and then for that value, I actually want
to take this other vector down here. If you right click this pin,
you can convert this to a float. So I want to do pin conversion to float. So I do that, I can now
convert this to a float value. And for this value I want to
change this to say, 50, 000. So just a really big value. And then I'm going to do a break vector. And now we have that x,
y, and z float variables. I'm going to plug in the x. And the Y. And then for the Z here, I'm just
going to set this to 50, 000 in the Z. Okay? So I'm going to copy the X and
Y and then set the Z to 50, 000. So that should kind of
launch us in the air. Okay? So I hit compile and save. Now we just need to call this hit by hit
actor event in our hit actor event graph. So when this capsule hits the player. We check and see if it's
actually the player. If so, off of this third person
character reference, we can call that hit by hit actor event. Okay, so select that. And now we just need to
give it a hit location. So for that, I'm going to
get this arrow component. So this arrow is right in
front of our hit actor. So I'm going to get our arrow
on the graph, and then I want to get forward vector. So that will get basically the forward
vector or the location of this arrow and can use that for our hit location
of where we should launch or what direction we should launch our character. Okay. So compile, save that. Now we should be able to test this out. So let's go ahead and hit play and
run up to our little hit actor. So now you can see our hit
actor or character gets launched all the way up in the sky. And you can see that we're getting
all these warning messages or errors. We're getting this collision
enabled warning message. So basically we need to go back into
our character collision and change a little setting so that it can stop
giving us that little warning message. So if we go back into our third person
character, in the viewport we're actually going to select our character mesh here. And I'm going to change our collision
settings, so if you scroll all the way down we should have Collision Presets. And instead of Character Mesh, I'm
going to hit the drop down and set this to Ragdoll all the way down here. Okay? So that will make our character
Ragdoll when we simulate physics. So now if we hit play, we can
go ahead and run up to this. And when it hits us, you can see
it still launches us pretty far. Uh, but we don't get any more
errors or warnings when we exit out of the play mode. Okay? So you can see we have
our basic launch logic. So it launches pretty far. But one thing you might notice
is it still continues to hit us, even though our character's
body is all the way over there. And then I can even move
our character around. So you can see I'm walking
around, but our character's mesh is all the way over there. So you can see there's a couple of
different problems that we need to fix. So let's go ahead and
fix some of those issues. So first things first, when we get
hit by this hit actor, I want to stop the character from moving. Okay? Because if I get hit by this,
like so, I can still move my character around and run around. Okay? So, go back to your third person
character, head over to the event graph, So right after this add
impulse, we're going to stop our character from being able to move. So I'm going to get
our character movement. So this is our character
movement component. If I drag off here and get it
on the graph, I can disable our character from moving. So I want to drag off here and
search for disable movement. So we have this disable movement node. And then we can hook this up like so. Okay, so that should stop us from moving. Now, if I go ahead and playtest
this, I can run over here. And now you can see that
it stopped from moving. But you can still see that
the hit actor is still hitting our character over and over. And our character's body is still flying
up in the air every time we get hit. So we only want it to
hit our character once. We don't want it to continuously hit our
character until we respawn our character. So... Back in our third person graph, a way
that we can set up the logic so that it only gets called once is if we go over to
this hit by hit actor, we can move this over and we can actually do a branch. So do a branch and then we
can also add in a Boolean. Okay, so unhook this. Let's go ahead and add a new
variable and this will be called is knocked out question mark. And we want to change this
from a float to a boolean. So compile and save that. And now we can take this is
knocked out, get it on the graph and hook that up for our branch. So if we are knocked out, meaning
if we were hit by the hit actor, we don't want to do anything
because we're already knocked out. Now if we aren't knocked out, we want
to set our is knocked out variable, our boolean, we want to set it to true. So hook that up for the false. So if we aren't knocked out, we want to
go ahead and set that to true because now we are, and now we should only be
able to get hit once by our hit actor. So if I hit compile and save and run
up to our hit actor, stand right here, you can see that it only hits our
character once, and our character's body is just, uh, still right there. Okay. So now we want to add the
reset or respawn event. So that our character will
be able to move back around. So back in our third person
character, we're going to, at the end of here, add a little delay. So I'm going to do a delay, delay node. I'm going to set this to 5 seconds, okay? So after about 5 seconds of our character
not being able to move, we're going to go ahead and reset our character. That way we can continue. To run around so off this completed. I'm going to drag this node all the way
over here and Drop it down here, and I'm going to search for set simulate
Physics so I want to do set simulate physics mesh for our character mesh Now
we'll add that same node that we have up here Now you can see that this little
wire is stretched all the way across here And what we can do is we can even
add a reroute node if you double click this It will add a reroute node that
we can select and move around and it sort of gives us the option to Organize
the way that our wires are laid out. Okay So kind of gives us a clean Way
that we can organize the wires, okay So this allows us to continue the logic
Flow all the way up from here And it continues to flow all the way down to
here You could additionally also add things like a custom event, that way
it could, you could add a custom event down here that you would call over here. Either way would work, okay? So, essentially what we're doing here
is we have to undo all the stuff we did here, so we're unsimulating physics. And then what we're gonna have to do is
we have to attach our characters and mesh. Back to the capsule, because
when we get hit by the hit actor, our character's mesh goes flying
away from our collision capsule. And so we'll have to reattach it. So to do that, we're going to get our
mesh, our character mesh, and we're going to do the Attach Component to Component. So the component that we want
to attach this mesh to... is to our CapsuleComponent, so get
our CapsuleComponent on the graph, hook that up for the parent, and
we just want to do SnapToTarget, SnapToTarget, and then for the Scale
rule, we can do KeepRelative, okay? Then we want to set the
RelativeLocation, because... If you look in the viewport, if
you select this mesh, it has this location set up, this negative
89, and then for the rotation, it's rotated 260 degrees on the Z. So we have to set the location
and rotation so it's perfectly matched and aligned up like this. Otherwise, if we were to reset this, you
can see the position is all messed up. So we have to set the location and
rotation, so in the event graph, we want to get our character mesh. So let's get the
character mesh on a graph. And we want to do a set relative location. Hook this up like so. For the new location,
this will be negative 89. So the same location that
we have set over here. Then we want to set the rotation,
so we can copy and paste our mesh. And do a set relative rotation. And then. For the rotation, let's select our
mesh here, and we have 260 degrees, so I'm gonna do 260 for the Z. Then, we have to reset our character
movement, because right now our character movement is set to disabled. So we want to re enable
our character movement. So we want to get our character movement
component, and do a set movement mode. Character movement, set movement mode. And we want to set this back. To walking. Okay, so that will go ahead and
re enable our input and Basically undo what we did up here. Okay. Now the last thing that we want to do
is we're using this knocked out boolean We want to set this back to false
Because basically or we knocked out we set it to true Then once we launch
ourselves wait five seconds reset the character We want to set that back to
false, that way we can get hit again. So I'm going to get our isKnockedOut
boolean, and set it on the graph, and just set it back to false, okay? So now we should be able to test this out. So if I hit compile and save, and hit
play, and run over here, so if it hits me, You can see that my character is
all the way over there and after 5 seconds it should reset our character. You can see that our character
is attached back to our capsule. We can run around, our movement
is back to being enabled. Now one thing I want to change is the
camera is getting hit by this hit actor. So you can see that the
camera moves in like that. So I'm going to go ahead
and fix that real quick. So if you go to your hit actor
blueprint, go to the viewport. We can actually select this static mesh. Or the hit actor itself, and we
can change the collision settings. So if we go into the collision here,
under the collision presets we can set this from block all dynamic to custom. And then you're going to see that
we have more collision options for different types of things. So in our case we want to
go over here to the camera collision and set this to ignore. So that will ensure that
it does not hit our camera. So compile and save that. Hit play. And now if we run up to our hit
actor, you can see it doesn't mess around with our camera. Okay. So now after five seconds, I spawn back
in and you can see it hits our character. Now let's actually add a couple more of
these different hit actors in our scene. Let's say we want to go
ahead and delete this. And we can do alt drag so if you hold
down alt and drag that will duplicate this let's go ahead and duplicate a couple
of these and Just make like a little obstacle course here Now when I hit play
you're gonna notice they all rotate Pretty much the same way and the same speed. Okay, so How could I? set different rotation rates So if
we go into our hit actor, basically our rotating movement is from this
rotating movement component, and we're using this rotation rate. So what I want to do is I want
to set a variable that we can change in our blueprint that
will change this rotation rate. So in our event graph, what we can
do is we can add a new variable. And this will be our rotation rate. And we're going to change this
from a boolean to a rotator. And we're going to set this to
instance editable and expose on spawn. Okay, so compile and save that. Now we're going to in the event graph,
right click and call our event begin play. Okay, so when play is called on
this actor, we're going to get our rotation rate, and then we're
going to set the rotation rate of our rotating movement component. So we're gonna get our rotating
movement component and do a set rotation, set rotation rate. So now we just plug in our rotation rate
variable into the set rotation rate. So compile, save. Now if we head over to our third person
map, if we select one of these hit actors in the details panel, you're
going to see we have this rotation rate variable that we just exposed. as a variable that we
can modify in our level. So let's actually give
this a default value. So if we go back to our hit actor, let's
select this rotation right here and let's give this a default value of 180. So that is the default rotation. Now, if we go back into our third
person map, you can see that the default value updates for that. So if I select any of these hit actors,
You can see that we have that variable and the default value is set to 180,
but now we can actually customize this. So I can set this to negative 180, so
it should rotate the opposite direction. Then I could do 150, that should
rotate a little bit slower. On this one I could do 190, and
then on this one I could do 140. Okay, so if I hit play you can see
that We have all of these different things rotating at different speeds
and we can basically create a different variety of spinning movement. Okay, just by exposing those
variables for us to modify. So really that is the power of Blueprint,
the ability to take variables and expose them so that you Inside of your level. And this is super useful for not only
things like game design, but also for creating things like blueprint tools. Now, one other thing that you may
notice is if you actually equip your hat, if you run up to one of these
hit actors, you'll notice that our character starts glitching out and
see they're all flying around the map. So that actually has to do with the
collision with the hat and our character. So to fix that bug real quick, you want to
head over to your third person character. Over in the viewport,
we have this hat mesh. So in the details, under the
collision settings, we're just going to set this to no collision. Okay? So set the hat mesh to no collision. Compile, save. And then if we hit play, we
can pick up the hat, and... When our character gets hit, we're
no longer glitching around, okay? So that is the blueprint
for beginners course. We went over what are blueprints,
the blueprint editor basics, all of the different variable
types, how we can do things like get variables and set variables. How we can create blueprint
classes or blueprint actors. And we've created all these
different types of blueprints. Now I will be making a follow
up tutorial to this video called Blueprint for Intermediate Users. So we have blueprint for beginners,
blueprint for intermediate users. And then I'm going to make a
third and final video called Blueprint for Advanced Users. So if you want to stay up to date
and be notified when those videos are released, make sure you hit
the subscribe with the bell icon. Also, drop a comment down below
on what you thought of the video. Maybe if there was a certain concept
or thing that needs more clarification. Let me know down in the
comments down below. Also, if you want to check out
some more Unreal Engine content. Go to my website, smartpoly. teachable. com and check out some of
my premium courses like my multiplayer survival game course. Now that is going to be it for this video. So as always, I'll see
you guys in the next one.