Transcripts
1. Course Promo Video (About the Course): Welcome. In this beginner
game development course, you'll learn how to script your very own
functional gameplay using blueprints in
Unreal Engine five. No coating or Unreal Engine
experienced, needed. Hi, my name is Greg wanderer, a 12-year industry veteran
who has been teaching game development using
Unreal Engine since 2016. By the end of this course, you'll have an
in-depth understanding of all the core concepts driving this node-based approach to programming will cover Blueprint
Classes and components, events, functions, macros,
variables, and so much more. This course is for everyone from the youngest Byron
game designer to the season industry
professional. We start from the very beginning assuming you know nothing. But by the end of
this course will serve as a valuable resource. You can reference
time and time again. So come on, join
the thousands of satisfied students who started their game development
journey with me. I can't wait to see
what you create.
2. Course Primer: Welcome, just a quick primer here before we
get to the good stuff, just so you know how to
navigate this course and extract maximal value from it. First of all, thank you
for choosing this course. I know you've got
a lot of options. I take making these
courses quite seriously. I've spent more than
a year making it. This is my dream course to put together because
I think this is the most foundational
important concept to get when working
with Unreal Engine, you're gonna be learning
some blueprint scripting. What is Blueprint
scripting world is essentially a visual, node-based way of coding
gameplay without staring at a wall of text and
syntax and all that jazz. So if you've never seen what Blueprints scripting
even looks like, I've got a quick example
to show you off here. This is Unreal Engine
five, by the way. In order to create
functional gameplay in Unreal with
blueprint scripts, you can just wire together
some nodes like that. And what I've gotten out
here is just a quick pickup. I've also got this
procedural wall where we can extend how many
pieces we have. All this is done with Unreal Engine is
Blueprint scripting. So who is this course for? I get that question
a lot. Is it for me? Well, I have designed
this course for everyone. I've had students as
young as six grade, as old as 65 take this course. Some know nothing about coding
or scripting somewhere, complete newbies and others
are triple a developer's. I've had students from
Naughty Dog and insomniac. I do at Teach though, as if it is your first time. So no threat in a Hey, I don't understand
anything about programming, anything like that. I start from the
very ground level. So how is this
course structured? Well, we're not
going to be building any one particular
thing in this course. Rather, this course is a
concepts based course, showing off lots of very
useful, practical examples. Now, I tried to make this course as
open-ended as possible, meaning it's meant to serve
as a resource for you, a repository of scripting knowledge that you can
come back to time and time again like a
one-stop shop of all these central
scripting concepts you could ever want and need. I mean, these were
all the questions that I asked myself on my learning journey throughout
the last ten years. Now, because of how this
course is structured, you can jump around
from lesson to lesson. You don't have to go
in a linear fashion. Although I do recommend
going in order. Now there may be a few
lessons here and there that reference previous lessons, but I'll try to call
those out when they occur and keep
that to a minimum. Now, I do want to note, it
is extremely difficult to teach a concept based course
like this, quote unquote, in order because to fully understand the
concepts presented here, we will undoubtedly encounter some dependencies on what that means is that in
order to understand this, you're going to need
to know about that. And in order to know about that, you need to know about this. There's a concept
or skill that is presented and it seems
entirely foreign at first. Know that a, I'm going to call
it out and be I will cover that topic properly
later on down the road. There is a lot, a lot to cover here. And just to give
you a quick primer as to how prepared I am
in teaching this course. I have my outline
right over here. This is the outline that I
use to build this course. Every one of these blue links, links to a lesson. So i've, I've spent literally, I'm actually closer to two years putting this course together. Again, I recommend
going in order, although you can jump around. Lastly, if you do find this
course to be valuable, please leave a review and
recommend it to other, there's no other better thing you can do than to
recommend it to others. I love teaching students
seeing or they can build. Nothing is more exciting to
me than seeing students take what I've taught and they
take it to the next level. Pretty exciting stuff indeed. Alright guys, enough of this. Let's get onto the good stuff. See you all in the next video.
3. Download & Install: Alright, first things first, before we get on with
any of the good stuff, we need to make
sure that you have Unreal Engine downloaded
and installed. If you already do, feel free to skip
over this video. This one is for the
complete newbies that I have no idea where to go, how to get started, et cetera. So using an Internet
browser of your choosing, simply just type in
Unreal Engine.com. Now they do have a page with some download
instructions on it. It'll show you some
system requirements if you're wondering about those, this is good for Windows or Mac, doesn't matter what you got. And the first thing
you need to do in order to get Unreal Engine is to actually download the
Epic Games launcher. Yes, it's a little bit
of a fuzzy process. We have to download the
Epic Games launcher, through which we then gain
access to the Unreal Engine. Weird, I know. But go ahead and click
on this download and launch your option. It's going to ask you to
save this installer package to a file destination
of your choosing. I've already done this before,
but once this is done, you can double-click
on this to begin the Epic Games launcher
installation process, it's pretty straightforward. All you need to do
is click through the boxes that are presented. Again, I've already done that, so I can't really
replicate that here. Pretty straightforward process. Now once you've done that, you should be able to find the
Epic Games launcher either appearing after that is done or you can
search it out here. If I click on my little
magnifying glass here and just type in epic, you can see there's my Epic
Games launch your app. Again, I've already
pre-installed this from here. I can right-click on this and pin to my task bar,
which I've already done. So once the Epic Games launcher
has finished installing, you have access to the
Epic Games launcher, which you've got store, library, and Unreal Engine
tabs along the left-hand side. Because we're obviously
working with Unreal Engine. You're going to want to
make sure that this tab is selected and across the top, you're going to want to
select your library tab. Now this is where
you go to install different versions of unreal. Now, every couple
of months or so, Epic Games is coming up with an updated version
of the engine. But to add any new
engine version, you can simply click on this yellow plus
button right here. It's going to add
this little card and then this drop-down, you can click to
specifically choose a version of the engine
you would like to install. Now, as of today's date
that I'm recording this Unreal Engine
five is still very new and this is the latest
version of the engine. Which engine version
should you install? I would recommend the latest
version, whatever that is. Now, if I click on this again, when you're picking a different
version of the engine, it's going to ask
you to install it. I've already done this
off-camera ahead of time, so I'm ready to launch it, but by clicking Install here, you will install that
version of the engine. And this can be a
rather lengthy process. So once you click Install, you'll see this epic or this Unreal Engine icon kinda
fill up like a meter bar. And also if you click on this
Download option over here, you can see the progress of the installation
of Unreal as well. So go ahead and do that now. Go ahead and then grab
yourself a drink, go have dinner, etc. Because it's going
to take awhile.
4. Create Project: Alright, with Unreal
Engine install, it was time for us
to create a project. And in order to do that, we need to launch the engine. Now there's actually multiple
ways to launch the engine. So I'm going to show you
those methods now here in the Epic Games launcher with Unreal Engine
selected along the left, the library tab selected
across the top. We could launch the version
of the engine we've just finished installing by
clicking right here. In the upper right, there's
a Launch button that will allow me to launch that
same version of the engine. Now if I had multiple versions of the engine installed here, I can click on this drop-down. They would all be
presented here. I could choose one. Whichever engine
version I had selected. That number would appear
to the right here. And again, clicking this
yellow Launch button would launch that specific
version of the engine. Now if all of this
is to inconvenient, you can create a shortcut by clicking this
little drop-down. And you can create a
desktop shortcut here, which I have already done
prior to this video. There is my desktop shortcut. I'm going to click
Launch right here. Okay, eventually you're
going to get to a pop-up that looks like this. We are creating a
gaming projects, so make sure you've got that
box selected along the left. We're also going to
be using the third person template to
help us along here. So make sure you've
got that selected. Over on the right-hand side, we've got some options. This is going to be
a blueprint project which that's
selected by default. That's all well and good. Our target platform here
is gonna be Desktop quality preset, maximum, sorry, content, sure, ray tracing your choice whether or not you want to have that selected, I'm going to say Sure. Project location, you
go ahead and choose a file location
on your computer. However, the project name
for the love of God, please don't leave
that as default as I see far too
many students doing. Change this to
Blueprint scripting. Then go ahead and click Create. Alright, and after
what scenes in eternity after
creating that project, we are getting our first
look at Unreal Engine five, the level editor here. Now if you saw a
little something in the lower right-hand window that said project files out-of-date. Just go ahead and click fix. Now to fix that up. In the upper right hand side, we can see the name
of our project. And I want to point
out that after you close out this project, you can get right
back into this by going through the
Epic Games launcher, the Unreal Engine Library tab
has is my projects section. In any project that
you've created will be listed right down here. So double-clicking
on this will open up this specific project for us, which is pretty handy. Mission accomplished here, guys, we've gone ahead and
created our first project. Let's learn about
Blueprint scripting in the next section.
See you there.
5. Blueprint Example: Welcome back everybody. Well, with our
project now created, let's just jump right in. Let's get to the good stuff. In this video, our goal is going to be to define
what blueprints are in Unreal and then show off an example of one in a game. And doing so will demonstrate conceptually what a blueprint is and how we can utilize these
in creating gaming projects. So prior to shooting this video, I went ahead and
created a blueprint. I created a pickup blueprint
just to get you excited about what we're gonna
be doing here in the first part of this course. This is something that you
see all the time in game. So I thought this would be
a very relevant example. I'm going to click
this green play button at the very top here. And in doing so,
in the upper left, it's going to say click
for mouse control. If I was suppressed WAS and ASD right from the get-go
and nothing happens. I have to click in this window first to gain control
of my character. Now everything you see
here was prebuilt. The only thing that
I built prior to this video was that
spinning cross. If I run my character into it, I collected, I play
a little sound. You see that kind of thing
in games all the time. I'm going to hit Escape
to jump out of here. Now if I go into
my content drawer and if I look at the tool tip, their control and Spacebar, That's also where I can
bring on the content drawer. This is where I can access
the folders and folders upon folders within
my Unreal Engine, I created this
blueprint class is BP example Blueprint class. Prior to this video, we're going to create one of
our own by videos anterior. But I wanted to point out
here with the content drawer, this is a new feature
and Unreal Engine five, you can click on this to
raise it or lower it, or do that control
plus spacebar. However, for those of you that are a little
bit more experience or veterans of Unreal, you can add something nor does the content browser that is a persistent view of that drawer down at the
bottom of the screen. So I'm going to come under Window content browser and choose content
browser wants to just have one copy of the content browser persistently available down here
in the editor. You don't have to do that. That is my own
personal preference. This is the exact same
as the content drawer has the exact same folders,
content, et cetera. Alright, The reason
I'm doing this is because I want to create a new folder here inside
of my content folder. So I'm going to right-click on my content folder right here. I'm going to create a new
folder and I'm going to call this one scripting. Then I'm going to right-click on this new scripting folder. And I'm gonna give it
a color right away. And I'm just going to
left-click, move this around. I'm going to set it
to blue because hey, this is a blueprint
scripting course. Alright, The reason I'm
creating this folder is because a lot of the assets that we're gonna be creating throughout this course. I want them to be how
specifically in this folder for easy access for me so I know
exactly where they live. Now along the
right-hand side here, I can create different
types of assets. And I can do that by right-clicking
and some empty space. In MI right-click menu, I can create a new
blueprint class. Now this would be a good
time for me to talk about what our blueprints in Unreal. So this term, blueprints, it kinda means two things here. Blueprints is the
visual scripting system inside of unreal, sometimes referred to as
blueprints scripting. But blueprints are
also assets like Blueprint Class assets that may contain specific components, data or script that helped your game in some
way, shape, or form. There are a lot of different
blueprint types in unreal. Now this whole blue
printing system, it is a way for non
coders such as myself to create functional
gameplay inside of Unreal, which is pretty sweet. So in a way you are
going to be coating, but in a very artistic manner. So what does that mean? We're gonna be wiring together some nodes and it's gonna
be way more visually appealing than ones and zeros and curly brackets and
all that kinda stuff. So here I'm going to
choose a blueprint class. When I click on this,
we're going to have to pick a parent class. Again, lots of different
types of blueprints, but by and large the most common is the actor
class blueprint. This is an object then that can be placed to
respond in world. So let's go ahead
and select this. Going to create that
asset down here in our content scripting folder. Let's give it a name. I'm going to call mine BP
underscore scripting example. I believe that's the name
I want it to give it. Example, pick up
no example pickup. That's the name I
wanted to give it. Example pickup. That's why I keep notes. Hit Enter. By the way, if you want to
change the name of this, you can right-click
and rename it F2 while having it selected will also
prompt you to rename it. If I was to place this
into my level right now, you can just drag and drop it
from your content browser. You can see that
there's an icon here. But if I was to
jump into my game, I wouldn't actually
see that thing. That icon is only available in viewable
here in the editor. I don't see it when I'm
playing the game itself. Now currently I have
rotational mode on this hits to some
basic navigational stuff. Rotation mode is on. You can go back to movement
mode to move this around. Alternatively,
your spacebar will toggle between movements, rotating, or scaling
your objects. All of those have hotkeys
associated with them as well. Alright, so that's
all well and good. The asterisk down here show
that it's not been saved yet. So Control plus S will say that, or you can right-click on
it and click Save as well. One more thing I
wanna do before we close out this video is I want to create a
brand new tests level. We're actually not going to be working inside of this level. This is all for
demonstration purposes. So I'm going to come under
file in the far upper left. I'm going to create
a brand new level. When you do that, it's
going to prompt you to select one of these
different templates. I'm gonna go with the
basic level here. Click Create. That's going to take me
out of this level and into a new untitled level. Now few things we
have to do here. One is I need to
save this level. So if I click this little
save disk icon up here, it's going to prompt me, hey, where do you want
to save this level? I'm going to put this
in my scripting level. I'm going to give us a new name and I'm going to call this LV underscore tests map. This whole map is just
gonna be a giant testing. Now for all of these
different blueprints concepts we're going
to be exploring throughout the course. We're going to click Save here. The name of this tab will
now be changed to test map. You can see that asset now lives inside of my
content folder. It'll automatically create
this test Mab build data. You don't have to do
anything inside of this one, but it'll automatically create this as well in your folder. There's one more
thing I wanna do here inside of our project settings. You can find that in the
far upper right settings, project settings. It's going to bring
on a new tab. Over on the left-hand side,
we've got maps and modes. Go ahead and choose this. We want to change
our editor default, start map from third-person map to the map that we just created, a level test map. We can simply exit out of here. And what this will do is make
it so that once we close out of the editor here
and open it back up, will automatically come
inside of this level. We don't have to find this level here in our content browser. So that's all well and good. I'm going to finish
off this level very quickly by jumping into that blueprint example that I had created in
my content folder, I can just simply
place one of these in my level and jump into
my blueprint example. Right here, I've got
this viewport tab that shows the different components
that make up my blueprint. And then I've got
this event graph that shows the scripting, the nodes and wires that created the functionality for this
particular blueprints. I overlap and it plays a sound
and it destroys the actor. So that's essentially what
we're gonna be building throughout these next
few videos here. But guys, that's gonna get us as far as I wanted to
get in this video. So we'll see you
in the next one.
6. Components Panel: Welcome back everybody. In this video, our
goal is to add some components to our newly created
blueprint to give you an understanding of what
the Components panel is inside of a blueprint and how to make the most
of working with it, because there is
a lot of nuance, a lot of good things
to know that will save you a boatload of time. Alright, Before we get to that, I want to kill out
this BP example that I'm read prior to the
start of last video. So we're going to say
bye-bye to that by clicking Delete right there in
the Content Browser. Alternatively, your
content drawer. I'm going to come
into my scripting folder and I'm going to place my BP example pickup
into my level. Again, there is nothing
inside of this blueprint yet, so I see this icon, but if I was to play, I wouldn't see anything. Now there's a couple
of ways we can go about modifying this blueprint. One is we can
double-click on his asset itself down in the Content
Browser slash drawer. Or with this object
placed in the level, you can click over in your
outliner where you've got BP example pickup
selected and right there is edit BP example pickups. So I'm gonna click on that. And if you see that
this is a data only Blueprints
sometimes happens when you open up a blueprint, you can simply click
right here to open up the full blueprint editor. Alright. This is our blueprint editor. I'm going to click on the
viewport tab right up here. We're gonna be breaking down every aspect of this
in detail here. But I'm going to the
viewport tab firstly, because we're gonna be adding some components in
the Components tab that we will then be able to
view in the viewport tab. I should point out here, we did make an actor class
blueprints in the last video. And lo and behold, the upper right-hand corner, it says parent class
is the actor class. Alright, so let's go ahead and talk about what are components. Components are essentially
the building blocks of a blueprint. If you think of a car, the construction of a car, a car blueprint would
have a mesh body. You would have some wheels, it would have some headlights, horn, maybe some exhaust smoke. All those components
could be added here in the Components panel. Now by default, the
Components panel is located in the upper left of
the blueprint editor. Now, you can resize this window by left
clicking and dragging here. You could tear off
this tab right here and place it someplace
completely different. Say down there. I choose to have it
back where it was. You can hide and show
the components tab. If I was to simply
right-click on this, I could hide that tab. If I click on that blue
little flag there, I can show the tab. I can right-click
on this and dock to the sidebar and move it
over here if I wanted to. And I'm just simply
clicking on it like so I can right-click on it again in undocked
from the sidebar. Lots of options here. I can also get rid of
this components panel all together by
clicking on that X. Students do this
from time to time, then they freak out and wonder, how do I get that window back? Well, if you come under your
Windows option up here, lo and behold, you have
a components option. There you go. Alright, let's add some
components to our blueprints. So we got some
pretty look at here. We've got this Add
button right here. But true to the
nature of unreal, if there are multiple
ways to do things. So I'm going to
try to demonstrate multiple ways to add components. Let's click this Add button here first and add a brand new. What we want is a sphere
collision and components. As you can see, lots of
different components here in Unreal, don't
get intimidated. There are some of
these that are used way more commonly than others. One of those that is
very commonly used is the sphere
collision component. This essentially
provides you with an invisible sphere that
we can check to see if your character
overlap to do things. So I'm going to call this
sphere underscored collision. You can give it a name up there. And with that components selected over in
the Details panel, I'm going to change
something about it. I'm going to change the details, the sphere radius to be 50. We'll deal more with the Details
panel in a future video. I'm also going to add a cube. And I'm going to call this
cube underscore horizontal. I can use my mouse wheel
to zoom in and out. I'm just gonna give
us a rough scale. I may adjust this at some point, but with this unlocked, I'm going to change this
to be 0.25 in the x, 0.25 and the y kinda thin it up. And I'm going to
change the Z scale to be 0.8, something like that. Now I can right-click on this. I can duplicate this one
because I'm going to create that cross shape that
I had in the last video. And it's prompting me
to give us a name. I'm gonna call this
one cube vertical. And this one I will keep truly vertical
because the last one, even though I call
it a horizontal, it is standing vertically with the cube
horizontal selected. I'm going to choose
rotation mode up here. You can press the
space-bar as well. And I'm going to
simply rotate this down to be 90 degrees, like so. Okay, let's add another
component. Shall we? How about we add
some fire to this? Sure, Let's add a
particle effect. I'm going to detach
this tab right here. And I'm going to undock it, place it somewhere over here. And the reason I'm doing that is down in my content browser, I'm gonna go into
my starter content. I'm gonna go into my
particles folder. Here I see a P fire particle. Now this is an older
particle system. In some future years are probably going to
get rid of these. The newer particle system
is known as Niagara up. So you don't have to use
these older particle effects. You can use a newer Niagara
particle effect when they, I'm sure we'll have those available in a starter
content folder. But what I wanted to
demonstrate here is I can left-click right here
in the Content Browser, drag this right up in to my
components panel like so. And you see that box
surrounding my cue horizontal, I'm just going to drag
it right on top of it. And I can see I've added
that to my blueprint. Now something else I wanted
to note there is that as we added this to our blueprint inside of our components panel, it added this to the instance of this blueprint
that is in our level. So as you can see as we modify things here inside
of our blueprint, it's going to modify and
update any instance, any copy of this
blueprint that we have placed in our level, which is what makes
blueprints so awesome. Something else I wanted
to point out here is, is sort of
relationship going on. You can see that
things are indented by dragging my P fire on top
of my cube horizontal. It actually made
it so that it is attached to this
horizontal cube. So if I was to select my
horizontal cube right here, let me just go back
to full sizing this. I've got my horizontal cube
components selected here. If I move this, the fire comes
along for the ride. I'm just gonna do Control
Z to back that up. However, if I was to select
the fire itself and move it, nothing else is
attached to the fire. The fire was attached
to the cube horizontal. So I'm gonna do Control
Z to undo that. If I didn't like that
it was attached to it, I can simply drag and
drop this bag on top. And now it is showing
as not being attached essentially when anything
is indented like this, it shows that one thing
is attached to another. So right now my two
cube mesh components, they are attached to my
sphere collision component. Now just because I want
to show off more of this sort of things
being attached. I'm going to drag
this right back on top of my cube horizontal. No reason for me to do
that other than just because I'm going to
undock this again, places just like so. What else do I want to add here? I want to add some, let's add some smoke, showy. So I'm going to grab a
smoke right up here. Actually let me do this. I'm going to put
this backup top, gonna go back to my test level. Here's another way that you
can add this component, grabbing my smoke,
left clicking, dragging it up to my tab. Now that tab
automatically opens, and now I'm going to
drag and drop this on top of the fire. So there, I just added
another particle effect. Now again, the smoke is
attached to the fire, which is in turn attached
to the cube horizontal. So if I was to move the
cube horizontal component, the fire and the
smoke comes with it. Control Z to back this up. And as you can see back
in my level editor here, it's smoking with this
instance of the blueprint. Pretty cool. Alright, I want to add, let's add something else here. I want to add going back inside of my blueprint
example pickup, Let's add some rotational
movement to show him. So I click under the add components in a
search components area, I can search for one
called rotating movements. So yes, you can search
for components. I knew that this one existed, so I knew by searching for it, I would whittle it down. Now by selecting this, it's going to dock
it kinda down here. This is sort of a
special component in that is not
attached to anything. You cannot attach a
rotating movement component to any other component. This essentially affects
every other components here in our blueprint. Now with this selected
over in the Details panel, you can adjust its
rotation rate. Now currently it's going to
rotate along the z-axis. You've got x, y, and z axis is that you can rotate
it on at a given rate. Now we don't see anything
rotating right now. However, if I was suppressed as Simulation button at
the top of the editor, you would see it spin. Now it's simulating on, I'm going to click
it again to stop it. I could change this to, let's say 2 thousand. And then click Simulate to
see it spinning much faster. Going to set that back
to its default value by clicking this
little back button. Okay, great. So if I was to go into my
level here and I was to play, well, if I was to play, I
wouldn't be running around. I wouldn't see this
actually spinning because I don't have a place actor or an actor placed in my
level in which to spawn. So coming under my Add button right up here at the
top of the editor, I'm going to come
under basic actors. And I want to add a player
start actor to my level. I can simply left-click
and drag and drop. And with this actor
does, is it defines a spot in my world
where I will spawn in this blue arrow pointing to the direction that my
character will be facing. So now if I was to click play, I would be playing. And I can see that all spinning. Yes, everything spins,
including the fire and the smoke because
it is all attached. I know it doesn't look great, just showing off
different concepts. Alright, let's add one more
component to our blueprint. And this one is also going to
be done in a unique manner. I want to find a given piece of audio too attached
to this blueprint. So what I'm gonna do here is select our blueprint here
in the level editor itself. And look over in
the Details panel. I'm going to peel
this down right here. I can see all the
different components that have been added
to this blueprint. And from here, I can
add a component. So let's try adding it
from here as opposed to in our blueprint
editor itself. So I'm going to click Add, and I want to add
an audio component. And in doing so,
it adds it here. However, if I was to jump into my BP example pickup that I had created here
in my scripting folder. Let's jump in there right now. I don't see that component
anywhere in here yet. So how do I make sure
that that change here to this instance of the blueprint propagates to my base blueprint. Well, if I click this
button right here, edit blueprint for this actor, let me click right there. What I can do is I can choose
this option right here, apply instance changes
to the Blueprint. So in doing this, I get a little notification
right there. And then if I go back to my
blueprint example pickup, I can now see that
that audio component has been added as well. Now once again, there
are many types of components that can be
added to a blueprints. There are many of these
I've never even used, but there are some that
are very commonly used. And one thing I
want to get across early here is on
working with unreal. There's so much to know, but you do not have to know
it all by knowing some of the key core concepts you
can get very, very far. So don't get intimidated
early on here. Common types of components
include static meshes. You've got some lights
that can be added. Where my lights,
There's my lights. You've got your
collision shapes. And then you've got
some of those movement. Once you solve the
rotating movement, There's one called
interpretive movements. That's pretty commonly
used as well. All right, a couple more
things I wanted to point out in this video
before we wrap this up, one has to do with this
attaching relationship that we have going inside
of the Components panel. One thing to note is that
with a given components selected that is attached
to something else, the location listed in
the Details panel is relative to the thing
that it is attached to. So right now I've got my cube horizontal
components selected. And that is attached to my
sphere collision component. If I was to set the z
location to be 100, that's going to move it
up 100 unreal units. Each unreal unit
represents one centimeter, 100 unreal units above the center point of my
collision component. So just know that all these
locational settings are relative to whatever
it is attached to. I'm going to set this back. Also wanted to point out that
you can change the root. Notice that when we created
this blueprint by default, it had this default seen
route in this editor here. That was that icon that
existed there before. Everything else is attached and their location is
relative to that route. You can change the root
component by simply selecting, in this case, I'm
going to select severe sphere collision,
not severe collision. I'm going to drag it and
drop it on top here. And it's letting me know
if I drop this here, I'm going to make
this the new roots and that the default
route will be deleted. Sweets, that is
now the new root. Everything else is positioned relative to my sphere collision. Last thing I wanted
to point out here, and what makes
blueprints so awesome is that by having one
blueprint actor created here, if I make a change inside
of this blueprint, it'll change every copy
that is every instance of this placed in the world and just demonstrate
that very quickly here. Can you go back to
my test level here inside of my scripting folder. I'm just going to place a few of these
throughout the level. By the way, you don't have to
keep dragging and dropping. You can hold the Alt key and left-click to keep dragging
out copies of these. Alright, so I've
got five of them. Now let's just say, I
think, you know what, that's spinning, fire and
smoke looks kind of dumb. I can go back into my
example pickup here. I can select my smoke. I can say delete. I'm just gonna do
Control Z there and say, You know what, I
want to get rid of the fire and the smoke. So I'm going to select
my fire and hit Delete. It's going to delete that out. I'm going to then
delete out the smoke. And now if I jump
back into my level, that's gone for
every copy of these, I do want to get rid
of those, yes, indeed. So I'm gonna go back into my
blueprint example pickup. Let's save this. And that's going to be all we wanted to accomplish
in this one. The Components panel guy is a very important part to
know about blueprints. It's gonna do it
all for this video, we will see you in the next one.
7. Viewport Tab: Welcome back everyone. In this video, our goal is to understand what the viewport tab is
inside of a blueprint. Now this is our window into what our actor class blueprint
is going to look like. Through this tab, we can
fine tune the placement of said components in
relation to one another. Now the viewport tab can
be found right up here. We've got three different
tabs, a viewport tab, it Construction Script tab, and then Event Graph tab. Each of these is going to
warrant its own video. So don't worry, we're gonna
get to those other ones. Let's start off by talking about the different
viewport options. That is, what is
found underneath this little hamburger icon
in the very upper left. So if I click on this, I'm presented with
four different options of which I have two of them on. By default, this
real-time option and this Show Grid option. We'll get to all of
those in a little bit. So let's reset camera one. If I was to click
on this right now, doesn't really seem
to do all that much. It just kinda jump
my camera back to show everything in my blueprint. Right here, front and
center in my viewport. Now, where this really
comes in handy is sometimes you've got a lot of different components here
inside of your view ports. Or sometimes for whatever
reason you have flown far, far away, such as I
am doing right now. And you're like, Where
is all my stuff? Where are my components? If you simply come under
this hamburger icon, click on Reset camera. It'll jump you right
back to where you want to be and you will sigh. Sigh of relief. Next up we're going to talk
about the real-time option. It is checked on by default, but we don't have
anything animating here, so it's hard to really
see what this does. I'm going to jump to
another blueprint to show off what it does here. So I'm going to jump back
to my level test map inside of my content
browser or content drawer. I'm going to come onto my
third-person Blueprints folder. There's my B P
ThirdPersonCharacter that is a character that we
are currently playing as when we hit this Play button, I'm going to
double-click on here to open up this blueprint. And again, if I click
on the viewport tab, I can see all of the
different components that make up our
ThirdPersonCharacter, including a camera, and
that's the camera that we're looking through when we
are playing our game. Now if you zoom up on this
character slightly and I'm just mouse wheeling in here you can see our character
animating a little bit. They're playing an
idle animation. Well, if for whatever reason I want the character
to just hold still, I can click this option. Turn off real time. It's got a hot key
associated with it as well. So if I do Control and our that'll toggle
that on and off. Pretty cool. All right, jumping
back to my BP example, pickup, coming under my
hamburger icon wants more. I've got the show floor option. Now this is off by default, but it's not showing floor here, which is rather odd. I'm going to turn this off. Let me go back to my
ThirdPersonCharacter and show floor. There we go. There is our show for option. I don't use this too often, but every once in a while, you do have a bunch of
components and say we're building out a car or
something like that. This can give you a better
sense of scale and just how things are laid out in
relation to one another, as opposed to just
a character or an actor class blueprint that
is floating off in space. Jumping back to my BP
example pickup once again, underneath the
different options, we've got the show grid. Now it is on by default and
you can see it's down here. I can toggle that off. And why that's useful
to show or not show. I'm going to demonstrate
here in just a bit. I'm going to show my grid and
now I'm going to lead into the discussion of
our different views here, jumping one over. Currently this is the
perspective viewport. This is kind of your
beautiful view. However, if I was
to click on this, I've got different
orthographic views that I can jump
our viewport into, such as a top view. This is kinda a bird's
eye view of things. I've got a left view looking at it from a left angle and you can mouse
wheel in and out. A front view. We're seeing the cross, not in the cross side, but more the side, side. And each of these has a hot
key associated with it. Now where the grid
really comes into play here is you can see these
different grid marks. So you may be wondering, well, what size does each of these
grid squares represent? Well, that is where we
lead into discussion of our different grid
sizes right up here. So if I was to click right here where this number five is, I can show different snaps
sizes, 1510, etcetera. It's currently set to five, meaning each of these
tiny squares represents a five-by-five unreal unit area. Now this is super handy
and I'm just going to jump to go to top view. If you're wanting to move
components around and you want them to jump
certain increments. So I've got this
snapping movement Snapping currently set on. That's what this blue
represents it over here I'm going to set my
snap settings to 100. Now notice that once I do this, the grid size is
changed to match. So this is now 100 by 100 as a grid size as opposed
to what it was before, which was five by five. So I'm going to change
this back to 100. Now let's just say
I want it to move my cube horizontal
mesh over here, over 100 units by left
clicking and dragging it, I simply jump it over 100 units. Now you can see if I move
this around in the top view, it is jumping it by
increments of 100. And you can see that reflected here in the locational settings. Again, these locational settings are relative to the root. Now, if I wanted to move it
in a more smooth fashion, I could turn off the snap settings when
it's not blue like that. That means I can move
it quite smoothly. But sometimes you do want to move it in very
discrete increments. And that's where that
really comes in handy. I'm going to set my
location here back to 0. And I'll turn my snap settings
back on and set it back to five while we're here and
talking about all of this. This is probably a good
time to talk about our different settings
here in our viewport. Currently, I am in the
translating objects mode. I can click right here to
change this into rotation mode. Like so. You can see right now, let me just jump out here
back into perspective view. You can see as I'm
rotating this, it is moving it in
increments of ten. And it's moving in increments
of ten because I have my rotational snap settings on, meaning it is going to move
it in increments of ten. And if I was to
click right here, I could change what increments. It is going to rotate it by. I like ten degrees, but there are cases
for these other ones. I also have scale mode
that I can turn this into. So I can go to my scale option. And now if I was to simply
grab one of these handles, I'll grab that blue
handle right there, which represents the z-axis,
the relative z-axis. In this case, you
can see how I am adjusting the scale of this. I'm going to set this back
to what I had it before, which was 0 points. I think I had it at points 8.8 indeed is what I had it at. So W, E, and R, as you can see in
those tooltips, those can jump you into
the different modes there, which is the movement mode, rotation mode, and scale mode. Clicking on these buttons
will do it as well, but w ENR can jump you into
those different movement, rotate and scale modes. However, the spacebar
will toggle between all three of them as well. Next, let's talk about our
different lighting modes. Currently by default,
this is in Lit mode, but if I click on this, I can change this
into unlit mode. Again, all of these have
hotkeys associated with them. Or wireframe mode. Not too many times I use
wireframe or unlit mode, but they are there in
case you do need them. What happens if you accidentally
close out this tab? It does happen quite often, more often than you
think actually. And then students are wondering, Where did it go, how do I get it back? So I'm going to do that
right now by closing it out. Well, the way to get
it back is simply to come under this window option. And then down below
you can click in turn your viewport back on. There are other view-port
options here that you can access by
right-clicking on it. You can dock it to a sidebar. What that does is it's
gonna jump it over here. And so if I was to click on it, I would expand this open. If I pin it, that means
I can't get off of it. So if I unpin it, I can right-click it and it will move it back
to the sidebar. If I right-click it again, I can undock it. So I can also close
it from here, which I did before closing it is the same as
clicking on this x. I can close the tab
to the right of this meaning of that
construction script or the event graph. If I get rid of those
guys, oh, they're gone. Those are not found under
the window option here. So to get those guys back
in the My Blueprint panel, you can double-click on the Event Graph to
bring that guy back. You can double-click on
the construction script as well to bring on
that particular tab. Next up, let's talk about
moving around the viewport. If I was to hold down the left mouse button and
simply move my mouse around. This. Driving in the viewport. By the way, these
are the same control back in your level editor. If you were in your
level editor window, left mouse button and moving
your mouse around drives. Right mouse button simply looks around here at
your level editor, as well as inside of your viewport for your
blueprint middle mouse button. And moving your mouse
around will simply keep it on the same 2D plane
and move it around. Middle mouse button plus, or I should say a
middle mouse button or left and right mouse, right mouse buttons together. We'll do the same thing again
back in the level editor, middle mouse button,
moving it around, left and right mouse
buttons together. Moving it around,
does the same thing. And then last but not least, is my favorite way to
navigate around the viewport, holding down the
right mouse button, and then using W, a, S, and D to fly around. Now the speed at
which you fly around, let me jump back into
my viewport tab of my blueprint that is determined by this
guy right up here. Your cameras speed sliders. If you click on this, you
can set this up or down. So now I'm gonna fly
around super fast. Or if I send it lower, I am flying around super slow. Now one thing to note here, the default is for
if you're to fly around and you're using your
mouse wheel in and out, scrolling up or down, you can actually modify how
fast you are flying around. So that is a good handy
trick to know as well. You want things to note
before we close out this video, the root components. In this case, I've got
the sphere could have collisions set as my
root two components. I can not move the
root components. You can see I can't really go
about selecting it here in my editor outside of simply selecting it in
the Components panel, you can select it,
but as you can see, I can't change it into translation mode or rotation
mode or scale mode. It keeps me in just the
select object mode, which is the Q hot key. And you can see over in
the Details panel to, I can only scale this. I don't have the option
to move or rotate it. Also, I wanted to remind you all of the relational aspect of the Components panel and how that affects moving
things around your viewport. If you remember the last video, I added this audio
component which is buried inside
of my cross here. Let me just move this guy up a little bit because it doesn't really matter where I place it, just that icon right here. I'm going to add this to my
cube vertical component. So again, if I was to move my audio component
around by itself, it will move independently. But right now it is
attached to my Q vertical. Supposed to move
that guy around. The audio component is going
to come along for the ride. So this relationship
is quite powerful. Use that and remember
these locational settings, these are relative to the
thing that it is attached to. If you don't like this
attached relationship, you can just go like this, drag at the top again
and it will not indent showing it is not
attached to it anymore. The last but not least, do not forget about
your snap settings up here in the viewport when you are moving
something around, rotating something around
or scaling something. And please, please,
please don't forget that you can modify your
scale snap settings, your rotational snap settings, and your movements
snap settings that can save you a lot of time as well. All right guys, that
is viewport tab. In a nutshell, hopefully, a lot of those tips
and tricks will save you a lot of time. That'll do to offer this one. We will see you in
the next video.
8. Details Panel: Welcome back everyone in this
video or goals to learn all about the details panel
inside of a blueprint. Now, blueprints are composed
of all types of things. We've got components. We've got variables which we haven't even
talked about yet, but will, and even information about the blueprint itself. Now all of this data, all of this
information is set by you inside of the details panel. Now, by default, the
Details panel is located over to the right here within
your Blueprint editor. Just like any other viewport, you can simply rip it off, left-click, drag it to some other part of your
editor window here. Some people like to
put it right below their components
panel because there's selecting various components
and then they like to change the details
right down below. I however leg get
right where it is. So I'm going to
dock it back there. Walla. Why don't we change a few different details about
some of our components. And right now I'm eyeballing are two different static
mesh components or cube a horizontal
and cube vertical. Right now we've got this sort of white cross for a health pickup. I think it'd be nicer if
we change it to green. So I'm going to choose my
cube, horizontal here, and over in the Details panel, I can change the material
that is applied to it. Right now I've got this
basic shape material. I can left-click on
this and I can choose one of these different
types of materials. I liked this basic asset, O3, that's pretty cool. Now, if you're not seeing this, or maybe you want access
to more materials. If you click on this little
gear icon right here, you can turn on and
show engine content. And that's how I'm
seeing more materials than you are at
first glance here. So if you also have
some plug-in content, this is how you can
turn that on as well. So showing engine content will review more materials for you. I'm going to use this basic
asset O3 to change his green. And I'm gonna do the
same for my cube vertical with that selected, changing the material
here by clicking on this drop-down and we
change it to green. That is all well and good. Now also, maybe I want
my sphere collision here surrounding my green cross here to be a little bit bigger, a little bit more of a
generous pick-up area, if you will, right over
here with a sphere because collision components selected in the Details panel, I can change my sphere
radius by clicking on it and punching in a new number
like 100 and clicking Enter. Or in these numerical fields, you can simply
left-click and drag. Let's see, clicking off with
and clicking back on it. And then you can move
it left and right to adjust it that way as well. I'm gonna go with the
number 100 for now. That seems pretty generous. Now once again,
if you mistakenly close out this Details panel
by clicking on that there x, you can come under the window
option and turn it back on. Now there are different
viewing options you should be made aware of. Over in the Details panel, you've got this gear icon. If I click on this, there's a bunch of different
options available to you. I'm only going to be
talking about a few of the more commonly used ones. One of them being collapsed
and expanding all categories. So right now I am going to
collapse all the categories. So yeah, now if you
want to get into them, you have to click
on them one by one. That can be useful if there's only a few different categories
you want to fiddle with. I'm going to go on
into this again, and I'm going to
expand all categories. Another one I like a lot is
show modified properties only or show only
modified properties. So clicking on this, it's a really easy way to see at a glance what are the
things that you've actually changed about
this particular component? I'm going to turn
that one backoff. Then show all
advanced properties. Now what are Advanced Properties under each of these
given categories? I shouldn't say each but
many of them there are advanced properties that by
default aren't expanded upon. So for example, I've
got my shape and I can change my shape
color if you will. Let me just click off of this. By default, it's red. But if I was to click back on my sphere collision under
the advanced category, I could change this to hot
pink if I really wanted to. Sure, why. Nuts. Now there's also this little, I don't know what you call that. A little bit of a
notepad type of icon. This will open a selection
in property matrix. What is this now
this is an option I do not use too frequently. However, if I was
to click on this, it's going to bring
open a new tab here. This is another way to go about changing
different properties. Again, everything
is collapsed here, but if there's
something that you wanted to change about it, you could simply pin it. I'm going to pin this
option right now. Does generate overlap events. You can see that this
is checked if I was to uncheck it here and then go back into my b p example pickup
under sphere collision. Under the collision
properties does generate overlap events
is no longer checked. I'm gonna change that back to where I had it and I'm
going to close out of here. I just wanted to
show what that is. I don't use that too often. You may find some
good use for it. And then you can see here with
vacuum I sphere collision, I can see that generate overlap event has
been checked back on. Now along the top
on our toolbar, we've got this class
default option that I wanted to
make you aware of. I'm going to click on
this and when I do, I'm going to bring
on a whole set of different details about this actor class
blueprint that are specific to this actor
class blueprint. Now there's not a lot that
you need to change in here, although I will
make you aware of one that's kind of fun
to play around with. And that is with class default selected initial life span is currently set to 0,
which means infinite. But if I was to set this
to something like three, that means this
guy is going to go away after three seconds. And I can prove this by simply clicking the play button here. And that's going to jump
into my level editor here by playing in
after three seconds. They all go by, by kind of
fun if I do say so myself. So I'm going to change
this class defaults my initial lifespan back to 0. So again, these impacts
certain things about this particular class of
blueprint, the class defaults. Next, I just wanted
to make you aware of the button over here, this class settings option. Later on in the course, we're gonna be dealing
with something called a Blueprint Interface. And that's going to get
all set up in this area. Nothing else I want
to change in here. In fact, you don't deal with
class settings too much outside of implementing things called a Blueprint Interface. But I just wanted to
bring that up now. So later on down the
course, you'll be like, I know exactly where to
go and what that is. Alright guys, that is
the Details panel. Know it, love it,
make good use of it. That'll do it all
for this video. See you in the next one.
9. My Blueprint Panel: Welcome back everyone. In this video, our goal is
to learn what the purpose of the My Blueprint panel is within an Unreal
Engine blueprint. Now this is an area of
a blueprint where you can create things
like variables, like functions or macros to help shape what a given
blueprint can do. Now if you're unfamiliar
with terms like variables, functions, or
macros, don't worry. We're gonna be breaking
those down much further later on in the course. For now, it's just good to
file away knowledge that the my blueprints panel here is where such things
can be created. So as you see here
in my BP example, pick up the blueprints panel, by default is located in the lower left-hand
corner of the interface, just like any other tab here, you can left-click on
this and you can drag it around to wherever you like. I like it where
it is by default. So I'm going to leave
it right there. Just like other tabs here, you can right-click on it. You can close it out. You can bring it back on
via the window option here, checkmark shows that it
is in our blueprint here. No check mark means
that it is not present. So I'm going to
bring that back on. Right-click options here. I could hide the tab. That'll just kinda barrier
that tab gives you a little bit more
screen real estate that oddly comes in handy
from time-to-time. Left clicking on it will
bring that tab back. Right-click. I can dock to the sidebar like I could before. Right-click on dark as well. You've seen me do
that several times. Alright, another option I
want to point out here in the My Blueprint
panels, this gear icon. Now if I click on this, it shows me various options showing empty sections
I have on here. What this does is it'll show any empty section,
any empty category. Right now, I have no macros
in my blueprint here. If you don't know what that is, again, don't worry about it, but just know that if I
was to turn this off, I wouldn't even
see that category. So by showing this and I like to have
it shown by default, I will see all the different
empty sections that we may have under the
blueprints category. Another important one
to point out here under this gear icon is this
show inherited variables. Now this is gonna show
inherited variables from parent classes. Now, in our case, our parent class here is
an actor class blueprint. So I'm going to
show this quickly. And when I do,
you're going to see some categories appear
right down here. So here we go. We're going
to show inherited variables. And I'm going to drill down
into my actor category here. And what do you know? I see a variable called
initial lifespan. Well, that looks
rather familiar. So what are all of these variables in these
various categories? Well, if you remember
from last video, when we clicked on our
class defaults button, we have a lot of
different parameters, a lot of different
properties that are specific to this actor
class blueprint. And one of these located under the actor class blueprint
category was initial lifespan. Lo and behold, that can
be accessed in here, the my blueprints panel as well. We show inherited variables. So this is another
way of having all of these class default
variables show up, not just when you click
in class defaults, but over here in the
My Blueprint panel. And I just want
to point out here that if I was to click on the initial lifespan variable and go over to the
Details panel. I can change my initial
lifespan to S3. Now if I was to go into the class defaults and find the actor category
initial lifespan. It's set it to
three here as well. So you're changing
the same property, just two different ways
to go about doing it. I'm going to reset this
back to where I had it. And note now that while I changed it here in the
class default section, if I was to click on my
initial lifespan property, it changes it back here as well. Alright, let's hide those
out back again so we can clean up our My Blueprint
panel here a little bit. So show inherited
variables. Nope. Let's talk about how to create new variables,
functions, or macros. We can also create new graphs
and event dispatchers, but those will have
their own sections later on in the course. If we click this Add button, it says you want to
create a variable, a function, a macro, a graph and Event Dispatcher. You can do it that
way or with each of these different categories
here you've got this little plus button
to create a new graph, a new function, a new macro, or a new variable, or an Event Dispatcher. Let's go ahead and
create a variable here. Even though that's not what
this video is all about, variables will have its own
a couple of sections here. We're going to
create one just to give you a sense of what this whole my
blueprint area does, I'm going to create
a new variable by clicking on this plus button. I'm gonna give this a
name and call it hiccup. Sound like so. Now next I need to
decide what type of blue or what type of
variable I want this to be. By default, it
usually shows Boolean when you are creating a variable
for the very first time. Or it'll set the
default variable type to be whatever you last created. Now before I created this video, I did a dry run and so
it's currently set to the variable type that I'm looking for. So how
do you change this? We can click right
here to change it. Or with his variable selected
over in the Details panel, you can change it
over here as well. So under variable type, click this drop-down and do
a search for sound base. In the little fly-out
menu here you want to choose the
object reference. Now in doing this, it will prompt you to
compile your blueprint. Again, it's showing my
default value here because I already did a dry run
prior to the video. But if you compile here, it will then allow you to slot in a sound of your choosing, clicking on this drop-down. I like the interplay sound. So if you do a search
for enter, play, and mouse over that
particular sound wave file, it shows in that little
pop up that appears that this comes from
the engine path. And once again, if you
don't see this sound, if you click over
on this gear icon, you can show engine content and you should have
access to that sound. Now you could really
slot in any sound here. This is just the
one that I chose. So feel free to slot in
the sound that you want. Now we're not going to make use of this variable just yet. That's going to come in the next video when we talk
about our Event Graph. But just to summarize here, the My Blueprint panel, this is where you house, where you create
things like functions, things like macros,
things like variables, and where to access
those things. Last thing before we
wrap up this video, you may have already
notice that all of our different components up
here in the Components panel, they are also displaying down here in the variable section. And this is a quick and easy way that we can add a reference to each of these different
components into our event graph. But again, we're gonna
be making use of that in future videos. For now, I just wanted to
point out the relationship between components added
to your blueprint, also showing up under the variables section of
the My Blueprint panel. That will do it all
for this video, guys, we will see you in the next one.
10. Event Graph: Welcome back everyone. In this video, our goal is to
learn about and demonstrate what the Event Graph is inside
of an unreal blueprint. Now this is an area
of a blueprint where all of our scripting
magic happens anytime we want to
add some kind of behavior, functionality
or gameplay. The place to make those
interactions come alive is inside the event graph. So here inside of my
BP example pickup, we've already explored
the viewport tab, Construction Script tab
we will talk about soon. The Event Graph tab is the one we're going to make the star
of the show in this one. So let me left-click on this. And what you see is a graph
that has a few nodes here. By default, these are event nodes of which we can
build some script off of. We'll talk about event
nodes in their own section. But for now what I
wanna do is I just want to left-click drag and I'm going to drag
out this box known as a marquee selection. And I'm going to hit
the delete key once all of those are highlighted
and Newcomb out. Bye-bye. We're going to
create our own script here. Alright, so the first
thing we wanna do is add some nodes to our graph. So how do we do this? Well, there's actually
several different methods and how to go about doing this. The first is by
right-clicking in a graph. If you right-click, you've got a whole bunch of
different categories. And in each of these
different categories, there are different
functions that you can add. There are different events
that you can add, et cetera. I'm just going to choose
Event Begin Play here. That's one that you
saw here before. And voila, you've
got yourself a node. I'm going to nuke that out. I'm going to actually
add one now that we want in our graph, I'm going to choose our
sphere collision component up here in the Components panel. Now I'm just going to jump over to the viewport tab quickly. The sphere collision is this invisible sphere
surrounding our cross here. So I want to do something
with our sphere collision. I want to have some node
associated with that. So going back over to my Event Graph with this
sphere collision selected, I'm going to right-click in my graph and note this
checkbox right up here. It's context sensitive. So it's going to show
me some nodes that are specific to my sphere collision and they're listed
at the top here. One of them that I'm going
to be adding now is under this Add event for sphere
collision category. So I'm going to click
this drop-down box and under the collision section, I want to add on
components begin overlap. Now this node is
going to fire out a signal when something
begins overlapping it. And it can output some
data here depending on what overlapped this
particular component. Now one piece of information I want to find when something overlaps are sphere collision was who was the other actor? So I'm going to drag
a wire out of here, and I'm going to type in cast
to third person character. Now, we haven't learned
about casting yet, but long story short, we will, this node is going to
allow us to check, hey, was the other actor that
overlap this sphere collision, was that the
ThirdPersonCharacter? If it is, we're
going to continue our flow of execution here. Out of this events
through this node, continue on through here. This is a bunch of
wires and nodes that we're linking together
to make stuff happen. If it was not the
ThirdPersonCharacter that overlap this
fear collision, this cast would
fail and the flow of execution would
continue out of here. So that's another way that
you can add a node is to simply pull a wire out of one
of these colored pins here. And we'll talk about these
different colored pins in future videos and then
search for a given node. The third way that
we can add a node to our graph here is
to drag and drop. We can drag and
drop a components. And I could do it here from either the Components
panel or from the variables section of
the, My Blueprint panel. Now, I'm going to do both just because it's fun to
demonstrate both ways. But the first thing I'm gonna do is I'm going to drag and drop, left-click and drag this
pick-up sound into our graph. It's going to ask me,
do I want to get this or do I want to set this? Well, I want to get the
contents of this variable. The contents of this variable
or this begin play there, sorry, this interplay sound
that's associated with it. I'm gonna get it. And then I'm going to drag
off of this node and I'm going to type in play sound. You see, I knew that this variable contained
a sound inside. It contains this
interplay sound. So all I'm doing
here is I'm saying, Hey variable, I want to play what sound that you
have inside of you. That's what this function
node does right here. Now this won't happen
unless I link up this execution wire to this
play sound function node. Alright, so that's
one way to drag and drop is directly from
the, My Blueprint panel. Now another thing I wanna do, and this is gonna be just
for demonstration purposes, is I'm going to drag a
component out of here. Let me drag in
something visual like the cube horizontal,
left-click and drag. And then I'm going to
drag out of my cube horizontal and simply
typing destroy. I'm going to destroy
this components when our ThirdPersonCharacter
overlaps are sphere. So that's how to read this
particular script right now, upon overlapping our sphere, we're going to find out
who the other actor was. We're going to cast to
our ThirdPersonCharacter, basically find out, hey, was it the ThirdPersonCharacter
that overlapped us? If it was, we're going
to continue with our flow of execution here
by playing the sound. And then we're going
to just destroy just the cube
horizontal component. Let's go ahead and
play test this. I'm going to click on this
Play button right up here. And I'm going to
move this off to the side here because
I want you to be able to not only see
me play the game, but also view the execution
of this script as well. Now currently I've got
access to my window here, but I want to do is hit Shift in F1 to bring my mouse cursor
back up to my editor. Now right up here I've
got my BP example pickup. I can click on this
and you can see I've got what amounts to 12345 different instances
of this pickup in my graph. So this is only going
to show this for whatever particular instance
I have selected here. So I'm gonna go with BP
example pickup, the first one. And now if I bring
this window back on, you'll see this flow of execution pulse out of this event node
through the rest of these nodes whenever I overlap this specific instance
of this pickup. So let's see this
first one here. So that was a one to show the flow of execution
right up above. And as you can see,
it just destroyed that one component didn't
destroy everything. Alright. I overlap that one. Again, it destroyed
the component, but you're not seeing the
flow of execution of above. Sweet, so it is
currently working. Now, I want to take this a
little bit further here, and we can ignore this
error here because what we just built here
was just temporary. So I'm going to
click this X button. So wanted to take this a bit
further here by destroying this destroy component and the heat and the
cube horizontal. Because that's not truly
what I wanted to do here. Instead, what I wanna do
is I wanted to destroy the whole actor when
we collect this. So I'm going to drag off
of my play sound 2D, and I'm going to simply
type in Destroy Actor. Now the target of this
particular node is itself, meaning this entire blueprint. So upon overlapping
this sphere collision, we're going to find out if it was a third-person
character that was the other actor that
overlap this sphere collision. We're gonna play this sound and then we're going
to destroy our actor. Fun factor this place down
to D. You can click on this to modify some
properties about this, such as the volume multiplier
can set that to two. For example, let's go ahead
and play this once again. Now this should destroy
the whole actor when we overlap it. And let's make this a little
bit bigger here, like so. And here we go. Sweet. Alright, with a little
bit of script built here, let's talk about navigating
the event graph. Here, the scroll wheel in the Event Graph will
zoom in and out. Left mouse button plus right mouse button will
also zoom in and out. So I've got both of
those down and I'm just moving my
mouse up and down. You can see the zoom
level in the upper right. By the way. If I right mouse button and
drag that'll pan around. It kinda gives me this hand icon to move it around like so, left mouse button and drag, left-click and drag like. So. That'll bring on this
marquee selection, which is great for highlighting a whole selection
of nodes like that. Fun fact here, something you can do with the
whole script like this added is tap the C key to add a
comment box around this. And I'll just call
this my pickup script. That helps keep things
nice and organized. So if you're zooming
way out like this, you can see all of
your different scripts that you've written here. Left mouse button on a No, that'll allows you
to select it so you can then move
it around like so. Right mouse button
on a node will bring up a content sensitive menu. Some options here that I
really liked to explore. These alignment options,
these are great and they work like anything you might find in PowerPoint or Google
Slides for aligning nodes, getting them light, left
justified, right justified. I love these, especially this
straightened connections. One is one of my favorites. What else we have here? We've got alt plus
left mouse button is how you can cut wires. So as you can see, we've got this unbroken
flow of execution. When this event happens, a pulse flows through these
execution pins right up here, holding down the Alt key and left clicking on
a wire will break it. So right now if I was
to play the game, I would actually play the sound but not destroy
the actor because the flow of execution through these execution pans
has not gotten here. Alright, Control plus left
mouse button will move wires. So let's just say I had, I'm just going to
right-click and duplicate my Destroy Actor node. Let's just say
that this was some other function down here. And I wanted to move this wire. You don't have to break it like this and then rewire
it like this. If you hold down Control, you can left-click and pick up that wire and move
it to another node. That's a very handy
trick as well. Use that one a lot. It's something to point out
here when breaking wires, you don't have to just, you know, Alt and
left-click on the middle. You can also Alt
and left-click on either one of these
execution pins as well. So there you have it. That's some quick
navigational stuff for your event graph. One more thing I want
to point out here with the event graphs because it's
always happens to students. Eventually, if you close out your Event Graph Tab,
boom, it's gone. You cannot find it in the
window option right up here. How do you get this back then? Well, that is contained in the My Blueprint panel here
we've got this event graph. And if I was to double-click on this event graph under
our graph section, that'll bring it right back on. Also, this is good
to note as well. It'll list out any events that are inside of your event graph. So let me just right-click and
add and events Begin Play. You can see as I add
this to my graph, it shows it down here under
my Event Graph as well. So if I was summer out yonder and I double-clicked
on event begin playing, it would jump me to it. I also have the ability
to create a new graph. Now let me just do this quickly
by clicking on new graph, and I'll call this new graph. Now I've got two
different graphs. Both of these are event graphs. One is called event graph, the other is called new graph. Why would you ever do this? Well, I do this sometimes simply to better organize my scripts. Depending on how much script you want to
add to a blueprint, it may make sense to have a graph that is very
specific to say, input events versus just
very passive things that can happen to
that blueprint. So some organizational
things to keep in mind as you're building
out your various blueprints. Alright guys, that's a quick
rundown on the Event Graph. Any blueprints.
11. Construction Script: Welcome everyone. In this video, our goal is to get a high level understanding of what the Construction Script
is inside of a blueprint. That is, this tab right up here sandwiched between our
viewport and Event Graph tabs. Now at first glance, it's going to seem almost
identical to the Event Graph. So right now I'm on
the Event Graph tab of our bp example pickup. You can see that there
are nodes wired together. Over in our Construction Script. Currently we have one node, but just like an event graph, we can wire other
nodes up to it. Now, whereas the Event Graph is the place meant to
create script that will execute while your
game is running. The construction
script is a place to create script
that you want to run before the game starts up while you're constructing
your blueprint. Now look, construction
script is great for building construction
variety into your scripts, as well as creating
procedural actors for you to work with. What you see before
you is a sneak peek of what's to come throughout
the rest of this video. This wall right here is an actor class blueprints
that is only utilizing, taking advantage of the
construction script. Now, what makes a
construction scripts so cool is that you can expose a few parameters
in your details panel. And just by changing a few of those parameters
that you've exposed, you can modify the look of this particular instance
of the blueprint. Now, as you can see, as I
alter some properties here, the script down
below is firing off. Once again, what makes
it Construction Script different from the
Event Graph is the construction script
fires whenever I make any change at all
to this blueprint, it could even be simply moving
it watches I move this. You're going to see
a pulse throughout the construction script
down below here. Now it also makes this cool, is if I create a copy
of this blueprint, I'm going to Alt,
left-click and drag. I can change the parameters
for this particular instance. So let me change the number of sections here to
something like ten. And I can change out
the material to be, let's just type in
the word brick. And so this can have a
unique material all its own. So the construction
script is where he can make something like this happen. Now think of the
possibilities with just how I have this construction
script set up. This is just a simple wall. This could be a row of chairs, it could be a fence. It could be a bunch
of electric poles with wires strung between them, that sort of thing. Alright, we're gonna
get started here inside of our content browser, specifically within
the scripting folder of our content browser. I'm going to right-click in
some empty space over here. Am I right-click menu? I want to create
a new blueprint. We want this to be of the
actor class variety because this is going to be
a blueprint that we place within the world. It's going to prompt
me to give it a name. I will call this BP
underscore example. How about just eggs? Construct script, that's
a very abbreviated name, but I kinda wanted it to
fit all on one line here, not wrap around x
construct script. Awesome. Going to double-click on this
to open it up right away. Then docket across the top, like I like to do. Now, we're going to be adding one component to
this blueprints. I'm going to come under the
add button and I'm going to type in static mesh. Just static will
whittle it down. Now, unlike before where we added a static
mesh component, in this case we want to add an instance Static
Mesh component. And the reason for that is
because we're going to be building out any number
of wall sections. And in order to do
that efficiently for the type of script that
we're about to be building, we want an instance
static mesh as a tool tip tells you this is how to render it efficiently. So let's add an
instance Static Mesh. I'm going to hit Enter here with that component is selected over in the Details panel we
can slot in a static mesh. I'm going to click
this drop-down here. Type in the number 400 because this section of wall
that I want to associate with this component
is wall 400 by 400. Go ahead and choose that. Now as you can see, we don't see anything in our viewport yet. We're gonna make use of this
in a different way here inside of our
construction scripts. So let's hop on over there. Now. The main takeaway I
want you to understand, at least for this, is what the construction script can do. For building out a very
dynamic blueprints. You can customize
your blueprints in an awesome way while you're
building out your level. Now the script that
we're going to be putting together right now, it's okay if you don't understand at all
what's happening, we're going to be breaking down these scripting concepts as
we go throughout the course. My goal in this
video is to simply build the thing so you can get an idea of what the
construction script can do. So bear with me on this. We're going to start off by
creating a variable here. Click on this plus button. We're going to call
this variable num of. Sections, we're going to use this variable of which
we will change this to an integer type to hold how many sections
of wall we would like for this
blueprint degenerate. We can give this a default value over in the Details panel, but it's asking us to
compile the Blueprint first. I'm gonna go ahead and do that. Let's start off with
a default value of one section of wall. That's nice. Now I want to point out
something else here. We can expose these variables to our editor if we check this instance editable
checkbox here. But before we do that, I need to actually place this blueprint
inside of our level. So let me jump back to my level test map tab that brings me back
to the main editor. Let me drag and drop this example construction
script to our level. All we see is that
root component icon. Now over in the Details panel, if I do a search for just numb, remember our given variable here was called
number of sections. I don't see anything. I'm gonna leave this search
right up here for the moment. I'm going to jump back into my example construction
script here. Let's go ahead and check this instance
editable box right here. Note that when I do that, this is the same thing
as clicking right here. Closing this eyeball means
not instance editable. Clicking to open it
up, checks that box. So you can check this
box either by clicking here or clicking right there. Now if I compile,
save this blueprint, and I go back to my
level editor with my example Construction Script selected here in the level
over in the Details panel. I've now expose this variable
to the level editor. This is going to be awesome
because we're going to be able to punch
in a number here. And then it Construction
Script is going to determine how many sections of
wall we want to appear. Pretty sweet. Alright, let's go ahead and build out that script. Back here. In the
construction script. I'm going to drag out a wire. I'm gonna do a search
for a for loop. And again, I'm gonna
be going through this a little bit quickly. So if you don't understand
what's all happening, That's quite alright and
just wanting to show off the power of the
construction script here. Now with this, I'm
going to feed this are a number of sections dragging and drop
that into the graph. I want to get it. Then I'm going to
drag off of this and I'm going to
type the minus key. I want to subtract node, and I'm going to
subtract the number one. And I'll explain why once we're finished
with all of this. And I'm going to plug this into our last index of the for-loop. So yes, please allow me to
build this out first and then go back through and describe
exactly what is happening. Now off of this, the loop body I'm going to drag off of this. Well actually first
I need to bring into our instance Static
Mesh reference. Let's go ahead and drag
and drop this from our components panel
right into our graph. Alternatively, I could
get it down here as well. I'm going to drag off of
this and I'm going to type in AD instance. So this is going to be the
know that's going to actually add a section of wall here. It's contained
within this instance static mesh to our world. We're going to take our loop
body and plug it into here. Next, I'm going to pull off of our index from our for-loop. I'm going to bring in a multiply button or
multiply node rather, I want to multiply this by 400. There's a very
specific reason that I'm choosing the
number 400 here. That's so happens to be the exact length of
our static mesh here. In fact, if I click on
this mouse over it, there you can see in the
tool tip the size of this, about the middle
of that box there, the approximate size
is 400 by 20 by 400. So it's 400 unreal units wide, 20 units thick, 400 units tall. So that's a very specific reason why I'm choosing
this number here, because I'm going to be
adding a given number of sections every
400 unreal units. Next I'm going to
pull backwards off of this instance transform pin. And once I release
and going to type in the word make transform, gives us a little
bit more space here. Move this over into
position like so. And then off of the
location pin right here, I'm going to left-click
and drag and type in, make Vector right down
here, make vector. And I'm going to plug
this into our x. And it's going to bring
in a conversion node, converting one datatype
integer to a float. So that's going to be fine. So now let's talk through
what we've got going on here. What's going to happen
is we're going to feed in a given
number of sections. And remember this variable
is exposed in the editor, so we'll be able to determine
how many sections we want. So let's just assume
we want ten sections. We're going to loop through however many of sections
that we have here, starting with our first index. It starts off with
the number of 0. If I have ten and I minus one, That's going to equal nine. So our first index
is going to be 0. Our last one is nine. So essentially that's
going to give us ten iterations of this loop. Again, starting with
0, ending with nine. That's why we're doing
this subtraction right here by putting in ten, subtracting one
that equals nine. But we are starting
counting at 0. So it's going to
run this ten times. It's going to execute out of
this loop body ten times. It's going to add ten
instances of this Static Mesh. Now all of this down
here is determining where to place the
static meshes. Essentially what we're
doing is for every index, we're going to move it on over 400 unreal units
in the x-direction. That's essentially
what this bit of script is doing right here. Now anytime you build
out some script, whether it's in the construction script or the Event Graph, you want to compile. Doing this, we'll
check your script to make sure that you
haven't made any errors. It's not going to
catch all errors, but it's going to
catch a lot of errors. And then you want
to save this out. Now let's jump back
into our level here. And what we see right now is
we have one section of wall. That's all well and good. Let me just raise this up. Hit the End key, and that'll smack it
on down to the floor. And that's pretty cool. What happens now if I change the number of sections to two? What do you know what
adds another section? 3410. Now we've got ten
sections of wall now that's a rather
bland looking while, but you can see what the Construction Script
has allowed us to do. It's a lot us to make a
blueprint that is very customizable by just
changing one value here, we're changing what happens
with this blueprint, one place inside of your level. Now let's take this one step
forward because this is a rather bland looking wall, if I do say so myself. So let's extend our script
down a little bit more. So come inside of our
construction script. And I'm just going to
zoom out a little bit. And I'm going to drag out another copy of our
instance static mesh here. Drag out a copy. I'm going to place
it right here. And then I'm going to
drag out a here and type in a set material. Set material. Our instance static mesh
will be the target. And let's keep our
execution going here. And off of our material here, I can right-click and I can
promote this to a variable. When I do that variable is going to appear in
our variables section. This is going to be a material
and I'm going to feed this the name new material. And I'm going to
click this box to make this instance editable. I'm also going to need to make this editable so we can change
this over in the editor. Let's give us a new
material right here. We can feed it a new
material I will choose. Let's try. I'm just
going to type in brick. You can change this
to whatever you want. I'll choose brick clay. Sure. Compile, save that
is our current script. And now if I jump back into
our level editor here, you can see that clay material is placed on every
section of wall. However, however, I don't
see it in the editor because I am currently
filtering by the word numb. So let me undo that filter
right there at the very top, I can see the two variables I've now exposed to the editor. Let me change my new
material to something else. Let's go to Chrome and wallah. We've got ourselves
a Chrome wall. This is how you make blueprints
that are very extendable, if you will, during design time. So once again, the
construction script is there to give your designers, your level designers,
if you will, great power and
flexibility about the blueprints that
they placed in your levels and how they
can customize them. Imagine if you will, if you had a blueprint
that was simply a light, a lamp, if you will, in a room. And maybe you
expose the color of the light like we did
here in our example, right here in the editor. We can make it so that for every lamp blueprint that
we placed in the level, we could change the color of that via the
construction script. So there you have it, guys, that is the power of the
construction script. Inside of a blueprint. They'll do to offer this one. We'll see you in the next one.
12. Class Blueprints: Welcome back everyone. In this video, our goal
is to learn about some of the different blueprint
types in Unreal, starting with something
known as a Class Blueprint. Now the reason we
want to learn about different blueprint types is because different types
serve different purposes. Additionally, the
interface and the way you go about working
with that blueprint can differ slightly depending on what it is you're working on. Now, let's use our bp
example pickup here. Take a look at this
really quickly. In the upper right. Once again, it
shows that this is an actor class blueprint that is known as the parent class. It is under the Class
Blueprint umbrella. Again, there are many
types of class blueprints. So what makes a Class
Blueprint a Class Blueprint? Well, you can think
of a Class Blueprint or blueprint for short, as a type of asset template. As a template that
you can easily add functionality or components
to make it your own. Now, right next to
this tab here I've got my BPA ThirdPersonCharacter. And inside of this
character class Blueprint, I've got a few
different components that came automatically from the creation of this
character class blueprint, namely the Capsule Component, the arrow, the mesh, and the Character
Movement Component. However, if I wanted to, I could customize this
and make it my own. I can add more components. I could swap out, say, the look of this mesh
in the Event Graph. I could change out all of this script at the fine folks
at Epic Games provided. And I could create something
completely different to have my character move in the manner that I
wanted it to move. That's what makes class
blueprints so powerful. They provide you the
template and from there, you can make it what
you want to make it. Now how do we go about creating
these class blueprints? Well, there's a
couple of methods. One you've already seen me do. In the Content Browser,
you can right-click and some empty space come
under Blueprint Class. And there it allows you
to pick a parent class. These are all different
types of class blueprints. The most common
ones listed up top, the less common ones down below. There are many. We're going to
explore several of the most common types
throughout this course. But know that there's
many, many, many types. So this is one way you can get at this class blueprint picker. The other way is right
along the top here with this little Node Icon, the blueprint icon, if you
will, you can choose this, come under new empty
Blueprint Class. And clicking on this
will bring up that same choosing your
parent class option. Now once again, the parent provides us with the
starting templates. So I'm gonna go ahead and
create a character here. And I'm going to call this
my temp character, like so. And I'm going to double-click
on this to open it up. We're going to compare
and contrast this with our existing BP
ThirdPersonCharacter. As you can see across the
top in the far upper right, it says the parent
class is character. And some of the commonalities that you'll see between this and the third-person
character is I've got a capsule component
in error component, a mesh, any character
movement component. These four can also be found in our ThirdPersonCharacter
component, capsule, arrow, mesh,
and character movement. Now one of the key differences between the
ThirdPersonCharacter and our temp character is the mesh here is populated
with a Skeletal Mesh. However, in my temp character, I could define this and
make it whatever I want to. I could choose whichever
Skeletal Mesh I wanted to. It's blank by default. You'll also notice
that here with our blank character
template here, I've gotten nothing in
the Event Graph that defines my temp
character's movement. However, in the
ThirdPersonCharacter, the fine folks at
Epic Games have already given this to work with. So once again, our
character class pooper, they provide the
blueprint for how to create a character by
providing us these components, however, the rest
of it is up to us. We can customize it by
adding new components, customizing the script to
make it move a certain way, you get the point. Next, I wanted to give a few ways for you
to easily identify. Are you working inside
of a class blueprint or a Level Blueprint level
blueprints are gonna be talked about in
the next video. Number one, in the upper
right of a Class Blueprint, it will list a
parent class Level. Blueprints will not. Number two. Class blueprints have a Components panel Level
Blueprints do not. Number three in the Event
Graph Tab class blueprints in lower-right was simply
say blueprint as opposed to Level Blueprints,
saying Level Blueprint. So some quick tips there. I've got a lot of
beginning students that sometimes are confused
where they're working in. Why don't they see
the Components panel, that kind of thing. So those things hopefully will help some of you out there. Lastly, want to
talk about some of the common class
blueprints here. So right-clicking and some
empty space Blueprint Class. After class blueprint. This is the one you want to choose when it is
something that you are going to place or
spawn in your level. By that, I should say, something that isn't a
character or a pawn. A character blueprint is a pawn. It extends from the Pawn Class, actually, you can
move it around. And one of the
great things about a character class blueprint
is it comes pre-built with a Character Movement
Component that gives you control over things like how
fast your character moves, how high they jump, that
kind of thing you can possess and control a
character class, blueprint, Game Mode, blueprints Game
Mode base, if you will. This is a primary place to store scripted rules of your game. It can determine
things like scoring, time limits of that
sort of thing will work on one of those
later on in the course. Alright guys,
that's gonna do it. That is the class blueprint upcoming next, the
Level Blueprint. See you there.
13. Level Blueprints: Welcome back everyone. In this video, our goal is to learn what a Level Blueprint is, how to access it, things it's used for, and how it differs from
a Class Blueprint. So what is a Level Blueprint? Well, it's the
blueprint associated specifically with a given level. In our case, it would
be the blueprint associated with our
test map level. Now how do we access
it? Well, right along the top here with this little
blueprint E-type icon, click on this drop-down
and right smack dab in the middle here we've got this open Level Blueprint option. Simply clicking
on this will open up our Level Blueprint tab. However, before I do this, I want to show you
a quick tip here because if I were to
click on this right now, it would open it up in
this separate window. I like to have my windows open right along the top here
along the main window. So I'm going to show you
quickly how to do that. Right now. I'm
going to come under Edit editor preferences in our
editor preferences window. Right here we've got the option under general appearances
category right here. Asset Editor, open location
is currently set to default. I'm going to set this
to be main window, and then I'm going
to close this out. So now when I tried to access my level blueprint right here, open Level Blueprint, bam, it puts it right
across the top here, instead of me having
to drag and drop this tab right along the top, like, I like it. Now I'm going to also
drag and move this right next to my level map tab itself. So notice something
here quickly, the orange icon of the mountain that represents
the level itself, the level of yourself
you're working on. This has the exact
same name to it, but it's got this blue
mountain icon that is the blueprint
associated with it. It is the Level Blueprint. So quickly before
we talk about what this Level Blueprint
is used for, how can we tell that this is different from a
Class Blueprint? Well, for starters here,
down at the very bottom, it obviously says,
Hey, Level Blueprint. Another way we can tell
that this is different from a Class
Blueprint is there's no Components panel are BP example pickup here
had a Components panel. Our Level Blueprint does not. Also notice that our
Level Blueprint does not have a
Construction Script or viewport tab are other
blueprints up here to the ThirdPersonCharacter
and our BP example pickup. Both of those have it as well. Also in our Level Blueprint, if we look along
the upper right, there is no parent class listed. And thus because it does not
inherit from a parent class, there's no inherited
components or variables. So in this level blueprint, what is it used for? Well, the Level Blueprint is
where you would put script for level specific things
such as level music. Maybe this level you only want that one selection of music play in just in this
level, nowhere else. This is where you
could script for that level music to play. Maybe you've got a
specific one-off events specific to this level, such as player passing
down a corridor. In this level, they overlap
a trigger volume and it causes zombie to break through a window and scare the player. That's very level specific
things that script should go inside of
a level blueprint. Contrast this with say
our bp example pickup. Now, jumping back
to our level editor here are BP example pickup. This is an actor
class blueprint. You can drag and drop this
throughout this level. And if I were to play my game, I can go ahead and run over these faux health pickups
and collect them. Now, it doesn't
matter if I drag and drop these inside of
my test map level, or I can create a second level, a third level of fourth
level, et cetera. This pickup is going to
behave the same way. Thus, I created this
script inside of our bp example pickup that checks to see if our ThirdPersonCharacter
overlap the sphere, plays a sound and
destroy as an actor, this script is specific
to this actor, and this actor can be
placed in any level. So the Level Blueprint
is where you put various levels
specific script. Now, one of the
benefits of working in the Level Blueprint
is it's really easy to get a reference or
add an event for an actor that already
exist in your level. This is something that is
not as easy to do inside of another class blueprint like
an actor class blueprint. And just to demonstrate
this quickly, I'm going to jump back
to my level editor here. And I'm going to come under
my Ad Content tab here. And I'm going to add a shape. We're just going to add a cube. So I'm going to
left-click and drag out a cube into my level, just going to raise it up
into the air a little bit. Notice that I have it selected. This yellow outline shows
that I haven't selected. And if I look at my outliner, this is currently known as the cube actor,
that is the name. Now I'm going to jump back into my Level Blueprint
with this selected. And with that selected, all I need to do is hold down
the R key and left-click. Or alternatively, I
can right-click and right here I can create a
reference to that cube. So this is the
right-click method. If I hold down Alt
and left-click. That's the same thing, getting
a reference to that cube. Now note if I was to
try something like that inside of my BP
example pickup here, let's jump inside of
this event graph. If I hold down the Alt
key and I left-click, it has no idea what you're
trying to reference here. In fact, if I right-click, it's like I have no idea what you're trying
to reference now, this is not to say we
can't get a reference to that specific cube inside
of our bp example pickup, but there's other methods
to do that and we can explore that stuff
later on in the course. But this is just a
quick example of one of the benefits of working
in the Level Blueprint is it's really easy inside of a Level Blueprint to
get a reference to anything that already exists
inside of your level. Alright, let's create
a quick script here inside of our
level blueprint. We've got our cube already
selected in the level. So I'm going to right-click
and some empty space here. And instead of creating
a reference to our queue because
we've already got one, we're going to add an event. Now, it says you're at event for static mesh actor to instead of cubed currently y
Static Mesh actor to well, to make this clear back in
our level, in our outliner, the floor, the default floor, that is a static
mesh actor type. This was a second
Static Mesh actor that we added to our level. Thus, it is considering
it Static Mesh actor too. So just wanted to
make that clear. Alright, with that
cube selected, right-click at event for
static mesh actor two, we're going to add an event
for when we hit this actor. So go ahead and add this. This will be a real
simple script. We're not going to
check who hit it. We're going to have this
thing floating in the air. So I'm going to drag off
of this and just type in plays sound to D. You can slot in any
sound that you like. However like to hear
things explode. So I'm going to check
to see if there is an explosion in here. There it is explosion. Feel free to put it
in whenever you like. And then after this, I'm going to drag out of my cube because I want to talk
specifically to this cube. And I want to say Destroy Actor. So this is a script specific inside of
this level blueprint. If I were to place just this
cube into another level, it wouldn't destroy it
like we're about to see, because that script exists only inside of this
Level Blueprint. So let's go ahead and play here. And bam, little delayed
explosion there. But a way, a way it goes
that indeed does work. Let's run through
another example here showing what the Level
Blueprint might be used for. It can be used for
something like kicking off playing of music. So jumping back into
this Level Blueprint, Let's go ahead and build off of this event
began play here. I'm simply going to drag
off type in play sound 2D. A 2D sound is one that
is not localized to any spot in a 3D space. It's simply like great for
menu music, background music, that sort of thing in our sound drop-down here I'm going
to type in the word music, and I'm gonna do
our starter music here that is in the
Starter Content Pack. Feel free to slot it
in wherever you want. And if I go ahead and play
wallah, you've got some music. So once again, these
scripts work in this level and this level only if I create a second level, I've gotta decide
which in this case, menu music I want to play, and what other
one-off interactions I may want to script as well. So up until this
point in this video, I have shown you a one-level blueprint
associated with a single level. So the question may come, can I have multiple
low blueprints? The answer to that is yeah, essentially you
can see how well, if I come under
my Windows option in the main level editor here, I can find this
option four levels. And when I open this, I'm going to open a levels tab. Now, I like to dock this
right next to my outliner. And what I can do here is I
could add a brand new level, essentially a
sub-level, a layer, if you will, to this
existing level. Currently, it shows that I have one level here known as
my persistent level. And this blue coloring
shows that this is the level that I'm
working with him. Come under this levels tab and its levels dropped
down right here, I can create a new level. So I'm gonna go ahead
and do that now. It's going to prompt me to choose a new level
and give it a name. I'm going to choose
an empty level here. We're going to create this. And it's going to say, where do you want to save it. So I'm gonna give
this the name of sub underscore level,
underscore 01. I'm going to how's it into
this folder right now, but I'm going to start
housing these things into separate sub-folders in
just a little bit here, let me get rid of
that capital U there. Sublevel one, we're
going to save this out. Now you see that this has added a level to my levels tab here. Think of a sub-level like
a layer in Photoshop. It's just an additional
layer of stuff, actors, objects, what have you that you can add to your level? Dev teams will often dedicate an entire sub-level to
lighting, for example. So that a lighting
specialists can focus on just the lighting
aspect of the level. And it's really easy
for that person to have sole access to that
one is sublevel and make edits to it without
interrupting the rest of the dev team
working on that level. So if we're making a
Massive Open world, we can have multiple
sublevels here. Maybe someone's responsible for sculpting that
massive open world. Maybe there's a sub-level
for all the foliage and other sublevel for lighting and other sublevel for effects, that kind of thing. As you can see here, when we created
this as sub-level, it made our sub-level blue emitted the current level
that we're working within. What does that mean
to make it current? Well, that means any actor
we were to add to this level now what actually add
it to our sub-level, our sub-level right
down here and created a brand new asset for this level down and
our content browser, as opposed to our main
persistent level or LV test map. Let's go ahead and give this
a try in just a moment. But however, I wanted to
point out that each sublevel has its own level blueprint. And that can be accessed
by clicking right here where there's that
little blueprint icon. So if I open this up, we can see it's got the name of my sublevel and again that
level blueprint icon. Now let's go back to our
main level editor here, and I'm going to
add a point light. So I'm gonna come
under my Add tab here. We're going to find our lights. Let's add a point light. Alright, now, we did
add it to our sublevel. And if I click this little
toggle visibility here, you can see that it
shows and hides it. And it's in our sublevel. If I was to hide our
persistent level stuff, we would still see our light because that belongs
to our sub-level. Also to help drive
this point home, I'm going to select
our light here. If I was to go into my sub level Level Blueprint and I was to right-click
and some empty space, I can create a reference
to my point light. I've got that point
lights selected in my level here, my
sublevel specifically. However, if I was to try
to add a reference to that inside of my main level
blueprint here, right-click. There is no reference that I can create to that point light. So whatever you have, whatever objects,
effects, et cetera, that you have existing
in your given sublevel. You can reference them directly inside of your Level Blueprint. But it's gotta be
whatever level or sublevel you've actually
placed that thing within. If you are new to Unreal, the whole idea behind
sublevels is probably well beyond what you actually need to know about right now. But since we're on the
topic of Level Blueprints, I thought it was
inappropriate time to at least bring it up. Couple of more things I wanna do before we close out this video. Let's go ahead and save
our level and sublevel. Both of these have the
asterisks on them. They can be saved by
right-clicking on these assets and our content browser or in our
levels tab right over here, I can click on each
disk to save it. Additionally, I want to create separate folders here
for some of our assets. Otherwise, we're going to
have too many one place inside of our scripting folder. I'm going to right-click. I'm going to add a new folder. I'm going to add 14 levels. And I'm also going
to right-click on our scripting folder. Once again, I'm going to
add another new folder, and I'm going to add one for
we'll call it overview for some of our very first
blueprints that we created. And then I'm gonna go back
to my scripting folder. And I'm going to drag
and drop some of these assets inside of
the appropriate folder. So I'm going to
left-click and drag and highlight as sorry not
left-click and drag. Control. Click my example pickup in
my construction script. And I'm going to drag and
drop these into inside of our overview folder. And the other 3123, I'm just control clicking. I'm going to drag
and drop inside of our levels folder,
move them here. Falling acids are
referenced by one or more, will say yes. And last but not least, we will file and save all
good spot to save all as. Alright guys, that's gonna
do it all for this one. We will see you in the next one.
14. Node Types: Alright, welcome back everyone. Over the course of
the next few videos here we're going to be
breaking down blueprints, scripting nodes in
much finer detail. In particular, we're going to be talking about
different node types. We're gonna be talking
about different pin types. That is these colored
circular shape pins versus these triangular
shaped pins. We're going to be talking
about the difference between input pins on the left side of a node versus output pins on the
right side of a node. We're going to be talking
about wiring up nodes and also how to better
organize nodes. Now, in this video, our goal is to discuss
some of the blueprint scripting node types
found in unreal. Now, we're going to
talk about each of these different node types in greater detail later
on in the course. But for now, I just wanted
to get you familiar with these different node types
so that you can better identify them and
understand their use. Alright, we're gonna
get our discussion of different node types started here with the red color nodes. Red colored nodes in Unreal
are known as event nodes. And they are critical
because they are needed to start any bit of script there. The spark that sends a pulse down this wire here to make any other nodes
hooked up to it, fire off as well. Now some example, events
or event begin play, which is super common. This fires off whenever
we start up our game. You've also got input events such as when you press one on your keyboard or the bottom
face button on a gamepad. Moving along, we have these blue color nodes and
these are known as functions. In particular, they're
known as impure functions. In pure functions make
something happen but are free to have
things modified. Some examples of
different function nodes include spawning an actor, spawning, and emitter. That is the older VFX
system in unreal, we've also got spawned
the system which is the newer VFX system in unreal, we've got this create
widget function. This is used to show types of menus or HUD that
you've created. We've also got functions
for playing a sound or setting and actors
location or setting, the material, that
kind of thing. I wanted to add this
one down here as well. You have some functions
that may have this development
only stripe on it. And that's because
this function note is really only meant for
developmental purposes. So if you ever see
something like that, That's why moving along, we've got these more
green color nodes. And they're known as
functions as well. But they are known as pure functions that are
simply used to get some data. And one key
differentiator between these green functions and
these blue function nodes. Both of them have
this fancy F on it is these blue impure function
nodes have something known as exact pins on them. Execution pins, exact
pins for short. Whereas the green knows
the pure functions do not. These exact or execution
pins are simply used to keep the flow
of execution going. In. Execution wire can
go in and out. However, these don't have that. So what exactly
is their purpose? Their purpose is used
to just get some data. In this case, this
node is going to get what our player
character is. In this node, we're getting
what level that actor is in. And this pure function simply gets the display name of
the object plugged into it. In this case, our level. These two nodes right here
are not pure functions. Next up we've got a category of nodes known as flow
control nodes. You can identify them by this grayish color
banner along the top. The lone exception to that is the switch family of nodes
of which there are many. And they had this sort of a golden color banner
along the top. They are considered flow
control nodes as well. So what a flow control
nodes do with their use to determine where to
go next in a script. So imagine if you will, we had an event, begin play it right before
this branch node. And it was plugged
in right here. So depending on the
condition, true or false, we could either a fire
off this way or this way. And I can have all kinds of different scripts attached
to my true branch or my false branch hello
control nodes are super common in Unreal
and blueprints scripting. And you'll know
you're really kinda leveling up your blueprint scripting game when you
start to master these, how do you find these nodes? If you simply right-click
in some empty space, you can type in flow control. And there's a whole
category actually listed as flow control. And you can see
where there's tons of switch nodes, flow control, let me collapse the
switch category and there's a bunch of your
flow control nodes. And next up we've got variables. Now I've created a bunch
of different variables along the left in
preparation for this video. Variables hold data
of a specific type. These are containers,
if you will. They can have their
values altered or set as we like to say, something other than
what it originally was, so long as it's the same type. Now these containers
are used to hold things such as health values. Or is the status of owning
something or spawn location. If it was a health
value, might be an int or a float type. That is some sort of a number. If it was status
of owning a key, it could be a Boolean type
that is true or false. And if it was the location
of an enemies spawn, that would be a vector type, that would be an X,
Y, and Z location. Finally, I wanted
to make mention of a very special and unique node found within
blueprint scripting, that is a timeline node. Timeline nodes are used
to alter the value of a variable or
variables over time. And they're used for things
like changing a float value to change a game timer
to decrease over time, like founded a sports game, you know, a clock counting down. Or maybe to change
a vector variable over time to move an object. In the case of a
moving platform, this is such a cool and
unique node that I have an entire video dedicated to
this later on in the course. So in summary, we've
got red nodes. These are known as event nodes
that are needed to start any bit of scripts. Are blue. Nodes are known as
impure functions. They simply make
something happen. They can spawn an actor, they can spawn a particle
effect, play a sound. They can show a
menu screen or HUD. What makes impure functions different from our
pure functions is that they do have execution pins coming in and out of them. Speaking of pure functions, here are some examples
of our pure functions. These are colored green. They do not have
execution pins on them, and they're simply
used to get some data. Flow control nodes
are colored gray, with the exception
of the switch nodes. And these are super
useful for controlling the flow of execution
within your graph. Next up we've got variables. There are many different
variable types. Variables hold a
piece of information. The contents of a
variable can be set, changed if you will, somewhere along your script. And last but not least,
we've got a timeline node. This is a very special node
within unreal that can change the value of a
variable over time. Alright guys, that's gonna
do it all for this one. We'll see you in the next one.
15. Execution & Data Pins: Welcome back everyone. In this video, our
goal is to learn more about and understand
the differences between execution
and data pans are various no tides within
Unreal Engine blueprints. Now up until this
point in the course, you've seen me work with some of these different pin types
on the various nodes, but we have not had an
official discussion about pin types. So that's what this
video is all about, using some of our
impure functions. Here is a quick example. Check this out. I've got some of these triangular
shaped pins on a node, and I've also got these
color-coded circular shaped pins on a nose. These things are
referred to as pins. What's the differences
between them? Well, these triangular
shaped pins are known as execution pins. These pins are where
signals are sent into and out of a given know. They instruct the node to
execute to do something. In this case, this node
would spawn a visual effect. Now, all event nodes have
at least one execution pin. And it's pretty critical
that event nodes do because they're the ones that start the
entire script to happen. So we began play. It's going to start a flow of execution out of this
pin and down this wire. Now it's important
to note here that not all nodes have
execution pins. If you remember from
the last video, these pure function nodes
do not have execution pins. These are just simply
meant to output some data. That leads nicely
into the discussion of what is a data pin. Well, coming back to our
impure functions here, because this node
has a lot of them. Data pins are pins
were data can flow into or out of a given node. Examples of data that can be plugged into a node
could be numbers, coordinates, objects,
that sort of thing. Now notice that these data pins, these circular shape data pins
come in different colors. And that's to help identify
the different data types. If I mouse over any of these different color-coded pins in the tool tip that appears. It lists out the
different datatypes that can be input into it. So the location is looking
for a vector datatype, as is the scale. However, this auto destroy is looking for a Boolean data type. Now you may have remembered
from the last video we talked briefly about variables
right up here, and that variables can come
in different datatypes. Variables can be plugged into these various data pins to instruct the node on what to do. For example, if we wanted to spawn an emitter at
a given location, I could plug in a
vector variable into this data pin to instruct this
emitter where to be spawn. As you can see as I'm dragging and dropping this over the pin, it's saying, Yep, That
is a vector variable. It is okay to plug that
into our location here. Now, if I delete this
out and I tried to plug that same thing into
this auto destroy pin. It'll say, Nope, can't
do it because that is not a compatible
datatype, can't do it. However, this Boolean variable
could be plugged into this auto destroyed because
that is a matching datatype. Now it's important to
understand that nodes can take in data as
well as output it. So this spawn
emitter at location as our spawn system at location, they can take in all kinds of data and it does
return data as well. But let's check out
another example of a node that outputs
a lot of data. I'm going to jump over to my BP example, pickup quickly here. And we can see on our
own component begin overlap event note here that
it can output a lot of data, including the other
actor that is the other thing that overlapped
this sphere collider. Now I want to help solidify
all of these concepts here we've got execution
pins versus data pins. We've got input pins
on the left side of a node versus output pins. So I added a temporary script up here inside of my
BP example pickup. That is this grip right here. I'm going to delete this
at the end of this video just to help demonstrate
this concept. I also in my level
have one instance, one copy of my BP
example pickup. Currently in my
level it is known as BP example pickup to. The reason I'm bringing
this up is because inside of that blueprint
right up here, I have selected this, my loan BP example, pickup instance as
the debug option. The thing that I want to see the script for it actually
firing off in working. Now this temporary script
that I added up here, this is going to fire
off every single frame. That's what event tick does. It is going to instruct our print string
function node here to print something to our
screen in pink texts. And it's going to
print off the name of our player character. That's what these, these
nodes do here as well. So this print string, if I unhooked this
wire right here, it would simply print
out the text Hello. However, with this
plugged into it, I am telling this
print string function what to print out to the screen. We are providing IT data of what to print out. So here we go. I'm going to click
play here quickly. And if I move this down a
little bit, there we go. You can see this event tick
firing off continuously, a continuous stream telling our print string to
continuously print off this display name to
our screen here it is spammed along the left-hand
side in pink texts. And there you have it. We have an execution node firing out into this
execution input node, telling this to print
out to the screen. We've got some data flowing into this node telling
it what to print. That is gonna do it all
for this video guys, we've got execution pins, these triangular shaped pins. We've got data pins, these color-coded
circular shape pins. We've got input pins on
the left side of a node. We've got output pins on
the right side of the node. That will do all for
this video, guys, we will see you in the next one.
16. Node Wiring: Welcome back everyone. In this video, our
goal is to learn the methods of wiring
notes together in unreal. Now, on the surface, it may seem there's not much to this, but there are some
subtle tips and tricks here that are very
much worth your time learning about because
they can save you a boatload of time over
many days of development. So firstly, let's talk about
different types of wires. White wires. These are execution
wires and they flow between execution pins. They keep the flow of execution going from one node to another. And fun tip here, if you mouse over
any of these wires, you can kinda highlight it like this to help make it stand out. You can see as I do this, kinda doles out all the
other wires down below. Pretty cool, makes
it help stand out. Next, we've got data wires. These are color-coded
according to their datatype, which again, we're gonna be
learning a lot more about datatypes later
on in the course. They pass along data from
one node to another. So this pink wire represents
a string datatype. And again, it says that in the tool tip as I mouse over it, if I jump over to our bp
ThirdPersonCharacter, we can find a few other
color-coded wires. These green wires represent a float datatype that is a
number with a decimal point. There's also a yellow
wire down here. This is a vector datatype. So once again, data wires are color-coded according
to their data type. Next, let's talk about different ways to
connect nodes together. Probably the most
common way is to simply left-click and drag from one pin type to another
similar pin type, like so. However, you don't have
to work in this forward, this left to right fashion, you could work backwards. If I was to disconnect this pin, I could do something like this. That is a completely valid
way of doing it as well. You can also drag and drop
some nodes onto other nodes. Look down below here in
my place sound 2D node, I've temporarily disconnected
my pick-up sound from my sound input here. I could do something like this, where I left-click and
drag this into the graft, I get it, and then I
wire it up like so. However, that's a
two-step process. Let's make our lives easier. So because this is of the same datatype that
this is looking for, I can simply drag and drop
it right on top of there, and it will wire it
up automatically. That is a really handy trick. Now this works not only
for inputting data, but for outputting data as well. So prior to this video, I have created a variable
here called Delta seconds of the float datatype because this event tick can output
some float data. If I left-click and
drag this on top of here, it can automatically. Why are these two nodes
together as well? Now we haven't
talked about getting some data versus
setting the data. We'll talk more about that
in our variables section. Another way to where
nodes together is to get something
context-sensitive. What do I mean by that?
Well, let me show you. I'm going to select
our horizontal cube mesh up here in our
components panel. And with that selected, I'm going to right-click
in our graph here. And I'm gonna do a search for
node called Sets material. So I can set material for
my horizontal cube here. If I selected this
function node, it is going to
automatically hook up our horizontal cube component
here to this function node. This works not only in an actor class blueprint or other blueprints
for that matter. But here in our Level Blueprint I can
demonstrate this as well. So let me jump back
to my test map here. I've got my cube selected, jump back into my
Level Blueprint. That's a reminder
on how to do that. With that node selected or
with that actress selected. I should say that cube selected. I can right-click and
some empty space. I can call some function
on that Static Mesh actor. Let me go into the
rendering section and I can set actor
hidden in games. So I'm automatically hooking
up a reference to my cube, to this set actor hidden
in game function. Now as I briefly demonstrated
in the last video, if you try to hook up one pin to another and they're
not compatible, unreal is going to let
you know about it. So if I was to break
my cue boy right here, and I tried to
plug it into here. It's going to say,
OK, can't do it. Event began play
in execution pin trying to plug it
into an int string, string datatype, Can't do it. Long story, short,
Unreal will let you know if you can connect
those pins or not. Now, let's talk about some
ways that wires can be cut. The easiest method
is to hold down the Alt key and left-click
on the wire itself. However, if you don't have to
do that on the wire itself, you could find either
pin that the wire is connecting and simply hold down Alt and left-click
on the pin itself. It doesn't matter if
it's this side or the other side of
the connecting wire. Another way that you
can do this is simply by right-clicking on the node. So let's right-click on our
print string node here. And am I right-click menu? I've got the option
to break node links. That'll do it. Another way that you
could do this is by right-clicking on
the pin itself. So let's use this
example over here. I've got this cube reference inside of my Level Blueprint. And I've got this hooked
up to two functions. So I can right-click on this pin itself and I could
break all Pin links. So notice that I've
got it hooked up to two different
function nodes here. If I wanted to bring both
wires at the same time, simply right-click on that pin, break all Pin links and
boom, all disconnected. Lastly, moving wires from one pin to another is one
of my favorite tricks. Instead of doing
something like this, where we've got our
cube reference and we want to hook it up to this. Oh, now we want to
hook it up to this. So we got to break the
pin and go like this. Yeah, that's perfectly fine. You can do that. However, if you hold down the Control key and you
left-click on the pin itself, you've got that
little hand icon. You can drag and drop that
from one data pin to another, just like that, love that trick. That is a huge
time-saver, right guys, that is some different methods
for wiring nodes together. That'll do it all for this one. See you in the next one.
17. Node Organization: Welcome back everyone. In this video, our
goal is to learn some note organization tips and tricks that will help
us be more efficient, as well as to write
cleaner scripts that can be more easily read. Now up until this
point in the course, we have written some
fairly basic scripts. They don't contain a whole
lot of nodes or wires. And thus organization of our nodes is not
that big of a deal, but as you get more advanced, your scripts will
tend to include more nodes, include more wires, and thus these organizational
options become o, so important for
readability sake. So in a blueprint
of your choosing, I'm going to be within
my BP example pickup. Let's explore some of
these and now I've intentionally messed up some of the node organization that I had going on here ahead of time. If you left-click and drag, you can highlight a
selection of nodes. Alternatively, you can hold down control and left-click to
select multiple nodes. Once you've right-click on
any of your selections, you can bring on a right-click menu in one of the categories is organization. We're gonna be
talking specifically about these alignment options. And in the little fly-out
menu here you can see we can align our nodes along
the top of the node. The bottom's, the middle
is less the centers, the rights, et cetera. All of these have hotkeys
associated with them. As you can see here. If you look carefully, it's Shift plus W, a, S, and D. That's the movement
of your character on the keyboard that easily
corresponds to the top, bottom, left, and
right. Pretty handy. So I'm going to align
along the top here, but there's a little bit of nuance with aligning that
you should know about. So let me just go
ahead and do this. You can see how it does align all of these nodes
along the top. But then the question
becomes, well, which one of these nodes
that it decide to align two? Let's do this again. Moving this a little
bit off kilter. You're going to do the control
selection of these nodes. So I've got 1234. So notice that Destroy
Actor here was the last node that
I have selected. Now if I right-click, I'm going to align
across the top again. And note that it aligns
it all according to the last node that
you have selected. Now we just did aligning
across the top there, but you can imagine
what aligning right, left, or bottom does. Next, I want to talk about
straightening connections. Many times, as your scripts
get more and more complex, you can have nodes kinda
curling up in one area, maybe curling back like this. No, it's kinda like that. Wiring all sorts of weird ways. Straightening out connections is one way to make them
look very clean. If I highlight these
two nodes right? Like this and right-click, you can see that the
hotkey for straightening connections is the Q key. And if I do that, you can see how it straightens out
that wired connection. Now here too, there is
a little bit of nuance. The first selection
that we made, and let me just kind of
get these off kilter. Once again. The first selection
that we made is the node you want to straighten. The second selection
that we make. In this case, it's going to
be our print string node. That is going to be the pin of the node we want
to straighten two. So notice this by right-click. Do align Q. We have straightened
to that pin, this node, we
straightened to that pin. Next, I've jumped on over to my Level Blueprint where I
have intentionally messed up the organization of
some of my variable nodes so I could demonstrate
distributing vertically. The first thing I'm gonna
do is left-click and highlight all of
these variable nodes. And I want to get them
aligned along the left first. So holding down Shift, I'm going to press the a
key because Shift plus a is the hotkey for
aligning along the left. As you can see vertically, they don't look very
evenly spaced out. So there's an option
for that as well. I'm going to
right-click on any of my remaining
highlighted notes here. They're all
highlighted alignments and we can distribute
vertically. And what that's gonna
do is it's going to evenly space them out between the topmost node
that I have selected and the bottom most node
that I have selected. So check it out. It evenly
spaced them between my top-most selected node and my bottom most selected node. Organizing notes horizontally
is not what's different. So here we've got some
flow control nodes that are a little off kilter. I'm going to left-click and
drag to highlight these four. The first thing I'm
going to do is hold down Shift and press the W key to align them
along the top here. And then with all of
these highlighted, I can right-click on any one of those four
that are highlighted. We can go to alignment. We can distribute horizontally
to evenly, space them out. Now, with these nodes selected, there's a couple of
different ways we can go about moving them. You can see I've got all
four of them selected. I can select any one of them and move all four round like this. However, I can also
use the arrow keys. So right now I'm pressing
down on the arrow keys, left, right, and up, that'll move nodes as well. Something else you
may note that I have on a couple of the nodes. Here is a comment, a comment about some of
the hotkeys associated with bringing a few of these
nodes into your graph. How do you get a node comment? Well, it's just a matter of right-clicking on
the note itself. And there you can
leave a node comment. I'd like to do this
sometimes with hotkeys, particularly when I'm
creating videos like this. Anytime you want to
leave a reminder for yourself about what a node does, or maybe some special case
that node is dealing with. Right-clicking on it and adding a node comet is quite handy. Speaking of comments,
you might see, notice if you will, that I've got this comment box around this entire
selection of nodes. Well, how did I get that? Well, that is
simply a matter of, let me just move these
nodes all on out of here. I'm going to delete that out. You can left-click and drag to create this marquee selection
around all your nodes. With them all selected, you can tap the C key
to create a common box. The moment you do this, you can see over in the Details panel, you can give a name
to your comment box. You can also name
it up here as well. Let me just move
these nodes down because it's overlapping
a little bit. You can also double-click on that name right there to rename it and also gain access
to your comment. Details here, I'm going to
call this flow control. You also give it a color
to the box right here. Something green. Perhaps. You can also change
the font size. This is really handy for when you are zoomed way
out like that. Maybe you want
something like that. Now another really
useful option with this comment node bubble is you've got this
movement in mode. Currently, if I was to
select my comment box, I can move all nodes because my movement mode is
set to group movement. However, I can also
change this to just the comment box itself. And I can move just the
comment box personally, I like group movement. So another way to
create a comment box would be to highlight
some nodes like so. And as you may imagine, the right-click
menu will give you an option for creating
a common box as well. I'm going to go ahead and
do that and I'll call these my loop nodes. And this also demonstrates
that you can have a comment box in side
of another comment box. So I could move around
these nodes like that, as well as moving all
of these nodes around. Let me change this
back to GRU movements, including the comments
selection inside of it. And lastly, no node organization
video can be complete without talking
about reroute nodes and their importance
within blueprints. To demonstrate the reroute node, I'm in my blueprint
wall, Scott's, which you can find as
of today's date anyway, in the starter content
Blueprints folder, again, you can demonstrate this in any blueprint, but inside here, you see this oftentimes
in scripts where he got some wires crossing
over other wires, wires going through nodes,
this sort of thing. Is there any way that you
can redirect that the wire? Yes, you can. And that's through
something called a reroute node. What
does the reroute node? It's essentially
a defined point, a band, if you will, that you create in a wire. To bring these on,
you can simply double-click on
any wire like so. Double-click this right
here is a reroute node. It's simply continues
the flow of data. In this case, you can
also add reroute nodes for the execution
wires, like so. It's great for doing this
kind of thing where you're sort of bending this around to make it more clear where this is going as opposed to
crossing over things. You can also bring in a reroute node by
dragging out of something and typing in re routes, you can add a reroute
node like that. And you can see that this
point lights right here, this component, if you will, is plugged into
multiples of these. So long as it's feeding
into a reroute note, I could do something
like this as well. This is a completely
valid way of doing that. It doesn't matter
in this case if I'm dragging the
point light from here or from the point
where it is rerouting. Both of those are
valid ways to do it. So the reroute node super
handy loved so much. And the simplest way
to get them is to simply double-click on a wire. Guys that is gonna do it for this video on node organization, please master these
tips and tricks. You'll thank yourself later.
18. Level BP - Design Time Object References: Welcome back everyone. Over the course of the
next few videos here, we're going to be
talking about one of the most key and
essential concepts in all a blueprint scripting. And that is how to create
an object reference. Now, this is such an
important concept and we're getting to it before we even talk about events,
functions, or variables. Because so much of blueprints scripting is centered around manipulating objects
in some way. For example, if you were to walk over a new weapon pickup, Well, you can't
collect that weapon without having a
reference to that object. Maybe you shoot a tank
with a rocket launcher. Well, you can't destroy
that tank without a reference to that
object to that tank. Or maybe you want to collect
some harvestable item to craft some Master
Sword, so to speak. Well, you can't
collect that item without having a
reference to that object. Now we're gonna be talking
about how to create these objects references not
only in Level Blueprints, but in class blueprints, and not only during design time, that is before the
game is running, also during runtime, that is, while the game is running. Alright, so creating references in side of our Level Blueprint. First of all, just want to point out that over in my
levels tab here, I am working in my
Persistent Level. And I have three objects that have been added to
this persistent level, a cube, my BP pickup, and my Construction
Script blueprint as well. And just to hammer home
the point that these were added to my persisted level, my level tests map, if you will. I'm just going to click
on this eyeball to toggle that on and off so you
can see that yes, indeed, they do exist inside of
this level test map, which is otherwise known
as my Persistent Level. I'm gonna go back into
my outliner here and I'm going to select
all three objects. Now, you can select all three of them here in your
view port by holding down the control key
and left clicking 123. Alternatively, if I click
off of it for a moment, I can select all
three of them here in my outliner as well, 123. And you can see all
three of those objects are outlined here
in the Viewport. Alright, now let's jump on
into our Level Blueprint by coming under our
blueprint button here. We're going to open
our Level Blueprint, even though I've already got
it opened up across the top. And something I want to note here that currently
my low Blueprint, I've got two event graphs. One called Event Graph, that one was there by default, and another one
called node types. I created this one when I was talking about the
different node types. Now the reason I'm
mentioning that is because within my node
types event graph, I've got this event begin play. You can only have one event begin play per Level Blueprint. So if I was to work in this Event Graph Tab
and right-click and do a search for Begin Play. And click on this. It's going to hop me from this Event Graph tab back
to my nodes type tab. There it is. Now I've also got to
function nodes out here. I've got a delay node
that's going to delay for three seconds and then
a Destroy Actor node. So essentially what
I'm looking at, looking to do here is
upon beginning play, we're gonna delay
three seconds and then we're going to destroy
a target actor. Well, which actors do
we want to destroy? Well, I've got these three selected back here
in my view ports. So let's create a reference to that inside of our
Level Blueprint. Now, if I right-click and
some empty space here, I don't seem to see
them at all right here, however, there's a
shortcut for this. I can hold down the R
key or as in Robert, left-click and
boom, all three of those references are added even though they are
overlapping one another. So you can separate them out. Like so. Now, that is my preferred way of adding a reference to something that exists
within your level, inside of the Level Blueprint. However, if I go back in here
and select just one object, this I'm going to select
my example pickup. I'm gonna go back to
my Level Blueprint. I can right-click in here. And when you have
just one of them selected in your
right-click menu, your third option down, you can create a reference
to that as well. Either method will
do personally, I liked the shortcut
of holding down the R, R as in Robert key
and left clicking. Now I've got two references
here to my BP example pickup. Is it okay to have more than one reference to the same actor, the same object? Yes, that is perfectly fine. There simply duplicates
you are talking to. Same thing. I'm just going to
delete one of them out here for the time being. So as you can see, all of these actors are from
the persistent level, my LV test map. And I can hook up all three
of these to my Destroy Actor. And you can see I can wire
them forward and back. So again, getting
an object reference is super important
because so much a blueprint scripting involves manipulating actors in some way. In this case, we're just going the brute force method
of destroying the actor. So if I play my game now, let me just firstly
compile my blueprint here to see if there's any
errors with my script. Save that right away. Go ahead
and click Play right here. And you can see
after three seconds, all three of those
actors are destroyed. Now, creating object
references is cool, not only because you can
affect the object itself, but you can affect things about that object on a
more granular level. Let me show you what I mean. I'm gonna get rid
of this Destroy Actor function right here. And with my BP example pickup, if I go back to where this
is in my folders here, I've got some
components here that I can talk to directly. These exists inside of
my BP example pickup. And I want to affect
this sphere collision. This is currently
my root component. So I'm going to change the
scale of this root component. All these other components
are attached to the root. So if I scale this, these are going to
be scaled as well. So as this audio one, but
that one is currently empty and frankly I
don't need it anymore. So let me go ahead and
delete that out of there, compile and save that. Alright, let me jump back
to my Level Blueprint. And I'm gonna drag off of
my example pick up here. And I'm gonna do a search
for sphere collision. And I want to go to
the very bottom. Oftentimes, when you're
searching for something that exists within
that blueprint, It's at the very bottom. And I want to get my sphere collision because I
want to do something to it. And then off of this, I'm going to drag off
of here and type in set world scale 3D. So this function does what you think it does is going to scale up this scene component,
that's the target. I'm going to set the scale to be three times bigger in the x, y, and z coordinates. So we'll do this
after three seconds. And again, all the other
components of the green cross, if you will, what's attached to this sphere root
collision component. So upon scaling this, everything should scale
three times bigger as well, including that green cross. So let me compile this to
make sure my script is okay. Let's go ahead and click Play. So after three seconds, we should see this change. Whoops, and I accidentally
clicked off the window. Let me try that once again. Focusing on that green cross, boom, three times bigger. Let's try something else here. Again using our bp
example pickup, let me just delete out some of these unnecessary nodes here. Going to delete out these guys. Inside of our bp example pickup. We have this pick-up
sound variable, and currently it's set to
this interplay type of sound. Now I'm gonna change this
to an explosion type sound. And I can do that within my
Level Blueprint so long as I have a reference to this actor
that exists in the level. So once I've got a
reference to this, I'm going to drag a
wire off of this and type in pick-up sound. I can get that sound or
I can set that sound. Let me go ahead and set it. And now I can change the contents of that
variable to something else. Let's go ahead and change
that to explosion. And I will make it so that
off of Event Begin Play. I'm simply changing the
value of this variable, this pick-up sound variable, from this interplay sound
to an explosion sound. Alright, so once I play, you're going to
hear an explosion. Now, when I collect
that health pickup, a couple of other
interesting tidbits of information I thought
I would mention while I was here with this example pickup reference in
our Level Blueprint, if I was to right-click on this, I can find this
actor in a level. So if you're ever
wondering, Hey, where does this thing
exists in my level, you can go ahead
and right-click, click on this and jump
back to your level Tab, and it'll jump you right to it. Something else inside of your Level Blueprint that
you could do is let me just kinda pan off of
where this reference is. Say I'm off in no man's land. I can come under Window. I can come under,
find results in, in this fine results window, I can just type in, let's just type in pickup. And I can find my BP
example pickup right there. I didn't realize I
was going to find my pick-up sound as well, but indeed that has
the word pickup in it. Simply double-clicking on
this will jump me right to where that object
reference is to. Pretty sweet. Alright guys, so there
is how you can add some object references inside
of your Level Blueprint, make sure you've got the objects selected here and your level. And then you can
either right-click and some empty space and
create a reference to it, or hold down the Alt
key and left-click, that'll get you there as well. That'll do it all for
this video, guys. See you in the next one.
19. Level BP - Run Time Object References: Welcome back everyone. In this video, our goal is to learn how to create
references to objects inside of your
Level Blueprint at runtime. This differs from design
time object references in that will be capturing and containing
references to various objects while
we play the game. Remember design time is
before the game is running. Runtime is while the
game is running. Now a common use case
for this is items or enemies getting spawn into
the game while we play. Perhaps after an item or
enemies spawn into your level, you want to affect
it in some way. In order to do that, you must create a
reference for that object. You must contain that reference
inside of a variable. Alright, we're gonna
get started here inside of our level test map. And just to make
things super clear, over n My Open levels tab, I have my persistent
level as the blue level, the currently active level. I'm going to be adding
objects from here on out to my Persistent Level, not going to be
doing any more work inside of my sublevel. So just wanted to
make that clear. If you want to make
this the active level, you can double-click on it or alternatively
right-click on it and make current that blue font shows that that is
your current level. We're gonna be adding
one actor to this level. And to do this, I'm going to come under
my quickly adding to the Project button in the
flyout menu all classes. And I am looking
for a note actor. So I'm going to left-click
and drag this into my level and place
it right about here. Now, in known actor, if
you're playing the game, you don't actually see
this icon out here. I'm simply using this
actor as a way to define a point in space where I
want to spawn something in. Now note, I currently have
my note actor selected, and I can see that I have it selected here in my outliner. Please make sure that
you do have this selected because we're
going to be creating a design time object reference for this here in just a second. So coming up under my
Blueprints button here, I'm going to jump on over
to the Level Blueprint, even though I've got
it opened up here, that's how you can jump back
into your Level Blueprint. And what I'm gonna do is
I'm going to jump over to my E Event Graph Tab
right over here. In some empty space, I'm going to create a design time reference
to that note actor. I'm going to hold down
the R key and left-click. So you saw me do this
in the last video. That is a design time reference. Now, I'm gonna come back
to this in just a moment, but I need an event key. I'm going to right-click and
some empty space and type in the one button. I'm going to add a
keyboard event for when I press the one key
on my keyboard. And often this, once
I press this button, I'm going to drag off
of this and type in spawn actor from class. This is a super
handy function, no, that's going to
spawn in something that we tell it from
this drop-down. What do we want
to spawn in here? I will spawn in
something visual. Let's spawn in this
blueprint effect fire. This comes from the
Starter Content Pack. Again, if you don't
have this constant pack when you're putting
this course together, anything will do
something visual. So it doesn't really
matter what you put in. I'm going to choose
the fire though. However, I do need
to tell this where I want this to spawn
and that's where this spawn transform comes in. And I have to plug
something into this transform input so it knows what to spawn
and then where. So that's what this note actors
is going to be used for. I'm going to drag
off of this and type in get actor transform. The transform is the locational, the rotational, and actually the scale information
for this node actor. But we only really care about
the locational information. So it's fine that we use
the entire transform here. Plug this into my
spawn transform. And this is where
we are going to create a runtime
object reference. We're going to be storing
something inside of a variable while the
game is running. So off of this
return value here, as I hover over the pin, it says it will return one instance of this
blueprint, the fire object. Now I want to store this into a variable so that I can affect it in some way while
the game is playing. So I'm going to
right-click on this pin and type in Promote to variable. So in doing this, over
in my variable section, I've created a new
blueprint effect fire. But I need to give this a name. I'm going to call this
promoted promoted fire. That's a fine name. So even though this
is a variable, I can compile this as well. Currently, when I compile this, I look at the default
value in and says, Okay, this is going to be of this blueprint site is Blueprint
fire effect, fire type. But right now we've got
nothing inside of here. However, once I
press the one key, this will spawn that actor at this location and then set
it inside of this variable. It'll essentially
contained inside of this container while we
are playing the game. Now we're simply
going to do this at runtime so that we
can then destroy it. So down below here, I'm going to Right-click type
in the two key, two inputs. They'll whittle down to
the keyboard to key event. And off of this, I'm going to drag out
type in, Destroy Actor. It's a very visual function. That's why I like
it so much when I'm putting these
courses together. And then it's going to say, what object would you like
to destroy which actor? Well, I can just drag
and drop this right onto the target to instruct
that to destroy it. Now note that if I was to jump in and play and
press the two key, in fact, I will do that now just to
demonstrate something. Playing the game. Let me see if I can kind of put this off into a
side window here. You can see my scripts. I'm going to press
just the two key to, to, to, to, to, to, whoops, I got to select
a debug option up here. Let's choose my
test maps so we can see the flow of execution here. And so I'm pressing that
two key and you can see that pulse off to the left
there as I press the two key. But watch this. When I hit Escape, I'm gonna be span
with some errors. And the reason I'm getting an error is because it's saying, Hey, we can't find anything
inside of this variable. We're trying to
destroy this thing, but there ain't
nothing in there. So the reason for that is because nothing is
currently stored in here. However, when we
press the wonky, we will spawn an actor that
blueprint fire effect, and then we will store it
inside of this variable. We have created an
object reference stored inside of this variable. So let's try this again. Clicking play. So my note actor was a round above the spot where my
character's head is here. So I'm going to press one key. There is that fire effect
That's just spawned in. And I'm going to press
the two key gone. And I can press
the one key again. Another instance
of that firewall, populate that variable,
press F2 key, gone. Now something else
worth noting here, I'm going to jump back
to my level test map. And I'm gonna change
my play option here, clicking these three dots. It changes to be playing
not in a new editor window, but in this selected viewport. I'm doing this because if you
look over in the outliner, over on the right-hand side, when I press the one key, you're going to actually
see that actor gets spawned into my list of
objects over in the outliner. So check it out. You can oppress the one key. You see the blueprint
effect fire appear right above
my BP example. Pickup two is going to
destroy it one to one. And just to point
it out there it is in the Outliner right there. Let's try a second example here. Right up here I'm going
to place under volumes, trigger volume, a
trigger volume right in front of where my character
is going to be spawning. And I'm just going to size
it up a little bit to ensure that my character has an easy time
overlapping this. I'm going to pick it up
off the ground slightly. Then with that selected, I'm going to jump into
my Level Blueprint here, and I'm going to right-click
add an event for when we overlap this
beginning, overlap it. And again it trigger
volume event like this is on actor
begin overlap can tell us who is the other actor that overlap does what I'm going to do those I'm going to
right-click on this pin and I'm going to promote
this to a variable. And in doing that, you
can give us a name. It's defaulting the name
here for me to other actor. Because before this
video recorded, I had entered that in as a name. You can press F2 on that
to rename it though. So once we overlap this, it can store a reference to
this actor that overlapped it during runtime as to
who the other actor was. Just to ensure that we know that in fact is
overlapping is taken place. I'm just going to play a sound, hear any sound will do. I'm going to jack up
the sound here as well. We'll play sure. A camera shutter,
this is just two. Notify us, it's something
in fact has happened. So that's great. But let's assume that when our character has overlap
that trigger volume that, that is, oh, that's
negative in some way. Maybe that's some sort of a poisonous gas cloud
that's going to shrink us. So once we've got a
reference to our actor here, we can affect them in some way. So I'm going to drag off
of here and bring in a reference to my other actor. And off of this I'm going
to type in the word scale. We'll set actor scale 3D. And I will press 0.5.5.5
values into each of these. So let's jump in, in play here. Once I compile, compiles, going to check to make sure
my script is all good. Let's play. I've got
my test map set as my default object that
I'm debugging here. So we can see these
scripts firing off. Here is my player window. So right in front of me, that invisible trigger volume. You heard me overlap that. In now. The other actor has been
populated during runtime here. So as soon as I press the
key, the other actor, AKA me in this point, they act or scale is going to be set to half size. Here we go. I'm pressing the
one key right now. Boom, down. I go. One more example here. Before we close this up, we're going to
show how to create multiple references to
actors during runtime. I've currently duplicated
my example pickup here. You can do that simply
by dragging and dropping individual instances or by alt, left clicking and
dragging on one of these to create another instance. So back in my level blueprint
off of my 16k event, what I'm gonna do is
I'm going to drag on a wire and type in, gets all actors of class. And in the actor class, I can slot in my pick up
my BP example pickup. And this can output all
instances of that actor. So I'm going to right-click
on this out actors pin. I'm going to promote this to
a variable and call this my pickup actors. It's an array. Again, I know we haven't
talked about array types, but an array is essentially a
list of a type of variable, in this case, are
BP example pickup. It's going to store all of those inside of here so that we
can affect them in some way. And what we're gonna do
to them is drag off of this pin and type
in for each loop. And again, I have a video dedicated to the
for-each loop coming up. So if you don't know
what that is right now, not a big deal. So for every item in this
list that we store here, we're going to do
something to it. And what we wanna do is for
each item in this list, the array element, we're going
to get the display name. And then we're going to print
this to our player window, hooking this in like so.
Click this drop-down. I'm going to change this
to a pink coloured texts because it makes it stand
out a little bit more. So essentially what's
happening here is as soon as I
press the one key, we're going to do a
search for all actors of a given class that
exists in my level. And we're gonna be storing them while we're
playing the game at Runtime inside of
this array variable, they're all going to be
of this variable type, my BP example pickup type. And then for each
item in this list, we're going to print out their display name
to the screen. Let's go ahead and
give us a play. And once again, I've got my level tests map listed up here. It acres, it increments that number each time
I play the game. So that's what that number is. You don't have to worry about
what that number means. Right here we go. Click and play. Now note in the upper left here, as I press the one key, you're going to see that flow of execution go through here. And it lists out all five
instances of my example pickup. I can do it again
and again and again. I'm just spamming
your right now. Now if you know back here
in my Level Blueprint, if I click my list of pickup
actors here in the editor. Well, there's
nothing inside here. Once again, we're populating the contents of this
variable during runtime, we're capturing it
inside of that variable. So let's do something off
of the two event here. Let's set the lifespan
of the mall Shelley. So once we've got a reference
to that list of actors, I can then grab that list of
actors, drag and drop it. Let's get it off of this. I'm going to type
in for each loop, we're gonna do something
for each item in that list. And what we will do is off
of the array elements. So this is for each
item in that list, I'm going to set their lifespan. Again. Each of these has a
lifespan property within them that I could affect. I'm gonna change that
lifespan to be two seconds. Alright, and let me just
shrink this down a little bit. I've got my test maps set as my debug option. I'm
going to click Play. Let me just move this play window and down
here a little bit, pressing the one key to populate
that list of variables. It's now been populated. So when I press the
two key, one to gone. So there you all have it. Some of the many ways you
could go about creating runtime object references
inside of your Level Blueprint. We talked about how
to do that off of a spawn actor from
class function node. Also when overlapping
a trigger volume, we could also hit another object as well
that would do it. Also, we talked about
how to do this off of a, get all actors of
class function. That's how you can
get multiple actors. There are other ways to be sure, but hopefully this
gives you a grid, sorry, guys, that'll do
it all for this video. See you in the next one.
20. Class BP - Design Time Object References: Welcome back everyone. In this video, our goal is to learn how to
create references to level objects inside
of a Class Blueprint. Now in doing so, we'll be
able to write script inside of a class blueprint that
can affect level objects, things place here in our level. This is a really handy trick
to know and unreal for creating a simple per
level setting system. So we're gonna be
doing that, although just a little bit of
a disclaimer here, this is going to be a super
simplified setting system and I'm using air quotes here. Alright, we're going
to start off in our content scripting
overview folder. And over in some empty space, I'm going to right-click
and I'm going to create a new blueprint class. This is going to be based on an actor class because
we're going to be placing this inside
of our level. So I'm going to be naming
this BP underscore L V, which is going to stand for
level underscore settings. Then I'm going to double-click
on this to open it up. And I am going to add
one component here, and I'm going to add a
billboard components. In this billboard components
by default gives us this dragon head
type of Sprite icon. This is the one I'm
going to roll with. You could change this out
to be something else, but this is going to designate
in my level that hey, this is your BP level
settings actor. I'm also going to
make this the root of this because I want to get rid of that default
scene root icon. So let me just drag and drop
this right on top of there. That's going to make
it the root and thus the only icon IC. So now if I place
this into my level, I can see this little
dragon head icon. Yes, the dragon
heads going to stand for my level settings in
order to the Details panel. If you do a search for
bill board and again, you've got to have
that level settings blueprints selected. You can whittle it down to
editor billboard scale. I'm going to change this
to be something like ten times the usual size. Just to make this
really stand out. This actor will not be seen
when you play the game, but for something like
a level settings actor, I like to make this
very prominent, very easy to see. And again, you don't
see that in game, so no worries there. Alright, the next
thing we're going to be doing is creating a variable inside our level
settings blueprint here. So under the variables section found within the My
Blueprint panel, variables. Plus, we're going to add
a variable called Music. And we're going to change
the variable type here from a Boolean to ambience. Sound, ambient sound
in object reference. Now over in the Details
panel, it says hey, compile this to set
a default value. So I will do that. However, I am going
to leave this blank. We're going to set this
within our level editor in order to be able to set this particular variable
from the level editor, I've either got to click on this little close eyeball icon or check this box where it
says instance editable. You see right now if
I was to go back to my level editor with
this actor selected, let me just exit out. I don't see This music variable, expose it all inside my editor. However, if I either
click this eyeball icon, which does the same thing as checking this
instance editable box. And I compile that
and I save it. Now here back in my level
editor that has been exposed here in the Details
panel inside my level editor. So what this is allowing
me to do is to set the value of this variable here in the editor
to some actor. In the editor, I could
click this drop-down box. And I can see that there's
nothing in here, however. But there's this pick actor from scene eyedropper
that would allow me to pick a sound file
that exists in my level. So let's go ahead and
search for a sound to play. I'm going to select my
content folder here. And I'm going to use
the filters option. And I'm going to
search under sound. And we'll do a search for sound wave files
that will search for any sound wave files
anywhere within my content folder or
any of its sub folders. I want to find this
starter music. So I'm simply going
to drag and drop this into my level, like so. Now if I was to jump
in and play our game, actually hear them
music escaped. And the reason for
that is because our starter music, let me just, with that selected, activate my viewport here and press
the F key to focus up on it. My star music in
the Details panel has a property for auto
activate checked on. I'm going to check that
off for the time being. And now if I play, I don't
hear that level music playing, pressing Escape once again. So what I wanna do now is in the side of my BP
level settings here, I want to set the value of my music variable to
that piece of music. So here we go. I'm going to pick
actor from scene. I'm going to select this
ambient sound actor. And now it's going to
slot that star music inside of my BP level setting. So that's all well and good. However, inside of
my BP level setting, I don't have any scripture to actually tell that to play it. I can change that
by going over to the Event Graph and doing
something off of event. Begin play here. Let me just delete out
these two other actors. So now I can drag
in a reference to my music variable here,
left-click, drag. We're going to get it. And if I drag out of here
and type in the word play, I can play the audio components. So long story, short, if you drag out of music, that variable, the ambient
sound variable right there, it'll bring in this audio
component automatically. We can set a delay. I'm going to right-click
and some empty space and type in delay. So we don't hear
this right away if we wire it through here as well. So let's say after two seconds, we will start at the very beginning of
this musical track. Let's compile and save to make sure that our
script is all good. And if I play after two
seconds, you don't play that. Let's try another
example here quickly. Over here in our
variables section, I'm going to click
this Plus button. And I'm going to type in
directional light as the name. It's gonna give me
ambient sound as the variable type because that was the last
thing I created. I want to change that. And I'm going to change this
out to a directional lights, directional light
object reference, not the component directional
light object reference. Now once again, if
I compile here, this is an empty variable. There's nothing inside of here. But also once again, if I check this
instance editable box, that'll make this eyeball
icon come alive to again, these do the same thing. And I compile this and I go
back to my level editor. I've now expose this variable to the level editor once I've got my BP level settings
here selected. Now the reason I set this to be exposed is because when we
created our test map level, I know that by default it had a directional light actor
already in this level. That is, this guy right here, this sort of sunlight icon with this white arrow
hanging off that guy. So what I can do is with my level settings
blueprints selected. I can set my directional
light inside of my BP level settings to be talking to this
particular actor. So let me click the eyedropper
right here and look. It knows that these
objects are not valid. However, that is valid. None of these other ones are no, but that is a
directional light actor. So we can set that one. Boom, it is now set as well. Let's hop back into
our BP level settings. And if I drag and drop this
into our event graphlets, get that off of this, I'm going to drag off
and type in sets. Intensity will set the intensity of our light component here, because directional light
consists of a leg component. And we'll set our
intensity here to, let's try a value of say, 500. Just continuing the flow
of execution right after our beginning of play and then the delaying
of two seconds. So after two seconds, we're going to hear
our music kickin. There's pressing that Q key
where that comes in handy. Then we're also going
to set the intensity of our directional light actor or compiled script is looking good. Let's go ahead and play. You can see we not
only hear the music. So these are some rather
extreme examples here, but we have created a very
basic level setting actor. And notice the power here. I could drag and drop this level setting actor into other levels as well and set a
unique piece of music and a unique
directional lights. So long as I am pointing
to a directional light for this variable and an ambient sound for this music variable. So you got to have
these in your levels. Well, whoops, directional
lead actor in music actor. But this is how we're setting level actors level objects inside of our BP level settings. A Class Blueprint, guys that is gonna do
it all for this video, we will see you in the next one.
21. Class BP - Run Time Object References: Welcome back everyone. In this video, our goal is to learn how to create
references to level objects inside of a
Class Blueprint at runtime, that is, while we're
playing the game. Now this is really useful when, for example, you want your character to interact
with something in your world. And then he wanted
to do something to that thing that you've
interacted with. Alright, to show off this example that I have
for you here today, I'm going to be putting
some stuff inside of our blueprint
ThirdPersonCharacter, this will work inside of a first-person
character as well. But once again, this
is the character we're using for this project. So go ahead and double-click
on this to open it up. Let's go over to the
viewport tab because we're going to see a component
here in just a little bit. We're going to add a brand new component in
our list of components. We're going to add
an arrow components. Go ahead and click on that. And I'm going to call this
my line trace end point. And with that
components selected, the x location for this, I'm going to set to be 300. Unreal units hit Enter. And if I kinda sweep on over, holding down the right mouse
button here, my viewport, I've set my arrow
component to be out ahead of my character
here by 300 unreal units. Now what we're aiming to do here is we're going to be sending out an invisible line into space using this component
to help us here, we're going to check to see if this invisible line
collides with anything. And if it does, we're going
to figure out what was that thing that hit us so that we can affect
it in some way. In doing this, we can create an object reference at runtime
while the game is running. So let us jump on over
to our Event Graph. I'm going to come over
into some empty space. And by default, character class blueprints
do recognize input events. So I'm gonna hold down, or rather Right-click
and type in the 0 key. By the way, not all
class blueprints recognize input
events by default, but the character class does. Off of pressing the 0 key. We're going to bring in
a function node called line trace by channel. There's a lot of different
trace function nodes. The one we're looking for
is line trace by channel. Now way later on the course, we'll talk about some
of these traces. And this is going to be way
more advanced than where you are at if you are
beginning with blueprints. But the circular nature of learning Unreal
Engine blueprints is that to know about this, you need to know about that. And to know about that, you need to know about this. So if you don't understand this part right here,
that's completely fine. We'll be getting to
some of these concepts. Just bear with me. This is just showing
off a technique for getting a runtime
object reference. Alright, so this node
is going to send out an invisible line trace
into our world here. So where do we want
to start this trace? Well, how about we started
at our actors location? So I'm going to right
click and some empty space Typing get actor location. And this will
return the location of ourselves or our
ThirdPersonCharacter blueprints. That's where we're
going to start this. Where are we going to end this? Well, that's why I included this line trace
endpoint component. I'm going to drag and drop a reference to this
into our graph. And then I'm going to drag
off of this and I want to get the world location
of this components. So essentially I'm
gonna be starting off this invisible line trace into our world at the location of
our ThirdPersonCharacter. And it's going to
extend as far as our line at trace endpoints. So from here to here, alright, moving along here, what we're gonna
do is this outfit. Essentially it's going
to give us a lot of different results about
what this did hit. And I can break out the
hit results here by typing in a breakout hit result. Clicking this down arrow here. So this invisible trace, this invisible line
being shout to the world can give us all kinds
of information, including what was
the actor that a hit. It can output all
this information. The one we're looking to have
output is the hit actor. Now, what we can do off of
this is right-click on this. We can promote this
to a variable. Let's do that. And let's keep the name
Hit Actor over here. And you can see
the variable type is just a generic actor. Now up above here, I'm going to drag a wire out
of this and type in branch. And I'm going to plug our return value here
into the condition. Essentially what we're going
to be saying here is we only want to continue
beyond this branch. If indeed it was true
that we hit something, we're going to only execute what's beyond this branch here. If it is true that
our line trace did hit something,
that's our condition. So let's drag a wire off of
this type in play sound to D. Let's have a
little sound feedback for if we did in
fact hits something. Let's set our sound
here to be anything, but I'm going to set this
to be clicked on a button. Sure. We'll go with
that. That sounds good. Off of this, I'm going
to plug this flow of execution into setting
our hit actor. So in fact, if we
did it something, if and only if we
did hit something, are we going to set the contents of this
variable if I compile, notice right over here
the default value is none only if our line
trace hits something. Well, we set the contents of this variable and
we're going to be doing it while playing the game. Off of this, let's
extend a wire out and type in print, string. And out of our Hit Actor. Let's just drag out of here
and type in get display name. So we'll print out the name
of the thing that we hid. So let me frame up
this script here. So if you want to
pause the video here and get a good
gander at that, you can see what we have built. Can't keep, can't quite get
the right zoom level here. There we go. One more setting that would
be useful here to set our Draw Debug Type here
to be for duration. In doing this, when
we press the 0 key, we're going to see a little
bit of a line there, a debug line, if you will, being shot out into the world. So we can see that
this trace channel leave it to visibility. For now that is our
default trace channel. This is essentially a name
channel that we're going to be shooting this
line out from beyond. Alright, and with this, we can actually
compile this, save it. Let's jump in and play to see if we can see a
line being shut out. Again once we press a 0 key. There, you see that red
line being shot out. That red line being shot out. Now the reason you're
seeing the red line being shot out into the world, but you're not
seeing that flow of execution in my script up
at the top is once again, because I've not set
my debug option. So I need to play first. And once I am playing, that's going to spark my
character into the world, then I can set my BP
ThirdPersonCharacter. Let me bring on that
play window once again. So when I press that 0 key, I can see that flow of
execution going right now. I'm not hitting anything. So you see that the flow of execution is stopping
at the branch. However, if I go to
an object chair, you heard the sound in the
upper left and my play window, it prints out the name of S M chair, cube, example pickup. And it's not going through this. It's that hitting
this bench at all. And the reason it's not
hitting this bench is because this bench Static Mesh does
not have any collision on it. So that's why it
is skipping that. So something to
keep in mind there. My Construction
Script wall as well. Okay, So this is
all well and good. We are setting this object
reference at runtime, but let's affect this
object reference in some other way once we have
captured a reference to it. So let's just put a little bit of additional script
down below here. I'm going to right-click
and some empty space. Let's bring in the
nine input button. There we go. And off of this, I'm going to bring
in our Hit Actor. Let's get that. And then let's drag a wire
out of this type in is valid, this question mark version. And if this is a valid object, meaning does it exist? If it is valid, we're going to drag
off of this inside been Destroy Actor. The target. We want
to be our Hit Actor. That's the thing we
want to destroy. Double-click on that to
create a reroute node. Little cleanliness there. So let's try to frame up
this script right over here, both of these scripts, so you can see them working. Let me go ahead and play. Try to shrink down this play
window here a little bit. Alright, if I was to
go ahead and press the nine key right now,
what you'll notice, you can see it is pulsing
out of the nine key over on the left-hand
side as I spam on that. But It's not advancing beyond the
is valid node because there is no valid hit act actor
that is an empty variable. However, let's press
the arrow key. I have now checked
to see if that is a chair by setting
that variable. Now when I press the Nike, the hit actor has
been populated. And boom, it goes bye-bye. Walking up to this cube, pressing the 0 key that has now been set
as my new Hit Actor. Pressing the Nike, boom,
that goes bye-bye. Now it's important to
note here that are Hit Actor is just a generic actor. We're not sure which object
we hit and so we can't modify variables are called functions specific to this
object reference. If we did want to do that, we could cast it this object to ensure that it was
of a given type. Now once again, this is
going to be a little bit more advanced for where
you're at right now, we will be talking about casting more later on in the course. But just to show briefly how you could do
something like this, I'm just going to
modify this script here a little bit more. Let's try something like
this off of my Hit Actor. I'm going to cast too. We'll do example pickup. We're gonna cast
and check to see if that was an example pickup. And if it is, Let's scale this
this type in world scale. We'll set the world scale
of our sphere collision, which all the other
components are attached to. And we'll set our world
scale here to be, well say, three times as
big and the x, y, and z. So once again, our
line trace is what's going to be populating, creating a reference to
our Hit Actor variable. If that is valid, we're
going to check to see if it was an example
pickup blueprint. And if it was, we're going to scale it
up three times as big. So let me just minimize
this way over here. Jumping in and playing, wrestling the 0 key. I don't wanna get
too close to this. Pressing the 0 key right now. My hit actor has now been set. Yet. There has been set. Let me just back away so I don't accidentally overlap it
when I scale this up. Now I'm going to press F9 key. And wallah, it is set the world scale of that
to be much bigger. Alright, there you
have it, guys. There is one very
practical use case of a runtime object reference. Again, there are other
ways to do this, but a line trace is
a super useful way, especially inside of a
character blueprint. That will do to
offer this one guys, see you in the next one.
22. Casted Object References: Welcome back everyone. In this video, our goal is
to learn how to cast to an object in order to create
a reference to something. So first of all,
what is casting? Casting is a way of
checking if a given type of object is of a
specified class. Now you saw me do this in
my BP example pickup here. We were checking to see what is overlapping our
collision sphere here, that is this sphere right here. In this case, we were checking to see if
that other actor, if the thing overlapping it was a ThirdPersonCharacter we were casting to see if that was
the ThirdPersonCharacter. Now, if it is of a
specified class type, in this case, the
ThirdPersonCharacter. We can then immediately capture that object as a reference. And more importantly, do things
specific to that object. There might be
functions, variables, or components inside of our specific class
that are unique to it. So by that, I mean, if we capture a reference to our
ThirdPersonCharacter here, if this is true, we can capture reference to
our ThirdPersonCharacter. That means ThirdPersonCharacter. We can talk to the
components in here. We have any variables
inside of here. We can modify them in some way. We can modify some of the class default
variables inside of here. Things such as
jumping max count, which is a fun one
to play around with. Hint, hint, you can double, triple jump with that parameter, all kinds of things. So note, this topic of casting is a topic
we're going to talk way more about in the Blueprint
communication section later on in this course. But for this video, we're simply going to
talk about how to create object references by
casting to a given thing. Alright, let's show
off a few examples here back in my level test map. Firstly, I want to
check that you have a player start actor
here in your level. And if you don't,
you can come under your little button here to
quickly add to your project. And in the all classes
category here, you can find a
player start actor, that guy right there, drag and drop one of those. Make sure you've got one
of those in your level. And then if you
come right up here, you've got these
three little dots to change your play mode
in place settings. This is where you can
change to play it selected view port or
a new editor window. By the way, however, I want to draw your attention to this spawn player at currently, we have this ticked, that means checked to spawn
a player character at our default player start that is at this actor
location right here. I could change this, change this to the
current camera location. So wherever I am in the
level, if I click Play, I could spawn from this location that I'm
looking at right now. However, we want this
set for purposes of this video to
default player start. Alright, with that, we're going to create some
script to capture a character reference inside
of our Level Blueprint. So once again, you can access
your Level Blueprint coming here and opening your
Level Blueprints. Boom. Now I want to do something
off of Event Begin Play. Now, earlier in this course, I created a second event graph
and I named it node types. And I mentioned we can only have one event begin play per
our Level Blueprints. So I'm just going to delete
it out of here and do all this work inside of
our base event graph here, our default event graph, which is currently empty. So here I'm going to then
right-click and typing begin, play. Event B in platelets. Go ahead and add that. And then I'm going
to right-click. And in some empty space, I'm going to type in
git player character. This is a really handy function right here that's going to simply return the
character that you, a single-player are playing, as in this case,
player index is 0. We only have a single-player, so that is going to be us. Off of this. We can drag out and type in
Cast to ThirdPersonCharacter. If you're playing with a first-person character
template here, you can cast to a
first-person character. We're going to cast to our
bp a ThirdPersonCharacter. So what we're doing here
is we're going to get our player character and we're
going to then check, hey, is this a ThirdPersonCharacter that you're
controlling or is this some other character
that you had assigned in your
project settings? And again, our project settings can be accessed over here, project settings and
over maps and modes. Under our selected game mode, we can see our
Default Pawn Class. Currently, we are defaulting to a third-person character class when we're playing this game. But this is kind of a way
of just checking, hey, are we indeed playing as
a third-person character? Now, here's where the
thing really comes in, where we're using
a cast to create an object reference
right here off of as third-person character. We're going to
right-click on this. We're going to promote
this to a variable. As soon as we do this, it's going to hook up two wires to this center
variable right here. So in our variables section, it has created a new third
person character variable that is a type that has
been given to it. The name. We can change this out. I'm just going to change
this to be Character Rough. And then I will right-click
on this node and leaving node a comment and just
call this promoted. That is how we created
this variable. We promoted it off of our
beginning of play here. We are going to capture a reference to our
ThirdPersonCharacter. Great sweet. That means we can then
do something with it. And it's great to do
these types of things. Oftentimes off of an
event begin play, because once you've
got it reference to a given actor type
a given object, then you're good to go. You can affect in any
which way you want to. So I'm going to create
some script down here to then affect our
character reference. Let's right-click in
some empty space. And I'm just going to
type in a number of key. Let's type in the
one events Shelley. And off of this, I'm going to drag in our
character reference. It's going to say, do you
want to get it or set it? I want to get a reference to our player character
and offer this. I'm going to type in my
old set world, scale 3D. Now what do we want
to set in 3D here? Let's set our mesh. And if we go into our
ThirdPersonCharacter Blueprint, were talking to this guy right here with that
components selected. Our character mesh or person, our mannequin, if you will. Mannequin woman, if you will. Alright. So when we press the wonky, we're going to set
our world scale and don't leave it at 0 because then you're going to disappear. Let's go 0.5.5.5. And let's compile this to make sure that our
scripts look good. Let's save it. Let's then set our
debug option here to our test maps so that, that is the scripts that
we will see firing off. Let's go ahead and play. Actually let me make sure
that I've got this set to new editor window. Jump back to my Level Blueprint. Now, we've already created this character reference we began played this did fire off. But if I press the
one key right now, you will see that that
script has indeed fired off. I've captured that
character reference off of Event Begin Play, and I press the one key that's
set my scale to be 0.5. Now you can see I'm
hammering on the one key. Now it's not going to keep
setting it at half the size, half the size, half the size. I just told it, set it to half of its usual size right there. So that's one example of casting to our
ThirdPersonCharacter, creating an object reference. Alright, let's try
another example here. This time not using
a player character, a third or first-person
character. I'm going to come under my button here to
get some content. I'm going to add a sphere. Let's go ahead and add
a sphere to our level. I'm gonna raise it
up into the air. And then I'm going to set
a couple of parameters, one on my sphere here and
then one on this floor mesh. First of all, I'm going
to rename my sphere here by simply clicking
on it and pressing F2. And I'm going to call
this my physics ball. That'll help offset
it a little bit. This is a static mesh actor. And then down in
the Details panel, I want to check a box
called simulate physics. And under this physics section here it is, simulate physics. Now what this is gonna do
as soon as I play the game, this ball is going to
drop down to the floor. Let's go ahead and
click play here. And you can see, whoops, I want to go to, in fact, I don't need
to play the game. I'm going to briefly
set this to simulate. And the moment I do, you're going to
see that bulge is dropped down to the floor. So simulation is
running the game, not playing the game, but there you saw the results. What happens when you run
the game without play? That was simulation mode. Now it's stuck in simulation
mode right now I'm gonna go back to new editor window. Near you saw that ball
dropping once again, shift and F1 will give
me my mouse cursor back. Let me exit out of there. Okay, so we've got our ball set to simulate physics
that's important. Next, go ahead and select
your floor mesh here. And what I wanna do
here is I want to look for something called simulate generates hit events. And if I come under my
collision section right here, here's a checkbox
I'm looking for simulation, generates,
hit events. This is going to be
a simulated ball, meaning it is going to
have physics on it. Simulation generate hit events for this floor means that it will generate a hit event
for a simulated object, aka this physics ball. So it's important
to have this box checked for what we
are going to be doing. Next, we are going to be
accessing our Level Blueprint. However, I want to
make sure that we've got our floor selected
here firstly. So make sure you've got
your floor selected and in your Level Blueprint. Let's move over to the
right here I'm going to right-click and
some empty space. We're going to add an event
for floor collision and we're going to do in
on actor hit events. Then off of this, we're
going to check to see what was the other
actor. They hit me. So if we drag off of this, we can cast too. Let's cast to a
static mesh actor. Why are we casting to
a static mesh actor? Well, we're casting to
a static mesh actor because our physics ball here, if I select that, the type of actors that this is, is a static mesh actor. Okay, let's jump back into
our Level Blueprint here. And once again,
let's promote this to a variable by right-clicking on that
pin, promotes a variable. And I'll rename this is
physics ball like so. The type is a static mesh actor. And let's just print some
texts after this as well. I'm going to drag off of this. We can print string
or print texts. I'll just go with print
texts in the text field. I will change this
to hit the floor. I'm going to right-click
on this and also leave a node comment and
call this promoted. Alright, let's do
something here with a key as well. I'm
going to right-click. Let's bring in a two key to key. Whoops, that was F2. I mean, we could really
do this off of anything. I'll just do the two key
because that's obvious. And then off of this, we want to get a reference
to our physics ball here. So let's drag and drop
this into the graph. We're going to get it.
And then off of this less simply type
in set material. We want to set a material on the static mesh
components, like so. And we will say
that once we press the tube and we're going
to change our material to, I'm going to type in gold. You can change this
to whatever you want. So once again, I'm
going to make sure that my debug option here is
set to level test map. Going to go ahead and
click in the play here. You solve that fire
right up above as I've got the window grabbed here, you can see I grabbed it
perfectly so you can see that pulse flowing through
the actor hit floor. We're casting to our
static Mitch actor. We are capturing our
physics ball there, any variable we are
creating a reference to it and we're printing it out to
the screen, hit the floor. And it's printing out
multiple times there. Once I press the two key, this should turn solid gold. And there you go. You've got a physics ball
that has turned solid gold. You can see it's registering
those hit events again, again as I roll it
across the floor. Because of course,
why wouldn't it? Alright, so there you have it. You've got a couple of
instances there of us casting to create an
object reference. Plenty of more things we
could have cast into figure. You could find some
use out of those. That'll do it all
for this one guys, we will see you in the next one.
23. Widget BP References: Welcome back everyone. We're starting this
lesson off here in the Internet by showing off
a couple of examples of, in this case, in inventory
screen from a Legend of Zelda, breadth of the wild. And also I want to show
off this example of the in-game HUD of
Legend of Zelda, breadth of the wild. So in unreal, if you want
to create something like health meters or mini-maps
or in-game messages, or in inventory screen, any of this kind of stuff, you need to create a
widget blueprints. So our goal in this
video is to learn how to create a reference
to a Widget Blueprint. So we're not going
to be really honing in on how to create
widget blueprints. Although we will be doing that, that's a whole another
course unto itself. But once you've created a
Widget Blueprint asset, how do you create
a reference to it? We're, we're gonna be
doing in this video is creating one of these assets. We're going to just put
up a simple health meter. It's not gonna be functional.
We're just going to put up with simple helped
me to earn her hood. Now we're going to
create a reference to it so that we can toggle it on and off
bacteria in Unreal, we're going to start
off by creating a brand new folder inside
of our scripting folder, I'm going to
right-click New Folder. I'm going to call this Widgets. Then inside of here, I'm going to right-click
over on the right. We're going to come
under user interface. And we want to create a Widget Blueprint asset in
the pop-up box that appears, it's going to ask us to
pick a route widget. All we wanna do is select
this most common one, the user widget one. Again, this is not going
to be a lesson on how to create every aspect of
a Widget Blueprint. I'll simply name this
WPP underscore HUD. And then we'll
double-click on this to open up this Widget
Blueprint asset. So long story short, what you can do here is you can drag and drop
different elements, these different widgets from
this palette panel right here into this viewport to
lay out a screen of sorts, a hood, a menu screen, a text notification,
all this kinda stuff. We're going to create
a very basic HUD, having a health bar. And we're going to
start off by adding a canvas panel widget. So under the palate panel, I'm going to do a search
for a canvas panel. Canvas panel is essentially
a tack board is going to be the widget that we can
stick other widgets onto. So I'm going to drag and
drop this right out here. Boom, we see this green
outline over in the hierarchy. It shows a listing of
all the widgets you have added to your
Widget Blueprint here. So currently we've got this
canvas panel and giving us a giant tech board, if you will, to
stick things on to. Great. Next we're going to add a
horizontal box components. Horizontal Box is simply an empty box that can
contain other widgets. I'm going to drag and drop this in the upper left here
because I want my HUD to have a meter of sorts in the upper left
corner of my screen. Now, currently it is this
size, this predetermined size. However, I'm going to adjust
this in just a second here, but just for sake of
extending this out, I'm going to change my size x here with this selected
to be something about, I don't know, 400, let's go 500, probably a little bit long,
something like that. Again, this is just an empty box that can house other widgets. Next I'm going to find a text widget right up here
under the common section. And I could drag and
drop this on top of my horizontal box to have this contained inside of it that way. Or I can simply drag
and drop it right here inside of my
horizontal box like this, you can see this
little indentation here showing that relationship. So currently this text
widget is contained within our horizontal box. I'm gonna change the text here. So with this selected over
in the Details panel, I'm going to change
this text that says textblock to simply health. I'm gonna give it a couple of spaces there because I'm going to add a health meter, if you will, right to
the right of this. So hitting Enter, Boom is going
to change that to Health. Next, I want a meter to go
right over to the right here. You can add this by adding
a progress bar widget. So I'm going to once
again drag and drop this inside of my horizontal box. Now the moment I do this, it's going to appear as
this grayish little slab, if you will, which does not
look at all like a meter. So the way we can change
this is with this selected, this progress bar widget selected over in
the Details panel, we can change the
size to be a fill. Boom, there you go. Now to actually fill this up, we've got this fill color and opacity which is
currently set to blue. You could click on this
to change the color. I'm going to go green, some shade of green.
Sure, That's good. But this percent right
here is going to determine how Fill
this is currently. It is 0% filled. So I'm going to left-click
and drag and you can see how this
can go between 01. So essentially this goes
from a 0 to 1 scale, 0 to a 100%. And you can choose
your bar fill type, left to right, up and
down, right to left. However you wanna do it, I'm gonna leave
the default there. This is going to work
just fine for me. So what this created,
I'm going to simply compile this.
We're going to save it. Awesome. We've got this Widget
Blueprint all created. Next thing we're gonna
do here is create some script that is going
to create this widget. And then we're going to
create a reference to it. We're going to add
it to our viewport, meaning it's going to
show up within our game. And then we're going to add
a little bit of script so that once we've got this
reference to our HUD, we can toggle the visibility
of this HUD on and off. I'm going to be using the ThirdPersonCharacter
Blueprint for this. Now, if you're creating
something like HUD, typically you would not use the character blueprint
to show or hide the HUD. But since that is a blueprint that we have
used up to this point, I'm going to use it just
for the purposes of showing how to create a reference
to a Widget Blueprint. So open up your
ThirdPersonCharacter Blueprint. If you forgot where that is
within your content browser, you can find it here under
third person blueprints. In inside of here, jump on over to the Event Graph. And we want to do something
off of event begin play. So I'm going to
right-click Typing, begin play, even begin planning. Boom. And often this, we're
going to drag out a wire and type in create widget. This is going to currently
say constructed none because we don't have any widget set
here in which to create. However, if you
select this class, little drop-down there, we can find our Widget Blueprint
that we've just created. Now once we select
this, we set that. It's going to say, okay, that's the Widget Blueprint
that you want to create. Great. But we have not saved
this to a reference yet. So let's right-click on
this return value here. To promote this to a variable. We do this. It's going to create
this variable over into my blueprints section. It is going to be of
the WB P HUD type. And I'm going to name
this appropriately. We BP HUD. As I've done before, I'm
going to right-click on this. And in the node comment area, I'm just going to leave
this as promoted. That's how we created that
reference to our widget HUD. And then what we're going
to do is drag off of here and type in
Add to Viewport. So essentially what
we're doing here is upon beginning play, once our character is
spawned in the game this event begin play fires off. We're going to create
this Widget Blueprint. We're going to create
a reference to this Widget Blueprint
inside of this variable. So it's going to capture
it inside of here. Then we're going to add
it to the viewport, meaning it should
show up in our game. Let's go ahead and
compile this to make sure that our script is
all good and it is. And then I'm going to
play just to verify that we see this HUD in the game. And there you go. In the upper left-hand
corner of the screen, you can see that we've got our non-functioning Health Bar. Alright, now since we've
got a reference to this, Let's create a little script
to show or hide this. Inside of here. I'm going to right-click
and some empty space. I'm going to bring in, Let's do the five key y-naught. And let's bring in a reference
to our Widget Blueprint, drag and drop this. We're going to get
it off of this. I'm going to drag off and
I'm going to search for a function called
set visibility. And I'm going to
hit Control C and Control V to create a duplicate, a copy of that, and
then a paste of it. This will be our target. When we press this, we want this to be hidden. So set the visibility
here to be hidden. And then when we release it, we're going to tell this widget
to be visible once again. Now, how did I even know that this function
was available to me? Well, many times, back here
in our Widget Blueprint, if you look over at the various widgets that you have added to your hierarchy, you can see all of
your properties in the right-hand panel over
here, the Details panel. And one of them for
this particular widget is the ability to
show or hide it. As you can see right now,
I've got this progress bar, visible or not visible. This entire thing can
be shown or not shown. The visibility of this can
be visible or not visible. Over here, I am saying, Hey WPP, when I'm pressing the five key,
I want to hide you. When I release it, I want it to show once again and we
can do this because we captured a reference to our Widget Blueprint compiling. This will check to make sure
that your script looks good. Let's say this. I'm gonna go ahead and play. There. You can see it. I'm going to press the
five key and hold it down. It is now hidden. And when I release it, it shows once again. So there guys have it. This was not a video on how to create a Widget
Blueprint that again, that's a whole another course. But how to create a reference to a Widget Blueprint notes. You can create references
to widget blueprints from class blueprints or a level
or sublevel blueprint. References to widget
blueprints are typically created at runtime, maybe off of a
game play or maybe off of a trigger volume
when you overlap things like a weapon for
some kind of pick up notification or AML
pickup notification, that sort of thing. That'll do it all for
this video, guys. We'll see you in the next one.
24. Tag References: Welcome back everyone.
In this video we're going to learn how tags added onto actors can
be used to find objects, create references to objects, and then affect those
referenced objects. So a tag, what are we
talking about here? Well, a tag is essentially
a label or a keyword that we assign an associate
with a given actor. And then if an actor
has a given tag, we can affect it in such a way we can create a
reference to that object. We can call a function on it, do all kinds of cool things. So we're going to
demonstrate that here. Before we do if you want
to play along at home, I've got three different
actors setup in my level. The blueprints ceiling light
is located at this location. If you've got the
starter content, I've got one of those out here. This fire emitter is in this location in the
starter content folder. And then this cylinder I just
grabbed from right up here. Boom, a cylinder if you
want to play along at home. Alright, so we're going to
add a common tag that is a keyword of sorts to all
three of these actors. And I'm going to
find that tag in the Details panel
with my cylinder selected by searching for tag. And I'm going to
whittle it down to component tags or actor tags. We want to add an actor tag, one associated with
this entire actor. Again, different actors can have different components
set up with them. We just want to
have one associated with the actor at large. So under actor advanced tags, click this little plus
button and we get to name the tag and I'm going
to call mine thingy. And just to ensure I don't have any spelling mistakes here,
I'm going to highlight it, hit control C to copy it, because I'm going to add
this exact same tag too. My fire emitter here. So I've got that
tag whittled down here to find my actor tag. Let's add that. We're going to add that here. And then also for my
blueprint ceiling light, we're filtering by the word tag. We're going to add that to
our actor advanced tag. And let's put that
name in here as well. Great, next, while
we're at it here, why don't we include this on
our BPS over here as well, our example Construction Script, as well as our pickups. So I'm going to navigate
to where these are at in my folders here. Bp example pickup. Let's go inside here. If you want to add a
tag to this blueprint, you wanna go under
your class defaults do a search for a tag. There it is, actor tags. Let's add things
in here as well. Go ahead and compile, save that. We can close that out and then we get rid of that
from the last video. Let's also get our
construction script wall right here in
underclass defaults, make sure you got
that selected tag. Let's add a tag for this guy. And there we go. So just wanted to show
where you would add that inside of a
blueprint itself. It's important to note that here I'm adding it to
the blueprint itself. For this particular
ceiling blueprint, I'm adding it just to this instance of the
object inside the level. I didn't actually
add this inside of the ceiling blueprint here inside of my ceiling
Blueprint Class default. If I search for tag, I won't see it here because I didn't add it
to the blueprint itself. Just this particular instance of the blueprint in my level. So let's start off creating
a reference to all of these tagged actors
that I'm gonna do this inside of
the Level Blueprint. So coming right under here,
open Level Blueprints, we got a bunch of scripts
that I've currently disabled all of the events for. I'll probably clean
this up between videos and get rid of some
of this old stuff here. Let's come under some empty
space in our event graph. And I am going to
right-click do a search for the T key, T inputs, inputs. Let's come under a keyboard. Keyboard events. Really, any keyboard
event will do. I just want to go with T
because T stands for tag. There's a tiki. And often this we're going
to drag out a square and we're going to
bring in a gets all actors with tag node. So unsurprisingly,
this function will do exactly what it
says it will do. It will get all actors
with a given tag. Here's the name of the
tag that we want to find. Anything with the tag thinking and with this out actors pin, it's got this sort of a waffle
type icon that is going to give us an array of actors
that have this tag. That means a list of
actors that have that tag. Let's right-click on this,
Promote to variable. And let's simply call
this our thingy array. You can see it created
this variable over here. So when I press the T key. We are going to store
all references to actors that have this thing
you tag inside of this array. And this array is
going to be a listing of all actors that
have this tag. Alright, so that will happen
when we press the T key. Let's do something to all
of these actors then. Now that we've got a reference
to all these actors, what do we wanna do with it? Well, I'm going to right-click
and some empty space. Once again, I'm
going to bring in the up key keyboard
event for up. And I thought that
that was appropriate because we're going
to be moving up these actors in
the z coordinate. I'm going to drag in my thingy array,
we're gonna get that. And then off of this, I am going to drag
out a wire and bring in a for each loop. Again, we're going to be talking about these for each loops, these flow control nodes
later on in the course. What you all need to
know for now is that for each item in this list, each item in this array, we're going to do
something to it. And what we wanna do is for each item in here, each element, we want to add actor
local offsets. And we end, we're
going to move it in a given direction
at an offset to it. And we're going to change
the delta location. That is, how much do we
want to change it from its initial location versus where it is the next time
we press the up key, up 50 unreal units
in the z-direction. So Tiki is going to get a reference to all
actors with this tag. The up key is going to look at all items within this array, all items in this
list stored in here. And for each item here, we're going to add an offset here that is to move it
up in the z location. Now, I'm going to
compile this script. Everything is going
to look good. However I know, let
me save this as well. When I play this in
error is going to occur. I'm going to let this happen, but let's go ahead
and give this a play. Alright, so I added
that tag onto that. They're cylinder, the flames, the ceiling lights that cross and the wall in the background. Let me do shift in F1. So I can minimize this. I want you to see this script
firing off here as well. So I'm going to shrink
this down a little bit. And I'm going to
press the T key. So I've got a reference
now to all of those actors bearing
that thing you tag. Now I'm going to
press the up key, that is the up arrow key. And well, some things move up. But that cylinder does not. And that's the era
was talking about. Let me go ahead and escape. And the air is going to demonstrate what
is happening here. It's gonna have mentioned that this Static Mesh
Component has to be set to movable if we'd like
to be able to move it. So static meshes aren't
going to just move without us changing one of
their settings to movable. So that's easily
fixed by going back into our tests level here,
selecting our cylinder. Right here. It's talking about the mobility
setting of the cylinder, changing this to movable. So once again, if we were
to go ahead and play this, let me shrink this script
down here a little bit. So right up here,
pressing the t key, we've got an array of all the actors with
a tag of thinking. And now, once I press
the up arrow key, all of them will move
up 50 unreal units. We're going to add
50 as an offset every time we press the up key. So let's just think about
all the possible use cases of creating references
in this way using a tag. Well, maybe you're spawning some different enemies and your level as time goes
by during a match, say every 20 seconds. And so you can't ever be sure how many enemies exist
at a time in your map. Now say you want to destroy all enemies in maybe some
environmental objects. Whenever the player collects super-duper, destroy all item. We could get all actors
having a given tag, say upon overlapping
that super-duper, destroy all item and then
destroy, adjust those items. So all kinds of good, useful use cases for that. One more side note I wanted to give here before
ending this video, we can do a check to see if an individual actor has a
tag. How would we do that? Well, I've got my cylinder
selected here in my level, back in my Level Blueprint, I'm going to right-click. I'm going to create a
reference to that cylinder. And off of any reference here, I can simply do a search
for actor has tag function. Then I could plug this into a branch node so I could
do a search here to see, hey, does that cylinder
have the tag of thing? And if it's true, we
can do one thing. If it's false, we
could do another. Just wanted to point
that out here as well. All right guys, that is
how you can go about creating references using tags. That'll do to offer this one. See you in the next one.
25. Event Begin Play: Welcome back everyone. In this section of the course, we're going to be exploring
events in greater detail. We're gonna be exploring some of the more commonly used
events in Unreal, starting off with
Event, Begin Play. Now our goal specifically
in this video is to gain an understanding of what
the begin at play event is, where you can find it and how we can make use of it in unreal. Now, jumping into
our level test map, our Level Blueprint here. You can find that by going
here, open Level Blueprint. You can see that I've set up some script prior to
shooting this video. I'm going to run all of this
off of Event. Begin Play. Now it looks a
little intimidating, but I'm going to
walk you through the different things that I'm
doing and why I'm doing it. Now. First of all, how
do you get an event? Begin play in here? Well, a couple of methods. One you can right-click
and just type in begin play like cell, That's how you can find it. Alternatively, I like to
use the hotkey shortcut, which is to simply hold down
the P key and left-click. Now, fun thing to note here before we even hook
this up is you can only have one event begin
play per blueprint. And it doesn't matter how
many graphs you have. If you remember earlier
in this course, I created a second graph
called node types. Now if I jump on over
to my node types graph, I'm currently in my
Event Graph, Graph. And I hold down the P
key and left-click. I can't find it. Alternatively, if I type in a search bar by
right-clicking and typing in, Begin Play and I click on it, going to jump me to
my Event Graph tab. So that's one thing to note. You can only have one event
begin play per blueprint. So then that begs
the question, well, what if I want to do multiple
things off of the event? Begin play? Do I just need a long strand of script to make
multiple things happen? Well, no, you don't. That's where this sequence
node comes in handy. We will talk more about the sequence node later
on in the course. But just know that the sequence node is something that you can use to essentially
split your signal. So by plugging event begin
play into a sequence node. You can add more output pins and then make one thing happen, then another, then another, and another, all in
sequential order. So let's explore what I'm
going to be doing in here. Off of event B in play inside
of my Level Blueprint. Well, the first thing I'm gonna
do is play a sound event. Begin play is a great
event to use if you want some music to simply start up at the beginning
of your level. The second thing I'm
gonna be doing right down here is getting my player
character casting to my ThirdPersonCharacter and then storing my
third-person character inside of this variable so
that we can make use of it. So casting to our
ThirdPersonCharacter and then encapsulating it inside
of this variable. Right down below is where
we're actually going to be using this variable that
we just stored here. We're going to get our character reference that we stored here. We're gonna get our actors location and then we're going to set that inside of
this vector variable. So something that is often
done off of event begin play as well is something called
initializing variables, that is to give it
an initial value. Now earlier in this course, and just talking about generally the different
variable node types, I create a variable of a vector variable that
had default values of 000 and they would be 000 if I didn't give
them some other value. In this case, I am
initializing it. That is giving it some
initial value that is based upon my
characters location. So it's going to feed our
characters location into this and store it inside of
this vector variable. Initializing variables
is something that is commonly done
off of begin play. And I'm also going to
print the results of this off to the
screen so that we can see the location of our character reference
when this is set. So three things
we're doing here, off of event begin play. We're going to play some music. We're going to create a
reference to our character. And then we're going to use our character reference to help initialize this vector variable. Here we go. So you can see some
initialization of our vector variable right here as being printed
off to the screen. You can hear the music. And of course this character
reference it as being said. That's not something that
is very visual at all, but that is being done off
of the event begin play. Next, let's talk about
where you can and cannot find Event Begin Play. As you can see it is here
in my Level Blueprint. What about my sub
level blueprint isn't available in there
as well? Yes, it is. And I'm going to click
right here to open the sublevel Level Blueprint. And I created some
scripts prior to this video in which I
am going to delay for three seconds and then play an explosion sound
and I'm going to debug so we can see
this firing off. But you will notice that once I play in wait for three seconds and
nothing seems to happen. The reason for that
is because I am not loading this subnet
level blueprint. And what I mean by that. If I go back to my levels tab, I need to right-click
on the sublevel, change the streaming method from blueprints to always loaded. And now if I go back
into my sublevel, I can click Play. You see that event firing
off the delay counting down, and that will make
Event Begin play, play the stuff that
comes after it. So it is available in a low blueprint as well
as a sub-level blueprint. Also, the event begin
play can be found in actor class blueprints such
as our example pickup here. Again, I added this prior
to shooting this video. You can also find it in third-person
character blueprints. You can see we're using
it here to create our HUD and show
it on the screen. However, you will not find
this in our widget blueprints. Here's our health meter,
the Widget Blueprint. And if I go over
to the graph tab, and I right-click and some
empty space and type in and begin play. You won't find it. Event Construct is essentially the event begin
play if you will, inside of a Widget Blueprint, you also will not find it inside of a game
instance blueprint, but pretty much every
other Blueprint class you can find Event Begin Play. And lastly, one more very
important thing to mention about Event Begin played
before we wrap up this video. While it's true that
this event does fire off when we begin play, what do we do for
different actors that spawn in at some other
points during play? When does Event Begin
Play Start for them? Well, event began play
starts for those blueprints. The moment those things is fun. And just to show this, I'm going to scroll down here a little bit in my level test map, and I've set up a
little bit more script off of event begin play, where I'm going to be
spawning a blueprint, ceiling light that was found MI star contents
after three seconds. Now, let me just bring this
on down a little bit here. So you can see it's
a little bit better. After three seconds
in our low blueprint, we're going to be spawning this blueprint ceiling light at a given transform non gotta
feed this a transformer. This is going to fail. Let me go in here
and I'm going to add a all classes I
clicked right here. All classes will find a note. Let's find a note actor just to give us a place
in space to reference. I'm going to lift, lift
it up in the air like so. With that selected, I'm going to jump back to my Level Blueprint, hold down the R key, left-click, There's
my note actor. I'm gonna get that
actors transform. We're going to spawn
this ceiling light. Now, what I did prior to
this video in my blueprint, ceiling light, and once again, that could be found in my
star content blueprints. This ceiling light right here is I created this bit of script
where I am beginning play. We're gonna delay
another three seconds. I'm going to set my point
lights attenuation radius. That's essentially how far of an area or point
light can affect. We're also going to
set its light color to this pinkish color. This event begin play
is going to fire off the moment it's spawns
into our level. And again, I'm spawning
into our level here in my level test map off
of event begin play. So let's debug this
setting that lake. So we tried to frame
this up like that. Okay, compile that, make
sure our script is all good. And in here we go off
to the right there. After three seconds. That light does indeed turn. So once again, here in my
blueprints, ceiling light, this event began play
fired off as soon as this actor spawned
into the level. So to review event begin play, it is great for running
script at the outset of play. In this case, playing some music is great for creating
object references. In this case, creating our ThirdPersonCharacter
reference is great for initializing
variables. In this case, I'm using it to initialize our vector
variable here. It's also good for spawning actors after a given
amount of time. Plenty of things you can do
off of event. Begin play. Well guys, that is
going to do it often. This video we will see
you in the next one.
26. Event Tick: Welcome back everyone. In this video, our goal is to understand what event tick is, where we can find it
and how it can be used. Now, since this is an event
that fires off every frame, you must use this event carefully or you risk totally destroying your
game's performance. That is, your frame rate can
suffer in a big, big way. So use this event with caution. So events it can be found
in just about any blueprint inside of Unreal that
includes Level Blueprints, sublevel blueprints, and
most class blueprints. One exception to that, but I know for sure is the
game instance blueprint. We will talk more about that important blueprint
type later on in the course. I'm just going to right-click
it some empty space here. I'm going to create
a new Blueprint Class of the actor type. I could choose any of these.
I'm going to choose actor. I'm going to leave it
as that default name, and I'm going to simply
double-click on it to open it up. And you can see when we jump
on over to the Event Graph, that event tick is one of the default events that is
immediately available to you. Now, if you were to
delete this out, let me go ahead and do that. I could right-click
and type in Tick, and I can add it back in there. Now you can only have
one of these paragraphs. So if I was to right-click
and type in Tick again, in simply going to be
like yep, there it is. It's going to jump
you right to it. Now I'm going to delete out this blueprint right here and
I'm going to jump on over to my Level Blueprint to do
some things with event ticks. So open Level Blueprint. There is my event tick. It is also worth noting
that you can only have one event tick per a
blueprint, not per graph. This is my Level Blueprint. In, in my Level Blueprint, I have currently two graphs, my Event Graph Graph and my known types graph
which I created. I was creating my
video talking about the different node
types in Unreal. So if I was in my Event Graph, Right-click and type in the
word tick and clicked on it. It's going to jump me over
to my node types graph meal. Yep, there's your event tick. There it is. Now event tick, as
we said earlier, it fires off every frame. Now, it's worth noting
that you can show your frame rate in
the level editors. So we're going to do
that now before we continue talking
about events here, jump back to your level editor. And here you've got this
three line hamburger icon, if you will, go ahead
and left-click on that. Right here, show frames per
second Control Shift and h, doing that will output
your frame rate to the screen that's 120 frames per second that I'm
currently running it. That's 8.33 milliseconds. Alright, so something else
that's worth pointing out here is you can set a
fixed frame rate. This is kinda a little
bit of a tangent here, but it's worth noting as well. If you go into your
settings, project settings, and you type in frame rates, I like to fill these videos
with all kinds of knowledge. I could use a fixed frame rate. Right now it's set to 30. There's no Save button
here or anything. And now if I was to jump
back to my level editor, they're showing I'm
currently running at 30 frames per 2.33rd, 33 milliseconds, going
to undo what I just did. So event tick fires
off every frame. Let's do something with our events inside of
our Level Blueprint. So let me just move
it on up here. And I am going to add, we'll add an enemy to our level. Not a fancy enemy of course, but here in my content browser, I'm going to come under
my mannequins folder, my meshes folder. You can place anything
in your level here. It's going to represent a simple, stupid,
non-functioning enemy. I'm going to drag and drop this Quinn simple into my level. And with that
selected, I'm going to jump back into my
Level Blueprint. I'm going to hold
down the R key in left-click to create a reference to our Quinn simple enemy
there, if you will. And off of event tick, I'm going to drag off of
this and I'm going to type in is valid. I want this question
mark version. I'm going to be checking if
my inputted objects here, my enemy is valid. That is, does it exists? And if it does not exist, meaning it is been destroyed. We're going to do once. What are we gonna do once? Well, we're going
to play a sound indicating that it
has gone, bye-bye. We're going to play a sound 2D, and we'll play a confirm
sound VR confirmed q. Now if we're going to
go with this checking to see if it is valid or not. We need to have some means
of destroying this actor. We need to destroy it so that it then checks as not being valid. Remember, this event tick is going to fire off every second. So I'm going to right-click
and some empty space down here and we'll do the four key. In off of the four key, I'm going to pull down our left-click to bring in another reference
to our Quinn simple. And I'm going to
drag off of this and type in Destroy Actor. Right? So the idea here is that every frame we're
gonna be checking to see if our enemy Quinn symbol
here is valid or not. If it is valid,
meaning it exists, we're gonna do nothing. If it is not valid,
meaning it's destroyed. Onetime we're going to
play this sound and this is how we're going to
destroy that actor. So this evaluates is not valid. Alright, let's go
ahead and play. And you can see event tick
is firing off every frame, but it's not getting
beyond this is valid because it is continually
checking is valid, yes, it exists in our level. However, once I press
the F4 key, here we go. It is been destroyed. And you can see how we
onetime played that sound. So that is a perfectly legit
example of using event tick. Now, one thing I want to
point out here is you can modify the tick rate. Now if our game is running
it at 120 frames per second, event tick is going to fire
off 120 times per seconds. Now, if I click on my class defaults
button right up here, I can modify the tick interval. And again, it says in seconds, the frequency in seconds at which the tick function
will be executed. So it doesn't have to
fire off every frame. I can fire this off
every two seconds, every three seconds, I'll
go every five seconds. Now this is going to be a
little bit extreme example. But now as soon as
I destroy my actor, it's not going to play
this sound immediately. Let's go ahead and
give this a try. I'm going to click Play. I am going to press the F4 key
to destroy our actor here. And then finally it played the sound a little bit
lagging after that. And that's because
it's only ticking, it's only firing out this
event tick every five seconds. So that's a way that you
can modify your event tick. Now here is a another practical
use case for event tick. Having something rotates to face another thing throughout a game, such as this chair, because obviously you would have a chair rotating the face
of player all the time. Now imagine if that was a security camera or
a turret look into gunned down in the
player and you wanted to attract the player. You could do that
every frame it's changing its rotation
of re-frame. Now, if you want to play along at home and see how I did this, I simply placed a static
mesh chair in my level. You can find when they're
in that directory, I changed the mobility for this selected chair to a
movable in the Details panel. And then in my Level Blueprint, this is my script for
having put that together. You get a reference
to your chair by selecting your chair, holding down the Alt
key and left clicking. And what I'm essentially doing here is I'm saying hate share. I want you to look
at this player and update the rotation
of that every frame. Now, we have not even talked
about deltas seconds here. So let me, I'll put this
to the screen firstly, we'll drag out here,
go print string. Delta seconds is the amount
of time between frames. So jumping back to my level editor
here we're running at a 120 frames per second, which is 8.33 milliseconds. So if I play this, it should show that the
time between frames is 0.0083 seconds because we're running at 120
frames per second. A 120 times that number is going to equal one full second. So there you have it. You might also notice
that in the upper right, it is not showing my frames per second while I am playing, even though it is doing
so in the level editor, the way we can get our frames
per second to show up in our play window here is
to simply tap Tilda key. That's the one to the left of the one key on most
keyboards in the upper left. That's going to bring on
a little console bar, if you will, at the bottom, if I type in stat
FPS and hit Enter. Now show your frame rate
in the upper right there. Good to know. Now you can use the output of Delta seconds in
calculations that determine how much
a given actor like a platform should
move each frame. In this way, you can use that
Delta seconds outputs to move a platform the same amount
regardless of frame rate. That's a little
bit more advanced. I'm not gonna get
into that, but just giving you a quick
primer on what Delta seconds could be used for most times you're not
going to need it though. And finally, at the very
beginning of this video, I mentioned about
how you have to be careful using authentic. Because if you don't use
it in a good manner, you could destroy your
game's frame rates. So I'm going to
demonstrate what not to do inside of my BP
ThirdPersonCharacter. You can find that character
blueprint here in this directory inside of
your content browser. Inside of here I've
pre-prepared a script. We're off of event tick. I am simply getting
my actors transform. That is where this
ThirdPersonCharacter is going to be located and
rotated within the world. I'm then going to be spawning a blueprint effect fire
that I've set right here. This is a spawn actor
from class node. And out of this, what I simply did is I drug out of this and I am getting the fire audio component out
of this blueprint. I'm just drawing that component
as soon as I spawned it in every tick here, every frame. Because otherwise
the audio for this gets really annoying,
really fast. So note that once
I click play here, my frame rate is going
to be destroyed. It's gonna go from
120 frames per second down to 20 pretty quickly
here. So here we go. Look in the upper right here. Notice that it is spawning a fire effect wherever my
character is, every frame. And you can see how detrimental that is
to the frame rate. And once again, if I go into
my class default here and I set my tick rate to
be something like, oh, let's, let's set it
to every three seconds. This could be something
that might be acceptable. So now, instead of this firing off every frame in
my class defaults, I'm saying, hey, authentic only fire off every three seconds. And doing this, you can
see that my frame rate is going to remain pretty
steady at least for awhile, because I'm only spawning that particle effect
every three seconds. So if you're going to use events tick and you really
don't need to spawn something or rotate
something or do something. Every frame come under the class defaults and set your tick interval
to some number. Well guys, that is gonna do all for this one for event tick. We will see you in the next one.
27. Event Input: In this video, our goal is to show how we can
utilise input events. One of the most
common events using gaming to fire off
a bit of script. Now when we're talking
about input events, we're talking about things like key presses on the keyboard. It could be button
presses like the a or B button on a
traditional controller. Or it could be something
like touching a device, a mobile phone, or an iPad, that kind of thing. Uh, typically these input
events are simply registering. Did you press it or
did you release it? Input events are not to be
confused with access events, which can read in a range of values like your left
or right thumbsticks on a traditional control
pad can tell if your character is moving just a little or if you're
trying to run with them. So access events are
different from input events. Now in the example I'm
about to show you, we're going to be making
it so that pressing a button makes our
player character sprint. And then releasing that
button causes us to return to our normal
locomotion speed. I'm going to be using our ThirdPersonCharacter
for this video. So if you want to
play along at home, it's in the content
third-person Blueprints folder. That's where you can
find that blueprint. Double-click on
it to open it up. And inside of here you can
see that we have already made use of some input events. Specifically, I'm
using the arrow key on my keyboard to send out a
line trace into the world. And up above here I'm
using the five key to hide or show my HUD Widget Blueprint that I am creating
upon begin play. If I move over to the
left here a little bit, there are some
other input events that were here by default. We have an input
action jump that this is set in your project settings and I'll show you how to do
that and just a little bit. And we've also got
a touch input. So both of these are making our character jump
or stop jumping. Alright, I'm going to add this sprint script just to the right of our jumped scripts. So right-clicking in
some empty space, I'm going to type in
the word keyboard to find all of our different
keyboard events. And you can bind this
to whichever key, like I'm gonna do
it with the L key. And I'm also going to bring
in a another event as well. I'm going to right-click
and some empty space. And I'm gonna do a search for a game pad, face button, bottom. Now, as you know, the PlayStation and
Xbox controllers are pretty identical. So gamepad face button bottom corresponds to the x button on the PlayStation controller, or I believe it's the a button
on the Xbox controller. You know that diamond
configuration over on the right-hand side. So they named them
rather agnostic, so as not to call out one particular
controller or another. Okay, what do we want
to have happen when we press the L key on a keyboard or hooked up
gamepad to your computer. Well, we're going to grab our character movement
component here, because if we select our
character moving component, you can see that
we've got a lot of different properties that
we can modify about that, including our max walk speed, that is this
parameter right here. This is determining how fast our character is moving
throughout the world. So I'm going to drag in our
character movement controller or Character Movement
Component, not controller. For this, I'm going to drag
out and I'm going to say is set max walk speed. Once again, that is
going to allow us to modify our max walk speed. And I'm going to hit
Control C and copy that Control V to paste that. Like so. And so when I press the L key and release the L key would all want our max walk speed to be. Well, you can see
that currently I have my max walk speed set to 500. I'm going to say
when I release it, I want it to set it back to 500. But when I want to sprint, I'm going to set
this to be something like 3 thousand
something kinda crazy. Now I currently don't have my gamepad face button
hooked up to this as well. But I can, I can make it
so that by either pressing the L key or the face
button bottom on a gamepad, I can set our max walk
speed to 3 thousand. Or if I release the alkene or release that face button bottom, I can set our max walk
speed back to what it was. Going to left-click,
drag, tap the C key. This is my Sprint script. Compile this to make sure that the script is looking good. And then let's go ahead
and set up click Play. And I'm going to set our debug option right up here to be our
ThirdPersonCharacter. Let me just bring in that
play window once again. Alright, so you can see we hit shift in F1 to kinda move
this down a little bit. Now you are going to be able
to see as I press the L key, that script firing off. And then when I release
it, it's going to set my max walk speed back. So WFISD to move around, holding down the L key, moving much faster,
releasing it. Going much slower. Alright, now this is not ideal. I've got two separate
input events essentially doing
the same thing. And they're also not
very descriptive. I've gotten L, a key and a
gamepad face button bottom, essentially doing
the same thing. Is there a way that
I can simplify this? And the answer is yes, you can. What we're gonna do is jump back to our main level editor. And over in the settings,
project settings, we're going to come under the left-hand side and
select the input category. And in here we can create our own action
mapping, input events. We've got access mappings
or action mappings. It's very important
that you do this under the action mappings. Now if I expand out this
triangle right here, we can see that one action
mapping input event already exists called jump. And this is interesting
because if we go back to our third-person character, go back to our jumps grip, we have an event node
called input action jump. The reason this exists is because in our project
settings we created a jump action mapping that
is an event node named jump. And currently if I
expand this out, I can see that two inputs will call for this input
action to happen. A spacebar on your keyboard or the gamepad face
button bottom. So we're gonna be adding a
new action mapping here. Click this plus button to
add a new action mapping. And we're gonna name
it whatever we want. I'm going to call mine sprints. And I'm gonna say, this is
gonna be bound to L key. Or clicking. I can add as many
of these I want. I'm going to make
it so the gamepad, Let's do face button, right? Sure. Gamepad face
button, right? Either of these
pressing the L key or the gamepad face button rights would make it so that our
character can sprint. Now there's no Save button
or anything in here. With this created,
I can jump back to our ThirdPersonCharacter
Blueprint. I can now right-click in some empty space and
type in the word sprint. And it will find our new action event that we
just created called Sprint. Going to name the node
input action sprint, I can now delete out
these two nodes, hook them up thusly. And if I were to jump
in and play once again, W, a, S, and D to move around
holding down the L key. And you can see that
I am sprinting, releasing will gradually,
slowly back down. Now, the next very
important thing to realize about input events is that while you can add them to a whole host of Blueprint types, not all of them will fire
them off by default. However, some will. If you were to add input events
to your Level Blueprint, this will execute as expected. You press the Z key,
it's going to print out this string
level to the screen. It will also do it for
character and pawn blueprints. So if I press the X key within my ThirdPersonCharacter
Blueprint, it is going to print
this out as well. It will also do it for player
controller blueprints. And now that's gonna
be something we talk more about later
on in the course. But inside of my project
settings right here, under maps and modes
player controller, that is the blueprint type
that I'm talking about. You can use input
events inside of the player controller
blueprint without any sort of special setup. However, in something like an actor class blueprint like
BP example, pickup here. If I was to press the C key, one of these in my level, it's not going to print
this out to the screen. So just to demonstrate this, let me go ahead and click Play, clicking on my window
here to activate that, I'm going to press the Z key. You see that texts level
appearing in the upper left. If I press the X
key multiple times, you see that texts printed out. However, if I press that C key, that texts that's supposed to say pickup here in
the upper left, that's not going to print out. And that is because actor class blueprints are not set up to register input events. By default, however,
you can change this within the class
default of this blueprint. So if I select my class defaults here over in the
right-hand side, I've got a category
called input. And as auto receive input in
here is currently disabled. However, if I change
this to player 0 because I've currently
got a single-player game. That'll make it so that now
when I press the C key, it'll print this
out to the screen. Let's go ahead and try this. Now when I press the C key, you can see the texts pickup now is printed out
to the screen. Now, it is worth noting
here that here in my class defaults
I had to change this inside of my
actor class blueprint. For the auto receive
input to be player 0. If you look in
something like say your ThirdPersonCharacter
Class default and you go to the input section. It currently also says auto receive input is
disabled as well. However, once again,
character and upon class blueprints
level blueprints and a player
controller blueprints. They will register
these by default, even though this is a
little misleading here saying auto receive
input is disabled. Next, we need to talk about
how unreal prioritizes the same input event when
used in multiple blueprints. And to demonstrate this
in my Level Blueprint, I'm using the X key
to print a string. I'm also using the x input inside of my third-person
character now. And I'm also using it inside
of my BP example pickup. Well, it's hooked
up in three areas. So if I click Play
and press the X key, which one is it
going to prioritize? And you can see is prioritizing my actor at class
blueprint right here, because I have enabled in my class defaults that I will receive input
from player 0, me, the loan player. So the prioritization
goes as follows. If you have a setup
like this using the same input after class, BP's will be prioritized first, followed by Control or player
controller blueprints than level controller blueprints and then Character
Controller blueprints. Now, what happens if two blueprints of the
same type receive inputs? Well, in that case, we would take in this
higher input priority. Now to demonstrate this, I'm going to unhook Just to
make it perfectly clear, the X key inside of my ThirdPersonCharacter
and inside of my test map. And now I've got my example pickup
hooked up to the x key. And I'm also using my BP example construction
script inside of here. I'm also going to be hooking up my X key to print
out this string. Also note here inside
of my class defaults. I've set up under the
input area for player 0, that is me to
receive input here. Currently both of them are
sets to input priority 0. Input priority 0, there it is. So which one is
it going to show? Is going to show this
pickup or is it going to show the construction script? Well, if I play it in press X, it's going to prioritize the one that I added
that x input to. Most recently. How ever? If I was to go into
my example pickup and change the priority
to a larger number, something higher than what is
in the construction script. It could be one,
it could be 100, it could be 5 thousand. Sure, Let's just go 5 thousand. It should now print out pickup as soon as
I press the X key. There we go. And finally, one more thing
I wanted to add about input events within your graphs is that if you have
that node selected, there are some options over in the Details panel you
can fiddle around with. This is a quick way for you to change the input key right here. You can also add a modifier. So instead of in this
case pressing the X key, you could be forced
to press the Alt and x keys at the same time in order to make
something happen. But the one I really wanted to talk about that I
learned through trial and error was this
execute when Pause options. A lot of games, you have it set up so that if you press
a certain button, you can pause the game. And then if you
want to unpause it, you press that same button. We'll check out this setup. I've got going here. I've currently got
it set up so that when I press the X key, I am going to pause the game. And then when I
released the X key, I'm supposed to be
unpause it and the game, but watch what happens here. I'm gonna go ahead
and click Play. You can see this
spinning health pickup over here that's going to really show off that the game
is paused or not. I'm pressing the X key
and everything pauses. I released the X key and
everything remains pause. And the reason for that
is I am not allowing this event to continue to be executed when
the game is paused, that's currently set to false. So if I want to make
it that this will continue to execute even
while the game is pause, I'm going to check this box. And so when I press
the X key now, it'll pause the game. However, when I
released the X key, it will un-pause
game because this is also going to
execute when pause. Here we go, holding down x, it's pausing it and now
I'm going to release ECS. And it also fired
off that pressing, or in this case,
releasing of the X key. So there you have it
guys that is gonna do it all for this one
about input events, we will see you in the next one.
28. Event Axis: Welcome back everyone. In this video, our
goal is to learn what access events
are in unreal, how we can create them, in how we can use them. Now in actuality, our
character blueprint already has some access events
inside of it and working. Let's go ahead and
check those out. First, coming into your content third-person
Blueprints folder, you will find your BP
ThirdPersonCharacter. Double-click on
that to open it up. And this is where we left off creating our sprint input event, that action input events. And this already had
jumped input action event that the fine folks at Epic Games had already
included with this. Now up above you will find some axis events and it
even says it in the name. We've got an input axis event for moving forward and backward, one for moving left and right. This controls our
character's movement. And then up here we have some
camera input axis events, one for the gamepad, and then one here on PC
for you, a mouse folk. And this is determining the movement of our
camera left and right and up and down as
we're moving that all around. Now, where did these axis
events even come from? Well, if you remember from
our last video inside of our project settings
is where we can create not only input action events, but also these
input axis events. So I'm going to come
under my edit button in the far upper
left of the editor. This is another way that you can access the project settings. Inside of your project
settings come under the inputs option along
the far left-hand side. And as you can see, we've got action mappings that we dealt
with in the last video. And here we've got
access mappings in here all the names for the various axis events that currently exists
inside of our editor. Now if I expand out one
of our axis events here, I can see that I can bind not only keyboard buttons to
a given named access event. I can also buying some controller inputs
as well that is similar to the input action mappings that we had
in the last video, like our jump and our sprint. Now, we'll talk about what these scale values mean a
little bit later on here. But before we even get to that, let's define what an
axis events even in is how does this differ
from an input event, one of these action
input events, well, the main difference is access events are events that
are fired off continuously, that is, once per frame to
really drive home this point, let's jump over to our third
person character blueprint. And if I zoom out just a little
bit here and click Play, you can see that my various access events
are firing non-stop. And it needs to because
if it's gonna be handling our character
movement per se, it needs to be
updating our movement every single frame
forward and back, left and right, as well as
the camera movement right. Now another defining trait of
access events is that they can output in axis
value and this ties in. If I jump back to our
project settings, these scale values that you see along the right-hand side
of the various inputs. For w, we have a scale of one, and for S we have a
scale of negative one. Now, to see these at play, let me jump back into my
BP ThirdPersonCharacter. And I'm going to
modify this script here just ever so slightly. I'm going to right-click
and some empty space and type in print string. And I'm going to
take our input axis, move forward and backward, pipe it right through here. And I'm going to be
outputting the axis value. It's going to convert
this float into a string, and it's going to print
it out to the screen. Let's go ahead and do this now. And you can see once again, this is firing off every frame
along the left-hand side, you're seeing a value
of 0 because I'm not pressing down either W or S. Now, when I press the
W key to move forward, look along the left-hand
side of my play window. You see all those
values change to one. My axis value is one. When I press the Esc key, it all changes to negative one. Now, on a keyboard is
all or none, right? There's no gradient
as you can get with an analog stick
where you can just kinda nudge it
just a little bit. On a keyboard. It's just one. Give me all of this
going forward, or the opposite of one, which is negative one. We're using the values
of one and negative one to mean one
thing going forward, or the opposite of that
thing in this case, which is going backwards. Now, if this is all
little confusing, you can mouse over
this scale value on this function node for
adding movement input. And they can tell
you that it can be used also for analog input. It does not have to be
just one or negative one. These scale settings are
just determining the range. And you can have a range
with an analog stick, whereas you cannot have
that with keyboard events. Now, I currently do have a controller hooked up to my computer to demonstrate this. Let me jump back in here. Click Play. And now I'm going to be using my Xbox controller and pressing forward with the left
thumbstick ever so slightly. And you can see
the value is 0.08. And as I nudge it
forward more and more, it is giving me good as
getting me closer to one. Whereas if I pull down on the thumbstick ever so slightly, and then more and more
and more and more, it's getting me closer
to my other bounds, which is negative one. So the analog stick
is allowing me to go somewhere between negative 11. Now to further drive
home this point I have a graphic here for you. Looking at a bird's eye view, top-down view of our character. This is our left thumbstick. In the Project Settings
under our access mappings, we set our w to have a scale value of one That's
as far as we can go, that equals you are going
forward as fast as you can. On the opposite end. Our S key has a value, a scale value of negative one, meaning the opposite of one, in this case going in
the reverse direction. Now again, on a keyboard, if you press W, There is
no, no in-between here. You're either going from 0. I'm not moving all
the way to one, I am going forward
and full speed. If I tap the S key, that means I am going
backwards at full speed. There is no in-between, however, with the
left thumbstick, you can make it so
that you could just nudge it forward a
little bit and get halfway to your bounds
of one or negative 0.5 to your bounds of negative one going in
the reverse direction. Now, it is worth
noting here that your scale values do not have to run from one to negative one. You could set some
other scale values, but oftentimes that
is the range set. Alright, Next, let's go
ahead and create a couple of access events that
we can make use of. So I'm going to click this plus button under Access Mappings, make sure you do not do
this under Action Mappings. Plus let me collapse my
move forward and back. I'm going to name this
first one companion. Move horizontal. And I'm going to set
this to my L key. We're gonna do some keyboard
events will do L, the L key. And the scale for this is
gonna be 11 more time. I'm going to set the opposite
of this to be the J key. And that's going to have
a scale of negative one. Then I'm going to add another
axis of mapping here. This is going to be called
companion, move vertical. And we're going to
set this to have the icky with the
scale set to one. And the opposite of that of
that is going to be the K key and set the scale for
that to negative one. Now what we're gonna be
aiming to do here is to add a component to our
ThirdPersonCharacter. And using these Access Mappings, we're gonna be able to
move that object around. It's gonna be a simple sphere. So companion, move horizontal, companion, and move vertical. We've set that up in
our project settings in the input category, Let's jump back over to
our ThirdPersonCharacter. And the first thing we're
going to do before we even deal with those access events
that we've just created. We're going to add a components. So click under components, we're going to add a component. We're going to add a
simple sphere components. Now over in the Details panel, actually let's go
to the view port first so we can see that sphere, that is a giant,
enormous sphere. I'm going to firstly
set the scale down. I want to set a uniformly down. So let's go ahead and click this lock button so that if I
change one of these values, 2.5, it will change
all three of them. That's what that lock icon does. I'm also going to set
the location to be to 20 in the x-axis. Just too, set it out in front of our character
just a little bit. Now I'm also going to
create two variables to help us out with our script that we're gonna
be writing here. The first is going to be coming under variables plus it's going to be called companion
horizontal rates. And this is going to
be a float variable because it's going to be
a decimal point value. I'm going to
right-click on this. I'm going to duplicate
this and this is gonna be called companion. Vertical rates, mips
misspelled there a little bit. And if I compile, I can set some
default values here. So I'm going to set my
horizontal rates to be ten. And I'm also going to check
this box, for instance, editable that'll come into
play here a little bit later. And I'll do the same for my
companion Vertical rate. I'll set that to ten as well. Also check this box,
for instance, editable. And let's go ahead
and save that. Next, let's go ahead and
create some script over in our event graph using those axis events
that we just created. So moving over to the
left here a little bit, going to right-click
and some empty space, I'm going to type in
and move horizontal. And there's my axis event for
companion, move horizontal. Now, don't be confused between the axes values and
the axis events. We want companion move horizontal with a little
arrow icon right there. Boom. Now I'm going to right-click
and we're going to type in move vertical, vertical. That little right arrow icon
indicates in events as well. Alright, and what we wanna
do is we want to move our sphere here a
little bit every frame. So go ahead and drag and
drop this into our graph. Right here and down here. And I'm going to drag
out of our sphere and typing add relative location. So we want to update
the location of this sphere, every single frame. I'm going to plug
this in right away. The delta location
is how much we want to change our relative location. So to do this, I'm
going to drag out of our axes value and do a
search for a multiply node. I want to multiply this by
our different rates here. I really could have done
just one variable here and call that just companion rate. But just to play nice here, I'm going to plug in
our companion and horizontal rate
directly into there. And then I am going to
pull backwards off of this delta location and
type in make vector. We're looking for a
make vector node. Now again, this vector value is looking for an x, y, and z. We only want to change the
location for this axis events. In the y-axis, we're going to
be moving it horizontally. So the y-axis, the
y-axis, that green arrow. So that's gonna be that scripts. And we're going to do
similarly down here. I'm going to copy and paste
these three nodes right here, 123 highlighting
all three of them, control C, control V. Tidy
this up a little bit. The sphere is the thing that
we do onto move around. And we got to make sure we
get our axes value in here, in our companion, in this case, Vertical rate right here. Once again, we could
have just created one variable called
companion rate, since they're the same value. But I do want it to show off this instance editable feature here
in just a little bit. Alright, we're
gonna compile this. We are going to save this in. Now, if we look back in
our project settings, you can see that if we
move the L and the J key, we're going to move
this companion, if you will, horizontally. And if we press
the I or the KCI, we're going to move
it vertically. So jumping back into
our level editor here, I'm gonna go ahead
and click platelet. Actually, let's fire this off from our
ThirdPersonCharacter. I want to see the
script firing off. So click play here. You
can see once again, these are firing off nonstop. I should really unhook
that print string. In fact, let me do that now. I'm going to unhook
this print string from earlier because that's
just gonna be confusing. Alright, I'm clicking playing. Those events are firing off. You can see that little
sphere there in front of me. I'm going to do the input
axis, move horizontal. So J, K, L key, like so. Icky and KCI is also moving
it horizontally as well. And the reason for that is because I made this mistake of simply having both of them
changing the y location. I'm going to hold down Control, left-click and plug this into the z location and that
should fix up that issue. Now. J and L and I and k. Yes, you can put it
through the floor. Now one fun feature here is
that because we're doing some multiplication here
to ultimately determine the rate at which we are changing the location
of our sphere. I can go back to
my level editor. I'm going to change
my place settings, clicking on these
three dots right here to the selected viewport. Once I do that,
I'm going to play the game and my
select the viewport. My ThirdPersonCharacter,
which has spawned into the level here is now
showing up in my outliner. That's what that yellowish color indicates that it was
spawned into existence. And selecting this, I can
search for a companion. And I can see these two
variables that I have exposed to the editor here from my BP ThirdPersonCharacter
by checking that instance editable box
on each of these variables. Now what this allows
me to do is as I press the R or the J and L key, or the I and K
keys, That's great. But shifting F12 gain control, I can modify these values
down in the editor now, so I'll change the
horizontal rate to be quite slow and the vertical
rate to be quite fast. Then right-clicking back here, my viewport, J and L, it's updating slowly, but up and down is
going quite fast. So that's just a fun feature I thought I would throw
out there as well. Once I escape out of here, it is worth noting that those variable values switch
back to their defaults. That's just to play around with different values in the game. A few more good to know items before we wrap this video up, as with the input action mappings found in
the last video, you can select these events. And over in the right-hand
side in the Details panel, you can modify a few
things about them, including execute when pause, I fell to talk about this, consume input one that is also available on the input
action mappings with this, if it is set to true, then that input will only
work for the blueprint that has the highest default
priority that implements it. Alright? That can be found
again in your class defaults. Remember, under your input,
this input priority, so that consume
input only work for the one that's got the
highest default priority. Now, another thing to
note here with this, this fires off
every frame, right? So you might be wondering, well, if I modify in my
class defaults, the tick rate, will that
affect this as well? No, it will not. Affecting the tick rate will
only affect that event. Tick event, it will not affect the rate at
which this ticks off. This is gonna go
off every frame, whether you change this or not. All right guys, that is gonna
do it all for this video, we will see you in the next one.
29. Event Begin Overlap: Have you ever played a game and wondered how when
your character is walking down that dark hallway
in a horror themed game, a zombie jumps out at just
the right time to scare you. Or maybe you're playing
a game like Uncharted. And as Nathan Drake is shimming along the edge of a rocky cliff, the rocky cliff just
so happens to collapse as he passes a
precarious looking area. Now the way that's done
in games is through something called
trigger volumes. And more specifically, when you begin overlapping a
trigger volume are going. This video is to show how we
can use trigger volumes to initiate an actor
begin overlap event. Now, this is one of the most common events
triggered in all of gaming, and thus this is an essential
events to know about. Alright, we're gonna
get started here in the upper left of our editor, right here under the, uh, quickly add to the Project
button, if you will. We can find volumes,
trigger volume. You can place one this
way into your level. Alternatively, you
could come under the place actors panel, which will add a place actors
panel to your level editor. In here you can find different
tabs of different actors, including a Volumes tab. And in here, these are all
listed alphabetically. You can find a trigger volume. Let me go ahead and
place one of these. And alternatively under
the Basics tab right here, you can find different shapes of volumes to add a trigger
box or a trigger sphere. There is a few subtle
differences between the two, although what we're aiming to do with these is
going to be similar. It doesn't really
matter which add. I'm going to add
this Trigger box just to show off a couple of differences between this
and my trigger volume. Now if the Trigger box
selected in the Details panel, it's gonna give me access to a line thickness option
under the Shape category. So I'm going to set
that to ten right away. And then for the box extent I'm going to set that to
be something like, well, let's go 300 by 300 by 300, something nice and big. I want this to be placed somewhere in front
of my players. Start actor, but not too close, so I'm not overlapping
it right away. We'll go something like that. It's fine if it's penetrating through the
floor a little bit. Now, you can also set
a shape color here. So if you unselect it, it will show that
shape color of green. Otherwise, when
you select it, it, it's got that yellow highlight. Now, this is just a show off, a little bit of
difference between our Trigger box and
our trigger volume. If I've got my trigger
Volume selected, you can actually change
the shape of this. This does not have to
be cubic in shape. And to do that, you'd come
under your brush settings. And under your brush shape, you could change
that to be a cone. You could change that to be a staircase if you
wanted to, a cylinder. And then there's
different properties to change depending on
the brush shape. But for the purposes
of this video, I'm gonna get rid
of this and just roll with this Trigger box. Functionality will be the
same between those though. Alright, so we've got this
actress selected in our level. I'm going to do
some scripting here inside of our level blueprints. Let's go ahead and open that up. And I'm gonna put this in
my Event Graph, Graph. And in some empty space, I'm going to simply right-click. And when you right-click with an object selected
in your level, you can add an event
for that object. In this case, it's Trigger box five is what is being called. And under the collision section, I would do a wanna do an add
on actor, begin overlap. When something overlaps
this Trigger box. We can do something and we can find out who the
other actor was. This will output, it will let us know who the other actor was. Just to help visualize this, I'm going to drag off of my execution pin here and bring in a print
string function. And I'm going to plug this
other actor directly into this to get the display name of whatever is overlapping this, if I was to compile
this and play, run my character
through this and look in the upper left of
my play window here, when I overlap this
trigger volume, it will show me that it's a ThirdPersonCharacter
overlapping this. Now you can't see
this trigger volume currently in the level. Let's go ahead and fix that before we go any further here. So I'm gonna go back into my level editor here with
my trigger box selected. I've got this actor hidden
in Game checkbox checked, meaning this will
be hidden in game. If I uncheck this, then
go ahead and play. I can now see that trigger
volume in all its ugly glory. Alright, let's make
something happen when we overlap this
trigger volumes. So going back to my
level blueprint. I can get rid of this now, left-click and drag there so that I'll put
the other actor. Well, let's drag out
of this and let's do this casting to our
third-person character just to ensure that we only
want something to happen when our ThirdPersonCharacter
is overlapping it also, we're going to be directly impacting our ThirdPersonCharacter
here as well. So it's kind of a dual
purpose why we're doing this. So when the other actor is
the ThirdPersonCharacter, what do we wanna do? Well, we can reach into our ThirdPersonCharacter here in modify something about it. Including if I bring open my ThirdPersonCharacter
Blueprint. Including we can
modify some properties in this character
movement components. So let's do that. And we remember the Character
Movement Component can control things like how
fast or a character moves. That's that max walk speed
property right over here. So back here in my
Level Blueprint, I'm going to drag out of my as BP ThirdPersonCharacter and typing character, whoops,
character movements. We can find that at
the very bottom here, get the Character
Movement Component. And what do we want to modify inside of this
Character Movement Component? Well, I wanted to modify
this max walk speed. So I'm gonna go back to
my Level Blueprint here. We're going to drag out
of this and type in set max, walk, speed. Now you see this kind of thing done in games all the time. In fact, recently I got done playing Final Fantasy
seven remake. There are areas in that
game where Cloud strife is walking along and his
movement speed slows. So what's happening
there is cloud is overlapping a Trigger box and the character max speed
is being set to down to a walking pace to prevent me from running
through an area. Maybe I'm going
through a tight space or something like that. I'm going to set the
max walk speed down to 200 here when I'm overlapping
this Trigger box, Let's compile, make sure our script is looking
all good here. And then let's play. Now let me set my debug
option up here to my level test map so you can
see this event firing off. Move this on up. Alright? And you can see that I'm
running at a decent pace. But when I go an overlap
this trigger volume, I slow on down. Now you can see that when I
exited this trigger volume, I don't speed back up. And that's because this is an on actor begin overlap event. It's affecting my
characters setting my max walk speed when
I'm overlapping it, but I'm not telling
it to go back to any usual max walk speed
when I end that overlap. Now that's a very basic example, but let's take this a
few ridiculous steps further just to show you the range of things
you could do on an actor begin overlap. Well, one thing you could do is you could drag
off of this and you could play sound at location. What location? Well, we could say our
trigger box's location. Let's right-click and
some empty space. I've still got my trigger
box selected in the level. So let's create a reference
to a Trigger box. Drag off of this and say Get Location, get actor, location. Don't really need to do
this at a given location, but I'm going to play some
music at a given location. Sure. Right. That's something we could do. Something else we could do is we could dry off of
this and we could spawn actor from class. What do we want to spawn? Well, let's first of all, we need to tell us
where to spawn. So using our Trigger
box once again, I can drag off of this and
say yet actor transform. So what do we want to spawn
at that location rotation? Let's spawn in sure,
some smoke showing. Then we can also do something
like drag off this and type in spawn system at location. Now system is going to spawn
any Niagara particle system. So unreal had this thing
where they used to every particle system called cascade and that was
the older system. Some of the explosions and fire effects that you've
seen me use thus far. That's the older
particle system, but the rolling with the Niagara particle
system from Huron. So if you wanted to add a
Niagara particle system, you can go to the
Epic Games Store and in the marketplace
under Unreal Engine five, you could come under
visual effects. You could set the
max price to free. And you can look to add some of these Niagara particle
effects to your project. That's pretty simple. I'm not gonna do
that now because it's going to take a
little bit of time. But if you were to
select one of these, you could add to the project. Select which projects
we wanted to add it to. What the heck? I am going to add this probably after this video at the project. And that's how you
would do that. As soon as you click
on this button, back here in your level editor, you would see the
appropriate folders show up that would have those
particle effects inside. And that would then allow you to slot in an appropriate system. Of course, you
would need to tell this where you want to spawn it. Alright, so just to
demonstrate this, let's go ahead and click
play one more time. And when we overlap this, slowing down,
playing some music, and our blueprints effect is
emitting some smoke right? Smack dab in the center. Archery. Lastly, it is important
to realize that these begin overlap
events are not just restricted to
these trigger volumes that you find here in
your place actors panel. On the contrary, I would
venture to say that most of the begin overlap events
that I use in scripting are found inside of blueprint
classes themselves. Now, to demonstrate this, let's go back inside of
our bp example pickup. Double-click on
that to open it up. And if you remember from the
beginning of the course, we were using a sphere collider, a trigger volume
to check to see if our third-person character was overlapping that in
order to collect it. Now if I come under
this components panel right here and click Add, if I scroll on down, there are different types of trigger volumes are under
the collision category, but there's box collision, capsule shape collision,
and sphere collision. Now with any of these
added to a blueprint, if you select it over
on the right-hand side, you can see that you've got a begin overlap event
associated with it. This is at the very bottom. Alternatively, if I
was to right-click on this and come
under Add events, that same event is
available here as well. Just as a reminder
here, my event graph. Here's where I'm using an odd
component, begin overlap. This is a trigger
volume of sorts. It's just an odd component. It's a component trigger volume currently in a spherical shape. And it always list the name of the component
here in parentheses, just like in the
Level Blueprint, it lists the name of the trigger volume in
parentheses as well. This is just an actor begin
overlap in my BP example, it's on component begin overlap. They are both overlap events in which you can fire
off some script. Well guys, that's gonna
do it all for this one. In the next video, we will talk about the end overlap events. Will see you there.
30. Event End Overlap: Welcome back everyone.
In this video, our goal is to show how
trigger volumes can also be used to fire off
and overlap events. Now sometimes you
want something to happen to when you
begin to enter an area and sometimes
you want things to happen when you exit an area. The end overlap event
is for those times you want something to happen
when you exit an area. Now we left off last video where when I entered this volume, this trigger volume right here, it would slow my character down. Now I did a few more
ridiculous things like play some music and spawn a particle effect,
that sort of thing. But I am not actually speeding my character back up once
I exited that volume. So in here, we're going to
explore how to do just that. Now before we even get to that, I'm going to jump back into my Level Blueprint right here. And I did finish off adding a Niagara particle system
at the very end here. And I just wanted to point
out in the last video, I directed you to
the Epic Game Store. And while we're in here, I went to the
marketplace and we were seeking out some visual effects. You E5, I went under a UE five visual effects
and I think I was pointing out under
the free packs. This one right here, this
is the old cascade system. If you want some
Niagara effects, go with one that says
Niagara right here. Now I did include
this between videos. And so thusly when
I play it now, you will see I've got a queen at shower that is going to be
spawning in there as well. Just wanted to point that out
to complete that last bit. Alright, let's get on
with the end overlap. So you can see on
the begin overlap where slowing our
character down. Well, let's speed them back up. Now, just like we showed
off in the last video, if we want to add this event
to our Level Blueprint, you need to make
sure that you've got that actor selected
in your level. So let's go ahead and
make sure that we've got trigger volumes selected. You can select it here or
over in your Outliner. Either way we will do. And back in your
Level Blueprint. That's how you can get back
into the love blueprint. Go ahead and right-click
and some empty space, we can add an event for this which is known as
Trigger box five for me, don't be alarmed if it says
something else for you. Trigger box 27 or whatever. Really depends on how
many trigger boxes you've added thus far. Here we want to
do in an overlap. Alright? We're also going to do a casting to our
ThirdPersonCharacter. We want to find out
if the thing that ended the overlap Cast to ThirdPersonCharacter was
the third person character. Now, if it was the
ThirdPersonCharacter that ended overlapping,
that trigger volume, we want to grab in, get our Character
Movement Component out of that
ThirdPersonCharacter. And then we can drag
out of this and type in set max, walk, speed. And again, I know that
this property exists because inside of the
character movement component, inside of my
third-person character, there is a max walk
speed parameter. So it was 500 before. Let me just jump back into
my third person blueprint just to show this off driving home Character
Movement Component, the max walk speed is
currently set to 500. So over here in my
Level Blueprint, I'm going to set that max
walk speed back to 500. So when we end overlapping that trigger volume, we should, we should get back up
to our normal speed. And I just want to show that these events are going
to fire off here. So let me set my debug
option right there. Bring my character back on. Alright. You can see he was
running at 500. Inside of the trigger volume. When I exit and overlap
back up to 500, you could see right down here these events
firing up. Alright. So consider the other possible
uses for an end overlap. We could make it so that
when we and overlapping we could stop playing some
music that we spawn, that we can't stop this music because this is a
fire and forget. But if you spun into music, we could save that
out to a variable and then stop playing their music. Perhaps you could
use an end overlap to stop hurting the player. Maybe player was in a poison gas zone that was affecting their health as
soon as they overlapped it. But when they ended
overlapping that they're no longer
losing health anymore. Or perhaps it could
be something like you see in Uncharted or
Final Fantasy seven, that when you begin
overlapping of volume, you cannot draw a weapon, but when you end
overlapping that volume, you can draw that weapon. That can be done through
Boolean variables set inside of your
ThirdPersonCharacter. Well guys, that's gonna
do it all for this video, we will see you in the next one.
31. Event Begin Cursor Over: Welcome back everyone. In this video we're
going to create a couple of blueprints
and also change a project setting just
so we can show off how cool mouseover events are. Now these are great events to know about if
you want to make something happen when
mousing over an object, such as an item of
changing color, like some kind of a
highlight effect, or making an item
description appear maybe the name of the object that you're
a cursory hang over. Or maybe some texts
that says press X to interact or pick up this
object, that kind of thing. Now this is going to be
predominantly a PC type of event, but it's good to know
about regardless of what platform that
you're developing on. Just to see all that can
be done here in Unreal. Alright, to show this off,
we're going to create an accurate class blueprint. And you can put this in
any folder you want. But I'm going to come under
my scripting overview folder, and I'm going to right-click
in some empty space, come under Blueprint class. After class is the one we're looking for and
I'm going to name this BP underscore mouse events. Then we're going to double-click on this guy to open it up. We see our default
scene root right here. We are going to add
a single component. So come under the Components
panel, click Add. We're going to add a
sphere components. Great, and let's go ahead and drop this right into our level. Probably good idea to place
it right in front of where your character is going to be spawning in that
players start actor. So we can see this right away and then jump
back into your p.sit mouse events and head
on over to the Event Graph. Now, we want to make
something happen when we mouse over
our sphere here. So what events do we
have available for this? Well, with our sphere
components selected over in the Details panel
at the very bottom, you can find all of the
events associated and available to you for this
particular component, including On begin cursor over. So if I click this plus button, I can add this event to our graph and it'll
jump me right to it. Now, you can also add this
events if you were to, right-click on that component. And then the little
fly-out menu add event, you would find it in this list. The reason it's not this list is because it's already
added to our graph. But if it was not
added to our graph, we can find it here as well. Alright, so what we
want to have happen is when we move our mouse
cursor over the sphere, we're going to
change our material. So let's grab a
reference to our sphere. Left-click and drag
this into the graph. And we're going to drag out of our sphere in order
to talk to it, to change something about it. I'm going to type
in set material. And once again, I knew that
this is a property I could change about this component because if I select my sphere, one of the available
details is the material. So that's a good hint if
you're ever wondering, hey, what can I change about a given component while
simply select that component. And in the details,
look at all of the different things that could possibly be changed about it. Now I'm going to set
my material here to be something quite obnoxious. Going to type in vertex green, That's what
I'm looking for. And the reason I'm not
finding it is because if I click this little gear icon, I want to search not
only my normal content but my engine content as well. And is vertex green not in here? Let me just type in
green there it is. Vertex color view mode, green only, that's the
one I'm looking for. So if I compile this, I can see that my scripts
here is good to go. I'll save it as well. You might think, okay, if I
jump into the game and I put my mouse cursor over this
fear that this will work. Well. It's actually not
going to work yet. We need to do some
work inside of a player controller
blueprints to actually enable these
mouse over events. Now, player
controller blueprints is something we're
going to talk a lot more about when we talk
about framework blueprints. But in order to do this
particular video justice, I have to wade
into these waters. For the purposes of this video, all you need to know about the player controller blueprint is that the player
controller works in tandem with a character or Pawn Class Blueprint to affect your
playing experience. The player controller is
essentially the puppet strings. The character is the Puppet. You are the marionette. Overly simplified
analogy, I know, but the player
controller blueprint has some mouse settings
inside of it that we need to set in order to make this begin cursor over
event actually happen. Let's go ahead and create this player controller
blueprints. So back here in
our level editor, I'm going to create
a whole new folder to house this player
controller blueprints. So I'm going to right-click
on my scripting folder. We're going to
create a new folder. And I'm going to
call this framework because we're going to be adding some frame work type Blueprints later on in the
course framework. Blueprints are some high
level blueprints to determine things about
your entire project. And inside of here I'm going to right-click Blueprint class. And one of the most common ones is a player
controller blueprint. It controls a pawn used by the player. That's
the description there. And let's go ahead
and create this. I'm going to call this BP
underscore player controller. We're going to double-click
on this guy to open it up. Not much here,
however, in the class, the class defaults button
with that selected over in the Details panel come under this mouse interface section. This is the really
important part. One thing you want to
make sure that you do is show a mouse cursor
by ticking this box, we're going to ensure
that our mouse cursor that I'm waving
around right now is going to be present
on the screen. And the other biggie that
you need to set here is enable mouse over events. That is critical for this
cursor over events to happen. Make sure that you
compile and save us. We can go ahead and
close out of here, but we're not done yet. We've created this player
controller blueprint, but we have not told our project to use this player
controller blueprint. So exiting out of here, go back to your
main level editor. You can come under
Settings, project settings, and in the maps
and modes section, we've got this player
controller class. We want to set this to our customer bp player
controller that we just created. In doing so, we're telling
our project here that we've created to use this
player controller class. And that player
controller class. Remember, has those
mouseover events enabled? Great. Now we can jump back into our level. Let's
go ahead and play. And you can see my
cursor is present on the screen and it turned green
almost immediately here. Let me go ahead and play. Okay, it's not green. I must have weighed my
mouse over it immediately. So let me just right-click
and some space here. That sphere is that
whitish color and as soon as I mouse over
it, boom, turns green. Now, jumping back into our
bp mouse events blueprint, you can see how I could extend this functionality
to play a 2D sound, a confirmation sound of sorts when I begin mousing
over the sphere. But I'm not doing anything when I ended that overlapping
of the sphere. We'll deal with that
events in the next video. Alright, I want to show
off one more example here before we finish
up this video, we're going to do this
next example inside of our bp, a ThirdPersonCharacter
Blueprint. So I'll hop on over there again. You can find that in
third-person blueprints. Inside of our
ThirdPersonCharacter. We're going to set the material for our character when we
begin mousing over it. Now the reason I'm gonna
be showing this is to show off a parameter
that you're going to need to have set
in here in order to make these cursor
over events to work. So what I wanna do is when I am a mousing over
this capsule component, that is this invisible capsule encapsulating our character. Wants something to happen. We're going to change the mesh, that is the material,
if you will, the color, the mesh of the color of our, of our mannequin here. Let's go over to
the Event Graph. And with this Capsule Component selected, I'm going
to right-click. We're going to add events on, begin at cursor over. It's going to add this
event to my Event Graph. Then I'm going to
drag in my mesh that is this whole mannequin, if you will, drag this in. And then I'm going to
drag off this and type in a sets material. And I'm going to make it so
that our material changes to, I'm going to change
it to green as well, that obnoxious color. Very nice. Now, I'm going to go ahead and compile this, save and play. And so now you can see when
I mouse over my sphere, yes, that changes green. You'd expect the
same when I mouse over my mannequin here as well, but doesn't seem to be
working what's going on here? Well, if you're looking to
do something like this, what we need to do is come back into our
capsule components. And in the collision settings, we want to expand out our
Collision Presets here. Collision Presets right there, it's currently set to pawn. We're gonna change
this to custom. And we're going to allow our Visibility channel
here to be blocked. Essentially these mouse
over events check to see if the visibility is being blocked and if
it is being blocked, this is going to fire off right
now we are ignoring this. That's how we're
detecting if this mouse over event is even
happening, happening. It's doing a visibility
traced into the world. Right now. It's just ignoring that
if we set this to block, it will recognize that yes, that trace has hit something, in this case the
Capsule Component. Let's go ahead and
change that material. Alright, let's compile
this and save once again, clicking play here at sphere turns green
and now look at that. My mesh turns green as well. Why not the whole thing? Well, the reason the
whole thing is not turning green is
because if we select our mesh here in the Components panel and
come under Materials, I'm only changing out
this element is 0. I'm not changing out
the element one, which is determining the color of other parts of our mannequin. So if I was to change this
to element index one, it would be changing those parts as opposed to those parts. Good to know. What are some possible uses
for this type of event? Well, once again, you
can show button prompt, interact, destroy,
pickup interact. You can have some kind of
an item highlight effect. It could be a sound, it could be a particle
that could be a material change
like we've done here. Well guys, that is gonna
do it all for this one. We will see you in the next one.
32. Event End Cursor Over: Our goal in this video is to
continue our exploration of mouse cursor events
by firing off and event when we end
mousing over an object. This is extremely useful for
making an object returned to its normal state whenever
we're done checking it out, just as we did in the last video where we moused
over this sphere, it turned green, but when we
don't mouseover it anymore, We end that mousing over. It doesn't return back to its normal state, same
with our character. So let's add some
end cursor over events to set those things
back to their normal state. Sir, in my ThirdPersonCharacter
Blueprint. And from the last video here, all we're doing is
when we're mousing over our capsule
component right here, we're making it so that are the material on our
mesh turns green, at least element 0
NOT element one. Let's go ahead and
set that back. Now the way we can set
that back is simply to right-click on our
capsule component here. At event we have this
end cursor over. Let's add this to our graph. And I can simply copy this
node right here, control C, control V. We can use the same mesh reference here
to set that as our target. And we're affecting
element is 0 right here. We're going to affect
element 0 down here. However, we need to change the material back
to what it was. And what was that material
once again, well, it was as MI Quinn. And we can jump to
this by clicking right here browsing to that
in the Content Browser. It says MI Queen. It's located in this series
of folders with that material instance
assets selected back here in our
ThirdPersonCharacter. And make sure you've
got this selected. We can simply click
this arrow right here to slot it in under
the material. Let's compile. That script is looking all good. Save it as well. Click Play. And now when I mouse over, our character, turns green, at least in those
areas were elements 0 is affecting our mesh here. And when I mouse off
of this, sets it back. Cool. Let's do that with our bp
mouse events sphere as well. Jumping to our event graph here, we're doing something
when we begin cursory over this sphere. So let's select our sphere. Let's right-click here
and some empty space at events for ending cursor over. And I'll do the same here. Control C to copy, control V to paste. We can use that same
sphere reference, or you could add a
new sphere reference, just showing off multiple
ways you could do something. Both are targeting the
same element index. This one only has one element index for
the material elements 0. And it is using this
basic shapes material. I can search for it here, or I could do like I
did before this time, let's simply search for it by clicking on this
drop-down arrow. Type in basic shapes,
basic shape material. And let's try this, compile, save and play. And I'm also over the
sphere turns green. In fact, let's show off this
script firing over here. It turns green, turns white, turns green turns white, and you can see those
events firing off as well. Pretty straightforward stuff. Use it in tandem with that
begin cursor over event. And once again, in
order to make any of these cursor over
events even happen, or those end cursor over events. You have to set
those settings in your player
controller blueprints to accept those
mouseover events, guys, I'll do it
all for this one. We will see you in the next one.
33. Event On Clicked: Welcome back everyone. Well, over the last two videos, we showed how to setup a player controller blueprint to detect when we're
mousing over something. And then the opposite of that, which is ending mousing
over something. We're gonna be taking
that a step further in the next two videos here to detect when we have
clicked on something, as well as when we have
a release that click. Let's get started here inside
of our bp mouse events. And what we wanna do
is we want to detect when we have clicked
on this sphere. So in order to do that, we can right-click on our
sphere component here. And in our Add Event
little fly-out menu here, I can add an on-click event. That's one way to do it. Or alternatively with
that components selected. Down at the very bottom
of the Details panel is our list of available
events for that component. I'm going to click here this plus button for
the onClick event. That's going to jump us
over to the Event Graph and add that event to our graph. So we're going to set up
a very basic script here. What I wanna do is I want to talk to our
sphere components so I can drag this in or
drag this in down here. Either will do, I'm
going to get it. And I want to set the world scale of this
object when I click on it. However, I don't
want to set this to a hard and fast number. I want to do a little bit
of a very basic math. So what I'm gonna do
is drag out of this. I'm going to get its
current world scale here by typing and just
get world scale. That'll give me its
current world scale, which if I select
my sphere here, The world scale of
this is currently 111. And I want to make it so that
every time I click on this, I'm simply going to add
a little bit to it. So dragging out of the
return value here, use that plus button
to add an add node. And we're simply going
to add 0.1 in the x, y, and z dimensions, making this ever so slightly bigger every
time you click on it. So the first time
you click on it, we're going to be
targeting our sphere. We're gonna be setting
our world scale. It's gonna go from one
to 1.1 across the board, then clicking on it again, it'll set it to 1.2,
et cetera, et cetera. Let's compile the
script and save it. And this all looks
well in good however, you'll see that once I
click Play up here and I am debugging this mouse
events object here. I can go ahead and highlight
it and it turns green. However, when I'm
clicking on it, nothing seems to happen. Now the reason nothing is happening here is because
I need to dig back into my player controller and check a box that
enables click events. So if you forgot what your player controller
blueprint was, we had it in our
framework folder. Double-click on
that to open it up. And inside of here with
a class defaults button selected come under the
mouse interface section. And just as before where we
enabled a mouseover events, we need to enable click events. Now once we do this, note this right down here, the click events keys. So we're checking this on. Yes, we can recognize
click events. And down below, we can set what registers as a click event. By default, it's going to
set the left mouse button, but you could click here. You could click there multiple times to add different keys. So I'm going to
delete this because I only want the left mouse button. So that will work. It will enable
left mouse button. It will register, that
is a click event. This is also worth noting here
that down below we've got a default click Trace
channel and it's set along the
Visibility channel. Let's go back to our
bp mouse events. And if I select my sphere here and look over in
the Details panel, come under the
collision section. You can see that if I come
under Collision Presets, which is set to block all dynamic for this
particular component. Down below, my trace channel, for the Visibility channel named or the trace channel named visibility
is set to block. This is important because so long as this is set to block, it can recognize a click event. Also going back to my
bp player controller, it shows that the trace
distance for this is 100 thousand unreal units. So the way it works is if I click here in my world, like so, that object is less than a
100 thousand unreal units from the place that I am
clicking on the screen. So it will register
that as a click event. If it's further than that, it will not register it. So let's give this a play here. I'm gonna go back
to BP mouse events so we can see this firing off, clicking play and
tucking this down here. So it's recognize
them mouseover. As soon as I click on, it
gets a little bit bigger. Clicking again, a
little bit bigger, a little bit bigger, a little bit bigger, a little bit bigger. So there you have it. To enable this onclick event to work inside of your
bp player controller, you need to have
enabled click events. And then also said at
least one click event key. Guys, that'll do it
all for this one. We'll see you in the next one.
34. Event On Released: Welcome back everyone. Well, this is the companion
to the previous video. We made it in the last
video that once we clicked on our bp mouse events
blueprint here, the sphere, we're making
it incrementally bigger. We're going to
change up our script a little bit and
we're going to make something happen when we
release our mouse-click. So we make something
happen when we click the left
mouse button down. But when we lift up on that, we want something
else to happen. Let's go back into
our bp mouse events. Currently I've got it so that as soon as I click
on the sphere, it gets a little bit bigger. I'm going to delete out these two nodes and
I'm going to simplify this script here a little bit. I'm going to hit Control C and Control V to duplicate this. And what I wanna do is
also target the sphere. However, I want to add
an unreleased events, so I'm going to right-click
on my sphere at event. And on release, this will
fire off once again. Once I lift up my left
mouse button click here. We're gonna make it so that
when we click on our sphere, we're going to set
the size to be two across the board,
double the size. And when we release it, it's going to set to be
one across the board. And I'll move this to
the upper left here, and we will compile that. Make sure the script looks good. Let's go ahead and play this. And you can see that once
I click on, it gets big. Once I release, it goes
back to its normal size. Big, small, click, Release. Pretty straightforward stuff. The one other thing
I'll throw in here is in your bp player controller. So long as under the class defaults you've
got enabled click events, as long as that's checked on and you've got a
click event key of some sort that all enable
the onclick event to work, as well as the release
event to work. So kind of a two-for-one there. Alright guys, that is going
to do it all for this one. See you in the next one.
35. Event Hit: Welcome back everyone. Event hit is the
topic of this video and this is a super important
events to know about because collision
between actors is happening in all kinds
of games all the time. Imagine in a shooting game, you shoot a bullet, hits a wall. You see a little bit of
dust fly up and you see a bullet D cal left at
that point of impact. Or imagine you're
planning a racing game. You bang into another car and
you see some sparks fly up. That is an event hint going off behind the scenes and
making those sparks fly up. That bullet decals appeared
that point in the wall. Alright, let's explore how
this event can be used. Now, I am going to be using this cube actor
place in my level, it is named cube. It is a static mesh actor. You can place any
static mesh actor into your level to check out what
we're about to check out. But if you want to play along
at home, I went right here, came under shapes and I
got my cube right there. With that selected,
I'm going to jump over to my Level Blueprint. And in some empty space, I'm going to
right-click and we're going to add an event
for that actor. We've got selected come
under the collision section. And here we've got
add on actor hit. Just like our overlap events. It can tell us who was the other actor that
in this case hit us. We're gonna check to
see, in this case, if it is the player
character that hit us. So let's right-click
and some empty space type in, get player character. We're going to see
if the other actor is equal to the
player character. That is, are they
the same thing? Is it the player
character that hit us? This is one way of
doing this checking to see is the player character, the other actor that hit us. If they're equal, then we're
going to drag out of here, bring in a branch node. And if it indeed is true that the player character was the other actor that hit us. If that's true, we're going to drag off of here
and type in plays sound to D. That is a
non localize sound, and I'll do my good
old explosion. Q, because that
is very distinct. That's something happened. Also, what I will do is I'm
going to destroy that mesh. So I'm going to right-click
and some space here. We're going to create a
reference to our queue here. Drag off of it and
type in Destroy Actor. Alright, let's go
ahead and compile this to make sure that our
script is looking good. Green check mark says yes it is. And then I'm going to go
ahead and click play here. And so you can see the
script firing above. Let's run our player
into that cube. Here we go. Bam. Now at this point, it's worth slowing down just a little bit to explain how this
collision was even detected. How did this even work? Why didn't my character just pass right
through that cube? Well, for starters, let's check in our third-person
character blueprint. I've got that open up here. And I've got the capsule
component selected. All the other components
are attached to that. That is the invisible component surrounding my character here. And if I look over in the Details panel under
the collision section, I've currently got my Collision
Presets set to Custom. And you can see
how the collision here is setup to
block everything, all different types of objects. Now, what type of
objects are there? Well, this particular
third-person character is a pawn object type that is
listed under the object type. And this pond is set up to
block world static objects, world dynamic objects, other ponds and all these
other things right here. Now let's compare this with
what we see on our cube. Now I've got my cube
selected here in the level itself that
is a cube instance. This cube instance is comprised of a static mesh components, and that's Static
Mesh Component. If you select that,
that is where the actual tube
mesh is slotted in. Scroll on down here and look
at the collision settings. Are collision preset here is
currently set to default, so I can't really drill down and see all those other settings. However, if I was to change this to custom just momentarily, it will expose the current setup of the collision for this cube. You can see that the
object type listed for this cube is a world
static object type. Now, this is set
to block a pawn, as is our
ThirdPersonCharacter are pawn is set up to block a world
static object as well. Long story short, they're meant to collide
with one another. One thing is not going
to pass through another. Now, if I was to
change my cube here. To ignore collisions
with a pawn. Remember my
ThirdPersonCharacter is set up as a pawn object type. Let's momentarily set
this to ignore ponds. Watch what happens now. Try to run my pawn, my character through that
and nothing happens. It does get a little wonky
thing with the camera. But long story short, that on actor hit
event never occurs. Let me go ahead and change
that back here to block. And it'll change the collision, present it back to default. Alright, now let's dive a little deeper here because there is some nuance you should know about wood working
with this event. We're going to right-click
in some empty space here I'm in my contents
scripting overview folder. And I want to create an
accurate class blueprint actor, BP underscore events. Hit is what I will call this. And I'm going to double-click
on this to open it up. And I'm going to add
three components here. I will add a cube. Going to zoom on back here. I'm going to add a sphere, going to move that
off to the right a little bit here as well. And I will add
scrolling on down. We'll add Sure, a cylinder. Alright, now it doesn't really matter what actors you have. You have attached to other ones. If they're attached or not. That doesn't really matter for the purposes of this video, what I do want to get to though, is the Event Graph
going to delete out these events and then
some empty space gonna show how you
can add event hit. The first way, Right-click
type in event hit. That'll get you event hit. Alternatively. Another way you can
check out what events are available within a
given a blueprint is over in the My Blueprint panel under the functions section. If you come under the override, dropped down right over
here, select this. It's got a whole list
of events available to you for this a blueprint
actor, including event hit. Now that's all a
little misleading, at least I found it
confusing when I first got into
blueprints scripting, because under the
functions area, you can find different events, I guess with their meaning
here is anything that you add beyond these various events. That is the functionality
essentially that you're adding for when you hit
something in this blueprint. Alright? So what I want to
show off here is drag off type in print string. And we want to find the
other thing that hit us. So I'm going to drag
out of here and typing get display name. The reason I'm doing any
of this is to show that this particular
event hits will fire off if we hit any
components that we added, it doesn't matter which one. So let's go ahead and play here. I'll set my debug objects too. Well, firstly, I've
got to add this to my level donor. That
would be helpful. Going to add this to my level, drag and drop it in here
and rotate it around a little bit. There we go. Go ahead and play. Our debug object is sets. And now when I hit any of these components
that will fire off, that will fire off. And then I'll fire off. It didn't matter which
component I hit that event hit did fire off and you
can see it in fires it off multiple times. Which is something to be aware
of because in many cases you don't want it to fire off
multiple times like that. To remedy that you could add a due once node in-between here so that
the first time you hit it, it only does it one time. But to get to our next
point here is you can add an event hit when you
hit a specific component. I'm going to select
my cube here. And if I right-click, I can add an event, add
on component heads. So this on hit is specific
to hitting just this cube. Let me drag off of here and
just type in print string. And I'm just simply
going to put it in the word queue when
we hit that Q. So framing up my
script like this, I'll click play one more time. Now you can see that
when I hit this cube, both of those events
are firing off. However, if I hit
adjust the sphere, just that top event
hit will fire off. Not that odd
components hit because that on component hit is
specific to that cube. Now, one very important bit of nuance to understand about event hit is what happens if you have physics objects
in your level. And by that, I'm talking about an object that can be kicked around or respect to gravity
dropdown, et cetera. Let me go ahead and click play here and show
you what I mean. You see that chair falling
on down to the ground, that is a physics object. Now these are really
simple to set up. If you have a chair, some other static
mesh in your level, any static mesh will do. Here's where I found
that chair in my starter content over in
the Details panel. If I select my chair instance, come under the static
mesh component, but come on into the
physics section. I've set this to
simulate physics. Now there's a whole bunch of
properties that you can set up If an object
simulates physics. But as soon as you
check this box, this is considered
a physics object. If I go into my BP event hit, you saw that chair hit this
actor class blueprint. Note that when I click Play, none of these events
are firing off. Kit events will always fire if it's character movement
that's triggering the hit, these hit events will not fire if a physics
object hits it. Unless the actor or
wanting to detect a hit has a particular
checkbox checked. So let's go ahead and do that. I'm going to come
under my components, my cube component inside
of BP event hip and over in the Details panel
under the collision section, what I'm looking for is
Simulation generates hit events. If I check this box
and then I click Play. You can see now that both
of those events triggered. Now what happens if I
drag this chair above, say the cylinder and
then it looks above the cylinder. And
then click play. Those events do not fire off. And that's because I
would have to select my cylinder and do
the same thing here. I would need to
check this box for simulation, generates
hit events. So very important bit of
nuance to understand their, their nose guys event hit. One of the most popular events use in all our
blueprint scripting. That'll do to offer this one. See you in the next one.
36. Event Any Damage: Hello, hello. Our goal in this video
is to begin exploring some of the damage events
available in unreal. Now, damage is obviously
a big part of many games, and it's good to
know that unreal already has existing
functions and events within
blueprints scripting to help implement
these concepts. We're going to explore
event any damaged first and then branch
out from there. Alright, the
ThirdPersonCharacter is going to be the
star of this video. So find your way on over to this directory in the Content
Browser or content drawer. Double-click on
it to open it up. We're going to start off
by adding a variable. We're going to add
a health variable. So come under variables plus. And we're going to
add a new variable simply called health. We will leave it
of the float type. It could be an integer because
health can sometimes be represented in whole numbers as opposed to decimal numbers. But we'll go with a
float type there. We'll compile it and then give
it a default value of 100. That's a nice round value. Now, while unreal does
have some damage related concepts and events related
to damage embedded in it. It does not have any
concept of health. At least as of today's
recording imbedded into unreal. You have to create a health variable inside of
your character blueprint, and then you can deal
with it from there using the various damage events. Alright, with that
created, Let's add an event, any damage. Couple of ways to do this. You can right-click
type in any damage. You can find it there. Alternatively, you can find it in the
functions section of the My Blueprint
panel in the override drop-down there is
events, any damage. Alright, with this events added, we want to modify our health
variable in some way. So this is how this works. Let's go ahead and drag our health variable into the graph. We're going to get it. When this event fires off, it can output how
much damage was done. Now we wanna do here is
take our health variable. We're going to drag out a here, type in the minus symbol
we want to subtract. So we're going to take our character's health
and we're going to subtract our health
by the amount of damage that was done. Then once that
calculation is done, we're going to update
our health variable. The way we can do this is
drag and drop this right onto the output
pin and set that. So we're taking our health, subtracting the damage
amount from it, and then setting that is
our new health value. Pretty simple and
straightforward. Then what we're gonna do is
drag off of this and bring in a less than or equal to sign. We're going to say if this
is less than or equal to 0, then we're going to branch. If it's true that were
less than or equal to 0, our health is dropped
to 0 or below, then we are going to
destroy the actor. In this case, the
target is us self. We're going to destroy
this entire thing. Now before I link this up, I'm simply going to sneak in
a print string node here. So we can see our health
value dragged out of here. We'll type in print string. And we'll go like this. And if we plug our health
into this in string, it's going to convert this
float value into a string. So that's what this
is doing right here. It's converting a
float to a string. And let's compile
this, make sure that this script is good to go
and it looks like it is. Now, note that this event won't do anything yet
because we haven't told this actor to be impacted by the concept of
damaged in any way. We're gonna do that next year back here in our level editor. And let's go ahead and
add a trigger volume. I'm gonna do that
by coming under here, place actors panel. I'm going to add
a trigger box and place it somewhere in
front of my players. Start actor. With that selected. I'm going to set the line
thickness to be a little bit thicker so I can see
it in the level. I'm also going to make
the box extent be 200 by 200 by 200. And I'm also going to scroll on down and uncheck actor hidden
game so that we can see it. Alright, with that all done, Let's jump on over to our Level. Blueprint. I'm going to right-click
and some empty space. We're going to add an event On collision on begin overlap. We're going to check to see if the other actor that overlapped us was the third
person character, not the game mode. The character. If it is, what we're
gonna do here, is dragged out of
here and type in apply damage, a-ha,
applied damage. Now, this base damage right here is going
to allow us to input how much damage we
would like to have done to our
ThirdPersonCharacter. So works like this. You decide how much damage
you'd like to call it. Let's punch in a number of say, 25.5, something
ridiculous like that. It's set here and then
here when this event, any damages called, it
will output that here. So you're passing
that damage along. Alright, with this all done, let's go ahead and
click play here. And I want to be my
ThirdPersonCharacter Blueprint. So we can see this
script fire off or not if we screwed everything up, Let's go ahead
and click Play. And we should see are
damaged value updated right up here in the
upper left because we're printing this
to the screen. Let's overlap this. And I am not seeing it. And the reason I'm not seeing
it is because I forgot a step back here in
my Level Blueprint, I forgot to have this damage actor be set as
the third-person character. So if we do this,
we're saying, Hey, ThirdPersonCharacter, this
whole applied damage function, fire this off and make
sure that in doing so, you are making this event
any damage fire off. So I'm calling this
function if you set the damage actor in this case
to be ThirdPersonCharacter, it will cause this event
any damage to fire off. Let's try this once again. So you should see that
damage value update here as soon as that overlap
this trigger volume. And there you go,
he saw fire off. If I do it again, you will
update the health again until eventually I go beyond that threshold and
boom, I am dead. Now, just a couple of notes here back in my Level Blueprint. This damage type class. There is the ability
to add fire damage, lightning damage, water damage,
all that kind of stuff. In Unreal. It does not need to be set
and it's beyond the scope of this video how to
set that kind of stuff. This server icon, that node indicates that this function only executed on the server
for single-player games, the local client is considered the server thought
I'd throw in those notes. Something else
worth pointing out here is that if I go back to my ThirdPersonCharacter
Blueprint and instead of subtracting
here, I did. Dragged out of this
and type in ad. You don't actually have to treat this as a negative thing. You could actually use
this whole concept of damage as a healing means. So instead of subtracting, you could do something like
this and add that amount. So if you wanted to have
a healing pond of sorts, you could do that too. One final note about
event any damage is it's meant to be used for
general purpose damage, like damage incurred
by your environment, safe from fire or poison,
that kind of thing. Alright guys, that's gonna
do to offer this one. See you in the next one.
37. Event Point Damage: Welcome back everyone. Well, we're on to the second
of our three damage events. In the last one we talked
about event any damage. That What's your general
purpose damage event to use for things like
environmental damage. And this one we're
going to be talking about event point damage. Now point damage is
damaged meant to be dealt by projectile weapons, hit Scan weapons,
even melee weaponry. And I'll even add
a fourth one here. We're going to be
dropping a physics box on our players heads so
it can be used for something like this as well. Now while functions similar
to prevent any damage, it does have some added info
that can be passed along, which makes it ideal for a projectile style
damage applications. Now, in the interest of time, I've set up a bunch of stuff prior to shooting this video, but I'll show you exactly what I did so you can play along at home if you're wanting to
follow along with this example. Firstly, you place
a static mesh actor into your level and place it right above
where your players spawns in that
Player Start actor. I'm simply using a cubed
Static Mesh actor, but anything will do
and you can grab a cube by coming under
here, shapes cube. And then with this cube
selected in the Details panel, I selected my Static
Mesh Component. And there's two checkboxes
I was sure to check. One is simulate
physics to ensure that this box is going to fall on
top of my character's head. And also down in the
collision section, I made sure to simulate
generate hit events. Setting that to true as well, because I do want this
to generate a hit event. Now with this selected over
in my Level Blueprint, you can find that
by coming under here, open Level Blueprints. I then right-click with that cube selected
into the level, right-click and add
an event for that. And I added an actor
hit and it shows that that is the
name of my cube. Now what I'm wanting to do
is once I hit something, I want to call this function
apply point damaged. Now you saw me apply any
damage in the last video. So something similar here. This was the apply any damage
from the previous video. We're doing something
similar here. We're going to apply
a point damage. And just like before
we need to feed this a damaged actor, before it was a
third-person character. Here we're going to go a little
bit of a different route. We're going to drag
out of our hit result from our hits when our
cube hit something. And all you need to do is
drag out here and type in break and then breaking
that hit result, you can extract all kinds
of information about the hit that occurred between that cube
and whatever it hit. One of those things that you can extract is the hit actors. So if you plug your head
actor into the damage actor, we can call this
point damage event on the Hit Actor blueprint. We'll get to that
in just a moment. Also, we can pass along
where this hit came from. What I'm doing here
is out of his head, we're breaking the hit
result and I'm saying, Hey, where did this occur, the x, y, and z location. And we're passing that
on to the hit from direction essentially
providing a coordinates x, y, and z where that
hit is occurring. Something else you
need to do here before you compile
is you need to pass along this hit information
from this hit events over into the hit info of your
apply point damage function. With all that done, you
can compile and save that. And this is all well and good. But the next thing you
need to do is jump on over to our ThirdPersonCharacter
Blueprint. Once again, over in
the Content Browser, you can find your
ThirdPersonCharacter right at this location. Here I set up this event point damage and all the things that
I wanted to occur. So firstly, where do you get
this event points damaged? Well, two ways you
can right-click and type in point damage. You can find it in
your right-click menu. Alternatively, if you did not have this added to
your graph already, you could come under functions and then the override section, you could find the point damaged function
in here as well. It's not listed
here because it is already added to my graph. Now once it's hit occurs back in our Level
Blueprint, once again, we're passing along
the Hit Actor and we know it's going to hit us
a ThirdPersonCharacter. It's going to call this
point damaged function, which is then going to result
in this event being fired. And what we're saying
here is we want to do this just one time
because this is an event that as it hits
things over in our level, this cube can bound around. It could hit our
character multiple times. We only wanted to
register one hits, so we only are going to
go beyond this 0.1 time. What I'm doing here
is I'm passing along the amount of
damage that I've specified back here in my
apply point damage function. Here, I'm just saying
50.5 just because this number right here gets passed along out of our
event point damage. So I'm subtracting this from our health variable over here and setting that
as our new Health. I'm just printing this
out to the screen. Then, then the last thing
I'm doing here is I'm going to spawn in
emitter at location. This is the old
particle system here, the cascade particle system. I'm just using an
explosion here. And what I'm doing
out of event point damage is right over here. This hit from direction. I'm passing this
information along, come out of here in hit
location to provide the location where I want
this explosion to occur. What results is this? Now you saw that the flow of
execution right up above. And here I am in my
ThirdPersonCharacter. Let's do this again. From my Level Blueprint. Zoom out a little bit. So once again, keep your eye
on this script firing off. Bam. You can see it's firing off multiple times
there because it's hitting the floor in addition
to hitting my character. Now, if you wanted to use the newer particle
system instead of this spawn emitter at location, you could delete that out. And if you do have any Niagara
particles in your project, you can simply specify
one of those here. I've got a coin shower which does not look as
cool as that explosion, but check that out right here. Now one thing I
haven't mentioned yet, but need to is if you're
going to be using this point damage in an
instance like I am using it, you want to be sure
that you're only using this event point damaged? Look what I did up above. I disconnected my
event any damage. Now if I hook this up as well
and notice that I'm doing this health modification
here to, well, it's going to result is
both events firing off. And you can see my
health actually dip below a negative one there. When you're calling. If I apply point damage, you're also going to be calling not only event point damage, but event any damage
as well because the point damage is
technically any damage. So just be aware of
that instance as well. Now note, while these
events are similar, the advantage of
event point damage is that location can
be passed along. You've got some other
things that you can pass along here as well, but that location is
chief among them. Alright guys, that's gonna
do it all for this one. See you in the next one.
38. Event Radial Damage: So there you are minding
your own business and then you step on a landmine, you suffer great damage. You fly halfway
across the screen and plunge to your death. Event. Radial damage is the cause for such instances and
Unreal Engine games. And what makes this
event unique versus the previous two damage
events is that it is perfect for area
of effect damage. With event radial damage, you can specify an origin point where maximum damage is applied, and also a radius upon which
falloff can be applied. So the further away you
are from the origin, the less damage that
occurs to your character. Alright, so I've set it up
an example prior to shooting this video and I'm going
to walk you through exactly what is going on here. Follow along if you
want to play at home. So what I did here is I placed a simple trigger
sphere into my level. You can find that by coming
under the place actors panel. And in my basic tab, I simply place a Trier's
finger in my level. In here, I simply set my
sphere radius to be 1,000. And I'm also making
this appear by simply coming under the where is it? Once again, the
rendering section, rendering, rendering,
rendering. There it is. I am choosing to not have
this hidden and game. I'm also setting the
editor billboard scale. That's this icon up to five, just to make this very obvious, to see next, what I did is
width this actress selected, I jumped on over to
my Level Blueprint. And inside of here, I created a reference to
this triggers fear by holding down the RT
and left clicking, so long as you have that
selected in the level. And then I dragged out of this and got the actors location. Now what I'm doing here is
upon pressing the E key, you can have any key
binding of your choosing. Once again, Level Blueprints
will recognize input events. I'm then spawning and
emitter at this location, the center point of my sphere, I'm just scaling up the
explosion to be extra big. Once again, if you
don't want to do the old school cascade emitters, well, you can do
a spawn system at location for the Niagara
particle effects. And then this is the key node that we're
talking about here, applying radial
damage with fall off. Now, note, if I
right-click and some empty space and type in apply radial, you can do apply a radial damage and also apply radial
damage with fall off. Both of both of these we'll call the radial damage event that we're gonna be making use
of in just a little bit. However, I like this one a
little bit better because it does have the ability to specify an inner radius and an outer radius as well as base damage and then
minimum damage. What this allows you to do
is specify a falloff range. So essentially what
I'm saying over here, let me just get rid of
this is my inner radius. Once again, my sphere is
1,000 unreal units in size. That's this right here. The sphere radius is 1,000. Back in here I'm saying
the inner radius is 200 unreal units, the outer radius is 1,000 units. The damage at the epicenter of the origin and within this inner radius
is going to be 100. So anything within this inner
radius is going to suffer to the maximal damage
that at the outer radius, at the extreme limit, I'm gonna do at
least one damage. Now I did put in as
damaged fall off value. This determines how quickly damage will fall off
from the center point, the origin points to the edges you can play
around with that number to have more or less of
an extreme fall off. And then the rest of these
inputs are all optional. But in order to get the system working, this is sufficient. Now, coming into my
ThirdPersonCharacter Blueprint, I set things up. Thusly, I got my
event radial damaged, which you can once again
get by right-clicking, typing in radial damaged, there's that event
radial damage. Another way to get
this event is over in the functions
overrides section. You can find this
in here if you did not already add
this to your graph. And here I'm passing along
this damaged received. I'm subtracting that from
my health variable and setting that as my
new health value. Now, what damage
amount gets passed along wall that is
really dependent upon how much my character was at the center of this
damage when this occurred. Now back here I'm
also printing out this health value to
the screen so I can see how much health was actually subtracted from my
base level 100 there. Then what I'm also doing here is a little bit of extra stuff. This is not really necessary in order to
see this even happened. But what I did here is I'm
grabbing my Capsule Component. I just dragged in a
reference to this. And I did a set simulate
physics function on here. Check that box. This is what is going
to get my character flying through the,
through the air. And this is what's going
to send him flying through the air a
radial impulse, impulse at the point of impact. All I'm doing here is I'm
passing along the origin, the center point of my
radial damage right here, I'm passing along that triggers, trigger sphere location
as the origin. And this is where I'm saying
I am sending out an impulse, imagine like an
invisible pulse wave. So the radius of this impulse
is going to be 1,000. And I set the strength
you can play around with these values to be
half 1 million. Now back in our level here
you can see my player start actor is gonna be starting
just outside of this radius. So if I was to click
Play and I've got my ThirdPersonCharacter
Blueprint now open and I press that E key. You can see that I'm not
doing any radial damaged because my character is
not within this radius. However, once I do
get within range, now note that I am
just barely stepping foot inside of this radius. Look up here in the upper left. It's going to show
how much health from my initial value of
100 is subtracted. So I'm gonna, I'm gonna guess I'm going to end
up with a value of like 89 or something like that because I'm
just barely in here, so I'm going to press the E key, ended up with 87. So almost 13 health was subtracted by just barely stepping foot. And
let's try this. Once again. This, I'm going to step
right towards the middle. So this should do
maximum damage. And if we go back
into our test map, you can see that the applied
radial damage fall off. It's showing that inside of
this inner radius of 200, I should be doing the
full 100 damaged. So let's see if that
is in fact the case. Let me open up my
ThirdPersonCharacter Blueprint. Once again, tap that Iike and in the upper
left it should show 0.0. And it does. So you can see, as said, simulate physics
and the head radial pulse. It is all for fun and games. Now, one last bit of
information to pass along here, just like the point damage. If you do have any damage
hooked up as well. Doing Radial damage will cause event any damage to trigger two. So now I should be doing
some damage to my character, as well as seeing
this text Hello up here as soon as I press
the E key inside of here. So you can see Hello
did appear as well as some health being subtracted. Alright guys, there is
event radial damage. Let's quickly recap the
different damage events. So any damage is good for
environmental damage. When you didn't take damage
at any specific spot. That's great for
stepping through fire or poisonous gas,
that kind of thing. Point damage is
good for specifying a given location where
damage occurred. Great for projectiles
hitting the player. Radial damage is good for
explosions and specifying a spot in origin where
maximum damage occurred. And this type of damage can fall off the further away
from the origin it is. That's going to wrap this up. We will see you in
the next video.
39. Event Destroyed: Welcome back everyone. Events destroyed is the topic of this video and our goal
is to learn what causes event destroyed to
fire for an actor and how we can use
that within a script. For this video, I'm gonna be using our Level Blueprint here. You can find that here,
open Level Blueprint. And I'm also going to be using our third person
character blueprints. You can find that here
in this directory. I've also done some setup
work ahead of time. If you follow it along with
the previous videos for various apply damage type nodes, this will all seem
very familiar to you. However, if you just jumped
ahead to this video, let me show you what I
did ahead of time in preparation for showing
off event destroyed. Now for starters here, I placed a Trigger box in my
level and all I did here is I simply sized up the box extends to be
200 by 200 by 200, set my line thickness to be ten. And also I made it so that in the rendering section where it is that rendering section,
once again, There it is. I said actor hidden
game to be unchecked. Then with this Trigger
box selected in my level, over in the Level
Blueprint, I right-clicked. I created an ad on actor begin overlap for that trigger box dragged out of the other actor we're casting to our
ThirdPersonCharacter to make sure that it is the ThirdPersonCharacter
overlapping us. And then if it is, we are going to apply damage
to our ThirdPersonCharacter, I'm doing 25 points
of damage here. Then in the
ThirdPersonCharacter Blueprint, this should look
familiar to you as well if you follow it along
with the previous videos. On event, any damage
getting called. And once again, this
gets called when this applied damaged
function back here in our Level
Blueprint fires off. This, then fires off. All I'm doing here is I am taking our current health
which starts at 100. We're going to subtract the
amount of damage that is supplied right here in our applied damaged function
in the Level Blueprint 25. We're going to
subtract that from our health set that as a new health. And if our health happens to be less than or equal to zero, we are going to destroy actor. Now this is the important
function right here. Because when this Destroy
Actor function gets called, event destroyed
fires off as well. So if I was to just go
ahead and play right now, this is what I'd have. I click in play here. Let me set my character
as my debug objects, bring out my play
window once again, over here in the upper
left you're going to see that health
value decrements. Reminder, my health system is not hooked up to my
meter here at all. We could change that later. Maybe we will 75, 50. You're seeing that event fire
off up above and then boom, our character is destroyed, but events destroyed we can further use to make
something else happen. So let's add event destroyed, and there's couple of ways
we could add this one. We could right-click
and some empty space, Typing events destroyed. That's one way. The second way, of
course, is over in the My Blueprint panel
under the functions area, you can override events, destroy the target here
is going to be an actor. And as you can see,
our Destroy Actor, the target is inactive. So in this case, our ThirdPersonCharacter,
we're saying, Hey, destroy ourselves. So there is no outputs here. We are destroying ourselves. Once this gets called, we are going to be
making a call over to this event to fire off. Alright, so let's make
something happened here. Let's drag out of
here and type in spawn emitter at location. Once again, you could
do spawn system at location that is the
Niagara particle system. I'm just going to be using
the old school explosion. There we go. And of course we have to
supply a location for this. So let's simply right-click
and some empty space and type in get actor location. The target is our
ThirdPersonCharacter is location. And let's do something else
is drying off of this. And let's spawn
actor from class. Let's spawn in some fire, our blueprint effect fire. We have to supply
a spawn transform. So I'm going to right-click. We're going to get
actor transform. Once again. The target is our self. You're a ThirdPersonCharacter. And then lastly,
let's just drag off of here and print string. And instead of the
string thing, hello, Let's just say something
like destroyed D steroid, if I can spell that right. Alright, so as we overlap
that trigger volume, we're gonna be applying damage to our
ThirdPersonCharacter. That damage is going to be applied to our health
value right here, once our health is less than or equal to zero, and that is true. We are going to
destroy this actor. This is going to cause event
destroyed to fire off. And then it's gonna do all
of this stuff right here. It's always a good
idea to compile. Make sure your script
is good to go. Let's save that, and
let's go ahead and play. And let me actually move this up so you can see this firing. Here we go. 12, that health is decreasing. Three now, look right up
above the play Windows. Well, for event
destroyed to fire off. Boom. There you go. We did spawn that explosion, and we did also spawn that
blueprint effect fire. Now I'd like to go
ahead and show off a one more example before
we wrap up this video. And just to show you
what I've done here is back here in my level, I added a cone right over here little bit beyond the bounds of
my trigger volume. You can find that in your place actors
panel right over here. But any static mesh will
do if you want to play along with that guy selected. What I've done in my
Level Blueprint is if I scroll over to the
right where you couldn't see this off
to the right before. I'm just going to be
extending the functionality. We are damaging our player. What I wanna do here
is bring this on. So in addition to applying
some damage to our character, I'm going to wait 3 s
the first time I overlap this Trigger box and I'm
going to destroy our cone. I got a reference to my cone here because with that selected, if I hold down the Alt key, I can left-click and bringing
a reference to my cone. So I'm saying, hey cone, you are the target actor
I want to destroy. Now down below. With that cone also selected, you can right-click and
some empty space and say, Hey, when you're destroyed. Once again, I'll show you
how I got this onDestroy. Here is I've got
that cone selected. I can add events and under the game section you
can add on destroyed. And if I select it right
now, it's just going to jump me to and say,
hey, I got you. Then what I'm doing is I can extract some information
from my destroyed actor. I'm supplying that
actor right here. I'm saying, hey, I want
to get your transform. Let's spawn are BP
example pick-up, and then let's play a sound. So this is going to
happen the first time we overlap
this Trigger box. So ignoring all this damage to the ThirdPersonCharacter
right now in 3 s, some are going to
destroy our cone, and then this event
destroyed is going to play and we're going to
have this spawn. Let's go ahead and
give this a play. Let's compile that first. Make sure it looks good. Going ahead and plan here, let me set my debug object to be my test map and bring out
my play window once again. Now the first time I
overlap this in 3 s, that cone is going to
turn into the pickup. There you go. So a couple of uses
for event destroyed. You saw me just demonstrate
a couple of right now. Number one would be to
spawn a particle or a sound at a locale
of destruction. Number two would be to
spawn and other actors such as a loo drop when
killing an enemy. Alright guys, that's gonna
do it all for this one. We will see you in the next one.
40. Custom Events: Custom events is the
topic of this video, and this is a super important
topic because custom events are some of the most used events in all a blueprint scripting. So our goal in this video
is to learn what they are, how they're added, and
why they're useful. Now a custom event is an
event that you get to name and call for it to fire
whenever you'd like. Alright, so seeing is believing, I'm gonna be using mainly the
ThirdPersonCharacter Blueprint in this video, but I'll be dabbling a little
bit in the Level Blueprint. So go ahead and get those open. I'll be starting off in the ThirdPersonCharacter
Blueprint. And firstly, we need to add
one of these custom events. Well, how do we do that? Right-click and some empty
space type in the word custom. And under the add
event category, we have added custom event. Now the moment I do this, it's going to add
events to my graph, but it's going to prompt
me to give it a name. I'm going to call
this add health. Now, if at anytime you
want to change the name of your custom event, two
ways you can do that. You can simply just
double-click on this and it'll give you the
ability to change it here. Or with this event node added this customer vendor and add it over in the
Details panel. You can change the name
of it over here as well. Alright, so adding health, Let's go ahead and make
this event actually add some health
whenever it is called. Now not right now. We've gotten nothing to
actually call this event. We will take care of
that in a little bit. But to actually make
this do something, let's drag in our
health variable. I'm going to get this. I want to drag off of this
type in the plus button. We're going to add
some amount to it. Let's add 010. Sounds good. Then I'm going to drag and
drop my health on top of this output in order for
us to set our health. So we're getting our health, we're going to add ten to it and then we're
going to set it. Sounds good so far. Let's go ahead and print this
out to the screen as well. So print string. If I take this output of my sit health
and plug it into the string, I'm gonna get a little
conversion node to convert one data
type to another, a float to a string that'll
print it off to my screen. And then let's also
drag off of here and type in spawn
emitter at location. Once again, you can spawn a system, Niagara
particle system. I'm just going to use
the old school explosion because I like to use that
for pretty much everything. It's very visual, right? So we're gonna spawn
and explosion where? Well, let's get our
actors location here. Yet, factor location. The target is ourself, the
third-person character. Let's plug that in here. And then let's just
play a sound as well. Drag off a few play sound. 2d. 2d sound is one that
is not at a given locale. It's just a great
for Menu sounds. By the way, I'm gonna do
compile, compile, success. Either one of these will do, alright, compile and save that. That looks like a fine script. Alright, so we need something to actually call for
this event to happen. So this is going to be a
rather academic example, but just to make
things easy here, I'm gonna do is right-click
in some empty space. You can put in the one key. And I'll say that off of
pressing the one key, we're going to drag off of this. And now if I type in Add
Health, Check this out. I have a node that I can add, a call function node
called AddHealth. So what I'm essentially
going to be doing here is when I press the one key, I am calling for this custom event called
AddHealth to fire off. This is a wireless connection and that's one of the benefits of using custom events and secrete these
wireless connections. Now it could very
easily just say, Hey, off of the one key, do all this. However, sometimes you've
got very complicated scripts and you want to keep things
nice, clean and simple. This is a good way to
create a wireless, wireless firing, a wireless
calling of that event. So this calls this, which is going to make
all this script happen. Let's go ahead and
compile and save. Go ahead and play here. And I'll try to
frame this all in. So watch. Once I press the one key, it's going to make
this all happen. You're going to see
that emitter occur. You're going to hear
a sound, et cetera. Here we go. And I can just keep doing this again and again
and again and again. So these wireless connections
are cool and all, but that's not really all of the benefits that you
get from custom events. With custom events,
you can also call for this event to happen
from another blueprints. So let's go ahead and call this event from inside
of our Level Blueprint. So if you forgot how to get into your Level
Blueprint from now, there you go for the 100th time. And I'm going to right-click
and some empty space and I'm just going
to bring in the, let's do the seven key or
any other keyboard event. Then I'm going to right-click
and some empty space. We're going to get
player character. We're going to drag off of this. We need this in order to Cast
to ThirdPersonCharacter. Because we need to
supply our casting of the ThirdPersonCharacter
with an object and that suffices get
player character. So in doing this,
we're checking, hey, is our player character
the ThirdPersonCharacter? And if it is, we can talk to our ThirdPersonCharacter in
some way, shape, or form. That includes calling
a custom events. So for this to work, you need to make
sure that you have compiled your
ThirdPersonCharacter Blueprint. Very important here. Once you've compiled this, you will now be able to find this AddHealth over in
our Level Blueprint. Let's go back here, drag out of your
ThirdPersonCharacter and type in, Add Health. And look once again, we've got that calling of the
function at health. That is the same sort of node that we had in our
ThirdPersonCharacter. Addhealth target is
ThirdPersonCharacter. Over in our Level Blueprint, AddHealth target is
ThirdPersonCharacter. Alright, compile this, save
and play and shake it out. I can press the one key. And the one key again is adding. Some are calling
that custom event from inside of the
ThirdPersonCharacter. But now I'm going to
press the seven key. And I've got my level set
as my debug option here. So you're going to
see this fire off. Here we go seven. That's can call it as well. So that is one of
the main benefits of a custom event is
once you've got a reference to that
given blueprint, in this case, our
ThirdPersonCharacter. You can then pull off of that
and find that custom event. You can make a call to
that customer event. Alright, with that,
out of the way, let's get onto some
of the nuances, some of the other
things that you can do with these custom events. I'm going to jump back to my ThirdPersonCharacter
Blueprint here. And what I'm gonna do is
I'm going to drag off of this little red box
here. What is this? This is an output delegate. So what can I use this for? Well, let's set up an example. I'm going to right-click
and some empty space here and type in events. Begin play. I had this hooked up to my creation of the
widget, my HUD widgets. Olivia disconnect this by
holding down the Alt key. Left clicking, I'm
going to steal event begin play quickly. I'm going to bring that
all the way down here by my adding Health
custom event. Then I'm going to drag
off of this and type in set timer by event. Upon beginning play. That is our ThirdPersonCharacter getting spawned into the game. We can have some event fire off whatever
event we plug into it. Now, this works for not
only a custom event, but I'm showing it here
with a custom event. This could work for
other events as well. You can see event B in
play and other events have this kind of a
delegate as well. So I'm going to take this, plug it into here, and I'm going to
set my time to be 5 s. And I'm also going to
set this to be looping. So now let's
understand what I've got going on here with
this custom events. I'm going to say a
pond beginning play. We're going to call
this function, this set timer by
event to happen. What's going to happen
here is every 5 s, this event that's plugged
into this set timer by event function is
going to fire off. And it's going to be
happening every 5 s because we've got this
looping checkbox checked. So check this out. So let's compile this and play. So no event B employee
already happened. Every 5 s. Can wait another 5 s. So this event begin play
fired off at the very start. Once I started up my game, my character respond in. From there. You're not going to see
this fire off anymore, but it will continue
to run this every 5 s, bam, bam, bam, bam, bam. Alright, so now
you know that with the customer event created
and added to your graph, it's up to you to
make sure that you call for that customer
vent to fire. Sometimes that can
be a little bit annoying when you're
testing things because maybe the conditions
you have setup to call that custom event
are a little bit complex. Is there something
that you can do for testing purposes to make having that customer
event fire easier? Well, there is with
this custom event selected over in
the Details panel, you have a call-in
editor checkbox. Go ahead and check that. This is a very important
step here with that checked, go ahead and click
this compile option. Once you do that,
notice this icon right here on your custom event
is going to change from that arrow icon to this little f sort of looking
thing in the diamond. What this is going to do now is if we jump back to
our level editor, once I play, we're going to see our ThirdPersonCharacter
be spawned in. It's going to be present
in our outliner. I'll then be able
to select that. And over in the Details panel. There'll be in AddHealth
button that I can go ahead and click to manually cause
a custom event to fire. I make this happen. I need to kind of side
window this a little bit. I'm going to click Play. All right, there's my
play window over here. Now, over in, my main editor. Going to have to peel
this down a little bit, sorry for this lack of space. There is in yellow my
ThirdPersonCharacter, I'm gonna go ahead and select
that spawned in that so that yellow
coloration indicates. And down here in
the Details panel. If I do a search for AddHealth, I can now find in
AddHealth buttons, so I've just made it,
I've just set it up. So here in the editor, I can manually call
this custom event. So note that once
I click on this, it's going to make all the
following script happen, which is going to create
the explosion in OneNote. So if you're looking
over here as I click on this Add Health, it's calling that custom event, bam, bam, bam, bam. You're seeing that
health tick up as well. But of course that
is not all checkout. What else we can do
with custom event with this selected over
in the Details panel, I've got this input section. What can we use this for? Well, let me click this
Plus button right here and show off a quick example. We get to create an input. Notice how this just popped
on a new parameter input, and there's the name of it. So let's go ahead and name it. Let's call this health to add. And you can change the type. Notice I updated the name
and an updated here. I don't want this
to be a Boolean, so I'm gonna change
this to be a float. And I will just modify
my script as follows. Let me just go ahead and make it so that our health to add, Let's not cross
the wires, right? We're going to call AddHealth. When we call AddHealth, we're going to find out how
much health we want to add, add it to our
existing health and set that as our new health. Now, note that this is
all a little confusing, at least in this stage because input is
what this is called. And this is on the
right side of a node. And as I mentioned before, outputs are on the
right side of a node. Inputs are on the
left side of a node. This is all a little
bit misleading here, but it makes sense if you
scroll down here and note that this AddHealth calling of this custom event added an input right here,
health to add. So in adding this input
to our custom event, you've added this as an input on the calling of that
custom events. So let's change this
to, let's go 25. And now if I go ahead,
compile, save, play. Note that whenever
I press one key, it's going to call for this
custom event to fire off. Every time I do,
it's gonna say, hey, add 25 health to our existing health and set
that as our new health. So here we go. You can see it's incrementing
25 up every time. So just to recap here quickly, why use custom events? Well, number one, if
you're going to call a custom event within the
Blueprint that you've created, that custom event,
you can create these wireless connections which keeps things nice,
neat, and clean. But the main benefit of a custom event is with one
created in one blueprint. So long as you have a reference to that,
given a blueprint, as we do here in our
Level Blueprint, you can make a call over
to that custom event, which is the most powerful
thing about them. Or guys that is gonna
do all for this video, we will see you in the next one.
41. Variables Overview: Okay, So with events in
the rearview mirror, we're going to be
shifting our attention to the topic of variables and our goal in this
specific videos to learn and variables are when
it comes to programming, or in our case,
blueprints scripting. Alright, so what
even is a variable? Well, you can think
of variables as containers that hold a
specific type of information. And I love the fact
that in unreal, these containers,
these variables are sort of capsule shaped. If you imagine a
capsule being able to hold some kind of thing, you get the idea of what
variables are all about. They hold something,
in this case, hold some data and actually specific types of
data depending on their types. Now, these containers,
these variables exists within a
specific blueprint. So right now I'm in
my Level Blueprint. These variables that
are created over in my, My Blueprint panel exists only in this specific blueprint. If I jump on over to
my BP example pickup that was an actor
class blueprint. I have a few variables in here, this pick-up sound
being one of them. I have a Delta seconds
variable as well. These only exists inside
of my BP example pickup. Let's take a look at our
ThirdPersonCharacter. There are variables
that exist just inside of my
ThirdPersonCharacter. Now these containers, these
variables can be created. These containers, these
variables can have a default value assigned to
them or they could be empty. And just taking a look at our third-person character here, I've got this health
variable and it's currently has a default value of 100. And these containers can have their content changed over time. Their contents can be varied. As we can see here, a third-person character starts off with a health value of 100. But you've seen in
previous videos modify this health
variable to change. It doesn't have to stay at 100. If I take some damage, it could go down to 75, 60, etc. Or I can heal back up and find my way back in
full health and 100. So where can you create
these variables? Well, there's a couple
of different ways to do it within the My
Blueprint panel. Way number one is you simply click on this Add
button right over here. There you can create a variable. Another way is within
the My Blueprint panel, find the variables section, and click on this plus
button right over here. So it's worth noting that some blueprints may have
inherited variables. That is, variables
that came along with the parent class that your current blueprint
inherits from. However, they don't show up by default over here into
my blueprints panel. You can expose them. So the way we could do
this is by clicking on this gear icon and you get this little fly out menu, show
inherited variables. Go ahead and click
on this check mark means that that
category is shown. And now you see a whole bunch
of different categories populate under your
variables section. And you can expand these out by simply clicking on any
of these triangles. Let me just expand out
this pawn category here. And now you can see all of your different variables over in the My Blueprint panel hover. It's kind of annoying,
clicking on them all individually like this to see what their default value is. Is there an easier way? Well, of course there is. If I click over on the class defaults button at the very top here
of my blueprint, I can see all the
different variables that exist for this parent
class is character, this specific of BP,
ThirdPersonCharacter. Note I have a upon
category of variables. And over on the right-hand
side it's showing all these same variables and it's showing all
their default values. That's kind of handy. This class defaults button. Note too, that the variables that we created
earlier in the course, we've got the health
variable and whatnot. They belong to a category
called the defaults. And WPP HUD was under
the category of default. So if we come onto our
class defaults, once again, we can see we have
a default category and those exist
currently under there. Now note different
parent classes have different amounts
of inherited variables. But if you click on
that class defaults, you get to see all the
variables that you can change about a given blueprint, including the ones that you have created and you get to see all their default values
as well, pretty handy. Now something else worth
noting here that while a given class may have a whole bunch of variables
associated with it. So to do components, so if I was to go
over and select my character movement component over in the Components panel. You can see that this
movement component, this character moving component, has a whole lot of variables
associated with it. These are all variables because their contents can be changed. Now note some common lingo you or hear a lot
when it comes to variables is that you can get the variable or you
can set the variable. Now let me just jump on over
to my Event Graph quickly. And I'm simply going
to use my healthier. If I left-click and drag
this out into the graph, I'm just simply left
clicking and dragging. And I released. It's going to say,
do you want to get your health value or do you want to set
your health value? So let's explore these. In getting it. We can say, Hey. How much is in here? And let's put that
into some other node. In this case, we're saying
how much health exists within this capsule, right? Conversely, I can left-click and drag and say, let's set health. Now, with this type
of node, a setter, you can determine
how much health this is going to be changed to. Again, a variable
can be changed. Here we're getting
the current contents. Here, we're setting the contents the value of this variable. So if I wanted to change
the value of our health, I could say, you
know what health, I want you to be 50. Now I just hard-coded this
in by typing in a number. But it could have another
variable that could plug into this that would determine that it's new health amount. Note however, that
with a getter, you are simply extracting
that data from that variable. With a setter. You need to hook in
an execution wire. And execution wire
needs to set this. So some event or some other node leading into this
needs to flow into it. And you could have
something flow out of it as well if you want to continue
on with your script, but you must have
something flow into this execution pin right
here in order to set, that is to change the
value of that variable. Now a couple of shortcuts
that you can use when trying to get
or set a node. You saw me, it left-click
and drag and you get that little menu there
to get or set it. A shortcut here is
if you hold down the Control key and left-click
and drop that in like so, you get that variable. Conversely, if you hold down
the Alt key, left-click, drag and drop, you get a
setter for that variable. So very important lingo
to understand there, you're getting the
value of a variable or your setting that variable
to some new value. And finally, one
very important thing to remember here is you must compile a blueprint in
order to set a default value. So I'm going to jump over to my BP example pick up
here, that's this guy. And let's just say
I wanted to add a variable that's
going to contain how much health to heal our
character once we overlap it. So I could create a variable by clicking
on this plus button. We'll call this amounts to heal. However, over in the
Details panel says I can't give this a default
value unless I compile it. So if I click over in the upper left by that yellow
question mark, compile means good to go. I can now give this
a default value. I'll say 25. Great. That's also important
because if you're trying to access this variable from
within another blueprint, that is a necessary step. And just to demonstrate this, let me show you that I have an instance of this blueprint, my BP example
pickup in my level, I'm gonna jump on over into my Level Blueprint,
open Level Blueprint. I'm gonna hold down the
R key and left-click to create a reference
to that example pickup. And now if I was to drag out of this and type in what did I
call that amounts to heal. I could now get the amount
to heal if I needed to find that and print it out to the screen or
something like that. Or I could drag out of this
and type in amount to heal. And whoops, not yet. Amounts to heal. We could set that amount. So if I wanted to change the default value here
to some other valuable, again, that's what variables
allow you to do to change the contents
of that container. I can say, You know what, I don't want you to heal 25. I want you to heal
just five instead. I could do that as well. All right guys, it's
going to wrap it up for this quick overview
on variables. We'll see you in the next video.
42. Boolean: Welcome back everyone. In this video, our goal is to learn what a Boolean
variable is, how to create one
in how it can be utilized when
blueprint scripting. So firstly, what is
a boolean variable? Well, a Boolean variable
is a variable that contains true or
false information. And we talked about
in the last video, variables are
essentially containers that hold some kind of data. A Boolean variable
is a container that simply holds true or
false information. So imagine a capsule and
inside is a piece of paper. And on that piece of paper
says either true or false. That's all it can be,
either true or false. And depending on the
contents of that, you can pair it with
something like a branch node in order to create branching
path of execution. If it's true, do this. If it's false, do that. So here I am inside of my third-person
character blueprint, and we're going to show
off an example here. Let's start off by creating
a Boolean variable by coming under the My
Blueprint panel variables, this little plus button here. And we're going to create a
variable called can jump. And I usually like to put
a question mark after it. I'm going to hit Enter here. I personally, and this is
my own personal preference. Like to name my Boolean
variables with a question mark. Essentially, is this
true or is this false? Now I can change the type of variable either by
clicking right here, and you can see it is
Boolean by default for me, I can click right
there and change it, or would that variable selected over in
the Details panel? I can change the variable
type over here as well. Just fun fact for you here. When you go to create
a new variable, it will set the type
of the variable to be whatever was the last type of
variable that you created. So what are we gonna
do with this can jump? Well, first of all, we need
to give it a default value. In order to do that, we need
to compile the blueprint. So let's go ahead
and compile it. And with that done, we
can set a default value. I'm going to say yes, we can jump by default, check that box. Checked means true,
unchecked means false. Let's go ahead and
check that box. Now let's go ahead and put
this Boolean variable to use. In order to do this, I'm going
to create a little bit of space here between our
input action Jump, which will fire off when
we press the Spacebar, and our jump
function right here. So with our can jump variable down in the
My Blueprint section, let's left-click and drag
that into our Event Graph. Do we want to get it or set it? In this case, we want to
get the contents of that. We want to find out
if we can jump. What I'm gonna do
next is drag off of this and bring in a branch node, one of the most common nodes in all of Blueprint scripting. You can see this branch
node can take in a red variable type that is
a Boolean variable type. That's the condition
here that allows us to plug something into
this to evaluate, Hey, what are the contents
of this variable? Now it's just fun facts here. If I left-click and
break this wire, we could hard set this
condition to be true or false, true, false. But I want to read in the
contents of this variable. So I'm setting this as my
input of the branch node. Now let's sneak this
in-between here. In here I'm going to cut
this wire by holding down the Alt key
and left clicking. And I'm going to set
my script to be like so once I press the space bar, which is going to
fire off this event, we're going to evaluate, is this variable true or false? If it is true, we will jump. If it is false, we
will do nothing. Now currently is set to true. So you would expect that
indeed, we will jump. Let's go ahead and compile. And let's play. And if I set my debug object here to be my
ThirdPersonCharacter. Let me go ahead
and bring this on. Now you'll see that script
fire right over here. When I press the space bar. You'll see that I can in
fact jump once I release it. By the way, this stop
jumping is going to fire. But because this
evaluates to true, I can go ahead and jump. Now if I was to change this, I'm going to hold
down the Control key, left-click and changes to false. Now we're going to see, hey,
is Ken jump set to false? Well it is not. So if I was to go
ahead and play, you will see now I
press that space bar. But it's never actually going beyond this branch node is dying right here because the contents of this variable can jump. Boolean variables set to
true is not set to false, so it is making it so our
character, it cannot jump. Okay, so admittedly, that was
a rather academic example, but let's go with
something a little bit more true to life. Let's go with this
scenario whereby your characters just
entered a crowded building. And oftentimes in games, you'll find that when you're inside of a crowded building, they disable your
character from running. They disable your character
from a drawing a weapon. And in our case,
we're going to say our character cannot jump. Now my computer crash
between little cuts here. So make sure you've set your input action jumped
script to be as follows. We want to say can jump, which is set to true by default. We're going to branch it
and make sure that on true, we're going to say
yes, you can jump. What we're gonna do here is inside of our
Level Blueprint, change the contents
of this variable. So when we are inside
of a trigger volume, we disable our
character from jumping. And when we're outside of it, we flip it back so it can jump. Let's go ahead and do that. Now we need to go
back to our level. Inside of here. We're going
to place a Trigger box. And once again, you can
do that by coming under. Here. Bring on your plates actors
panel with this basic tab, you can find your trigger box. Place that in front
of your players. Start actor. I'm going to quickly size
it up to 100, 200, 200. Let me set the line thickness
to be something like ten. Something nice and thick. I'm not going to worry too much about the policeman of it. And down below, I'm
going to change the rendering so that actor
hidden end game is unchecked. That'll make it so
we can see this. Now, this Trigger box selected. Let's go to our Level Blueprint. You can bring on your
Level Blueprint by going here and here, right-click. And we have that trigger
box selected in our levels. We can add an event for it. Let's add one for begin overlap. And we're also going to
add one for end overlap. In what we wanna do is check to see who the
other actor was. We want to check to see if it was the third-person character. So I'm going to
drag out of here, type in third person we can cast to our
ThirdPersonCharacter. Like so. If it was the
ThirdPersonCharacter that overlapped us, guess what? We can reach inside of our ThirdPersonCharacter
Blueprint. And we can access those variables
that live inside of it, including that can jump a Boolean variable
that we just created. So really seeing, I'm
going to set my ten jump, I'm going to type in
can jump like so. And there is my variable. I can either get it or set it. In this case, I want to set it. So I'm going to say that
when our character is overlapping that trigger
box, we cannot jump. We're going to leave
that as false. Left-click drag, going to
highlight these two nodes, control C to copy, control V to paste. I'm going to hook this
in like so and like so. And we're going to
say that when we end overlapping that trigger box, we're going to say yep,
you can jump once again. So inside the Trigger
box, we're going to say, Nope, you cannot
jump outside of it. We're gonna say, yes, you can remember back here in our
ThirdPersonCharacter Blueprint, we are checking when we
press the space bar, we're checking the contents of that variable by default true. But over in our Level Blueprint, when we're overlapping
that trigger box, we're changing it to false. When we're ending it, we're
changing it back to true. Go ahead and compile
this quickly. Make sure our script looks good. Save it. Let's go ahead and play
and a phrase this up. Let me just move this
up just a tad here. Can't actually, I cannot move
this while we're playing. So let me just
note that up here. Play once again.
Alright, here we go. I'm outside of that
trigger box spacebar. Yes, I can jump. We're going to move my
character inside of it. You see, it is
switching that variable now to be false,
mousing over it. I can see that as well. Let me go ahead and
press the space bar. I cannot jump. However, once I leave this, that variable gets flipped
back to true and I can jump. Alright, let's talk through some possible Boolean use cases that you see common in games. One could be, is the
door lot true or false? Do you have the key card, e.g. how about can you fire a weapon? Do you have any animal
left, true or false? What about can you
pick up an item? Are you close enough
to it, true or false? What about can you
equip an item? Are you a high enough
level, True or false? What about can you buy an item? Do you have enough
money, true or false? Those are all possible. Example use cases of
a Boolean variable. Alright guys, that's gonna
do to offer this one. See you in the next one.
43. Integer: In this video, our goal is to learn what an
integer variable is and how it can be utilized
in your own gaming projects. We're gonna be starting off in our ThirdPersonCharacter
Blueprint. So that's where
you can find it in your content browser
or content drawer. Double-click on
that to open it up. And before we even create an
integer variable down here, let's talk about what
an integer even is. Well, this is a container. This variable type
is a container that holds whole number information. That is, numbers without
a decimal point. These can be positive
or negative numbers. Now, you can think
of some example use cases for where
whole numbers are used. Things like score values are oftentimes printed
out in whole numbers. Money values, how
much gold or silver, that kind of stuff you have. Or what about a
character's level? Level one through 100? Those are usually whole numbers. Now, integers are often used
to drive logic as well, e.g. you might check to see if the
given value of an integer save experience points earned has reached a certain threshold. And if it has, the
player levels up, alright, let's create
an integer variable. Over here are my
blueprints panel. This time I'll create
one by clicking right here under the add button. Let's create a variable. And by default
it's going to make the type the same as whatever your last
variable created was. So it's starting off Boolean. I'm going to call
this total XP earned. And you can change the
variable type either here, which I will do. We want to set this to be
integer not integer 64, but we'll talk about
those differences a little bit later
on in this video. So you can change it here
at the variable type or in the Details panel, you can change the variable
type right here as well. We'll talk about
these differences later on in the course. But for now, just know the
variable type that you want to change is in this
drop-down menu. A little bit more nuance to
explain while we're here, we can set a slider range for this variable as well
as a value range. Well, what does that even mean? Well, to really drive
home this point, let's compile our blueprint so that we can set
a default value. And now if we set a slider
range and let's try from zero to, let's go 50,000. Like so. And our value range is, we'll say 0-100 thousand. We've essentially
set some caps on how far we can take this value. Now the slider range comes about when you
left-click on this, see how arrow icon went from my mouse cursor to left and right arrow, I can left-click. And if I move this to the left, I can't go below zero. However, if I move
it to the right, I can go up to a cap of 50,000, that is the slider range. However, if I was
to click on this and put in a number
and I'll try 200,000. This is hard inputting
it and press Enter. It's going to cap it
to my value range here it's saying my value
range is 0-100 thousand. That's the highest
that I can set this. The slider value determines how much if you
left-click in here, how much it'll go if you
simply left-click and drag it. The value range is
if you click on it, What's the max and
minimum numbers? You can hard input. I'll set this back to
zero for the time being. Next, let's jump over to
our event graph and create a simple script to make use
of this integer variable. I'm going to right-click
and some empty space. I'm going to type in keyboard and I'm gonna look
for the keyboard event. Any of these will do just fine. But I'm going to look for
x because we're gonna be doing something worth our
experience points here. So when we press the X key, what do we wanna do? Well, we're gonna take
our total XP earn. I'm going to hold
down the Control key, left-click and drag
to get that variable, the contents of which
are currently zero. And then I'm going
to drag off of this. Bringing the add operator plus
button will get you there. We're going to add 100 to this. I'm just going to hard set this. Then I'm going to set
a new XP earned value. So I'm going to hold
down, actually, I'm just going to
left-click and drag and drop this right on here. I'm just going to hold
down the Alt key, left-click and drag. But if I just drop
this variable right here on this output,
they'll give me a setter. Okay? Well, we're
gonna be doing from here is dragging off of this. Let's print this string. Let's print the amount
of this to our screen. Brings in a little conversion, converting an integer datatype
to a string datatype. I will then drag off of here. And we're going to
do a search for a greater than or equal to node. We're going to say
if our total XP earn is greater than or equal
to, we'll say 500. And I'm just going to set. These, on the node themselves, I could contain these
invariables themselves, but let's just go with
the hard value of 500. Drag off of this, bring
in a branch node. We're going to hook
this in like so. And we're going to say
that if it is true, if our total XP earned is
greater than or equal to 500, what we're gonna do then
is drag off of here. Do another print, screen, print screen, print string. And our string here is
simply going to read on Gratz your level two. And let's just change the
text color here to be somewhat noxious color
like hot pink shore. And make that appear
on the screen for 5 s. So that's our
scripts right here. We can left-click and
drag to put a comment box around this left-click and drag highlight those all tap CQI. And we'll call this R using an integer to level up script. I'm going to change the
comment box here over in the Details panel to black. Alright, compile
this to make sure your script is good to go. That's what we've
got going on here. Let's go ahead and
play and see that we're making use of
this integer variable. Okay, so every time
I press the X key, let me set my debug objects here to my ThirdPersonCharacter. Every time I press the X key, you're going to
see this fire off. In the upper left. I've got 100 XB. We start off with
zero, added 100. Our new total is 100. Once again,
200300400500 congrats, you are level two. So that is one example use
case of an integer variable. Alright, let's try one more
example this time accessing this variable from another blueprint,
our Level Blueprint. I'm gonna go back
to our level here. Let's make sure we have a Trigger box placed
in our level. You've seen me do
this several times. I'm going to place a
Trigger box in my level. I'm just going to size
it up a little bit. Let's go 200 by 200 by 200, changed the line
thickness to ten. You're getting good
at this by now I'm gonna go down to the
Rendering section. Ensure accurate hidden
game is not checked. With this selected. I'm going to jump over
to our level blueprint. In any empty space, in any graph that you choose. I'm going to right-click. We're going to add an event
for that trigger box. When we begin overlapping it, we're going to drag out
of the other actor, see if that is the
ThirdPersonCharacter. And if it is, we can now extract some information from our
ThirdPersonCharacter. That is, we can access
any variables that live inside of our
ThirdPersonCharacter Blueprint. Once again, once you
have a reference of some kind to a given object, in this case, our
third-person character. You can access the variables called functions inside of it. It's cetera. So I'm going to type
in total XP earn. Let's get that amount. And let's drag off of here. Do the same thing. We're
going to add 100 to it. And then let's go ahead and set that variable drag off
of here, total XB. We can set it. Of course, with centers you have to
pipe in and execution wire. And let set that as
the new XP amount. So let's compile this Save. And now what we
have going on here is anytime we overlap this, we're going to increment our
total XP in that manner. Here we go. So looking
in the upper left, I overlap it once, and I didn't print it
out to the screen. So that would probably
be helpful to do. Drag off of this type
in print string. I'm not going to be doing any
level up and just hoping to show that this is actually
incrementing that variable. Alright, there's our scripts,
compile, save, play. When we overlap that
trigger box, 100, overlap it again, 200, 300, etc. So imagine you could
give your character experienced points if they reach the top of the mountain,
that kind of thing. Finally, earlier in this video, I said I would describe a little bit what the
difference is between an integer or integer
64 variables. So let me just jump back to my ThirdPersonCharacter
Blueprint. I'm going to temporarily
create an integer 64 variable. Let's go ahead and do that. Plus, I'll call this int 64. We'll change this
to an integer 64, variable type compile save. The difference is the
range of possible values. So with an integer 64, you can have a wider
range of values. Again, that's in the
positive and negative, going to left-click and
drag this all the way over. It might even run off the
screen there. It does not. You can look up on line
for the range of this, but essentially,
with integer 64, you get a much wider range
of possible numbers. It's not quite infinite. In 64 is do take up a
little bit more memory, but it's not that
much in most cases. And just about every case in
integer should be just fine. Let me go back to
my regular integer and show you the range. Whoops, I got to take
off my cap here, deletes my cap, delete. Let me just set this
to none and like so. Boom, that's the limit for an integer variable
number that goes in the positive and the negative
in 64, infinite nine. And that is the range
for the int 64. Again, that goes in the positive and the negative direction. Guys, that's gonna do it
all for our discussion of the integer variable. Very useful, very handy to know that'll do
to offer this one. See you in the next one.
44. Float: All right, welcome
back everyone. In this video, our goal is to learn what a float variable is, how to create one,
and how it can be utilized when
blueprint scripting. So firstly, before
we get started here, what is a float? A float is a variable that
holds a decimal point value. Again, it can be
positive or negative. Now, in Unreal, this variable is oftentimes used to
hold a time value or to determine a percentage
like zero to 100%. And that's usually
represented with 0.0, meaning 0%, and
1.0 equaling 100%. Let's show off a couple of
different use cases here. I'm going to be inside of
my BP ThirdPersonCharacter. And I'm gonna be piggybacking
off the script I used in the previous video when we
were showing off an integer. Let's go ahead and
create a variable. Gonna do it by
clicking right here. And let's call this delay. We're going to set
a time delay before making our string print
off to the screen here. Again, we want to make this a float variable so you
can change it here. Changing it there,
or conversely, you can change the
variable type with that variable selected
over in the Details panel. Now, once we have that created, we can compile to set a value. Once again, floats have
a decimal point value, so let's try 1.5. That'll be our time
that we're going to delay this printing
of our string. Let's bring in our flow
variable holding down Control, left clicking and dragging will bring in a getter
of that variable. And you can see floats are
this lime green color. And then let's just bring in a delay node so I can right-click
it. Some empty space. Type in delay. There is our delay node. And let me just sneak
this in right over here. Like so. So once again, this
delay function node, we could hard to set a delay which is
currently by default at 0.2 s. Or we can plug in
some afloat value again, on the left side it's
asking for an input. And the input is
looking for is a float. So you could hardcode it, or you could store
it in a variable. So we're storing it in here. Our current delay
is set as 1.5 s. So upon pressing the X key, we're going to find out our total experience points earned. We're going to add one to it. And we're going to set
that as our new variable for the total XB
earned that integer. Once this has equaled
or exceeded 500. Once that's true, we're gonna
delay by this amount 1.5 s, and then print off that message that Congrats you are level two. Let's compile our script. Make sure it's good to
go save it. Here we go. Play. Let me just tuck this over here so you can see this all working. Okay, so pressing that X key, we haven't exceeded
this threshold yet too. You can see that
amount right up here. And we are outputting some
weird value for x p earned because I forgot to set XP earn back to zero from
the last video. So I need to fix that up. Let's set that back to zero.
That'll screw things up. Compile save, play
one more time. X I got 100, 200,300,400.500 XP delaying and then congrats your level two. Now you can see that once
we've exceeded that, that delay kind of
countdown count counts down here in the script, which is pretty handy. You can see as I press it again because we're exceeding
that threshold, that it counts
down pretty handy. Next, why don't you jump over to this a bit of script back in your BP ThirdPersonCharacter
Blueprint where we were creating our HUD and
adding it to the viewport. I destroyed this a
few videos back. So what I'm gonna be
doing here is let me bring on my vent, begin play. It's going to jump
me way down here. Let me just move this event
B in play into position. And if you did destroy this
a little bit of script, this is how you can get it back. Event Begin Play. We're going to create widget. This is a Create Widget node. You can set your WB P HUD back in here in order to create
that Widget Blueprint. Then on this pin I right-clicked
on this and promoted it to a variable in order to encapsulate that
with any variable. And then we added
this to the viewport. With all this done,
we click Play. We can see that that
health meter is added back to our screen here. Now that's all relevant
because we're gonna be using a float variable to drive how much health is displayed in this
health meter. So. Inside of your mind Blueprint panel of your
ThirdPersonCharacter. Sometime back we did
create a health variable. If you didn't, you can
go ahead and do that. Now. Currently it is set to
a default value of 100. Now I mentioned that
float values are oftentimes used to
have a value between 0.0 and 1.0 to determine a percentage 0% all
the way up to 100%. So we're going to set
this float value to 1.0, meaning full health. And then down below I
had some script to set the visibility of that HUD. Turn it on and off. I'm just going to destroy
this one instead, I'm gonna do is when
I press the five key, I'm going to
increment our health down a little bit so we
can see a decreasing. So I'm gonna hold down Control, left-click and drag this in. And then I'm going to drag out of here and
I'm going to bring in the minus key,
the subtract key. And I'm just going
to say decrease it by 0.1, that is 10%. And then we're going to
drag and drop this onto the output in order
to set the health. Okay, So we currently
have this bit of script going on inside of our
ThirdPersonCharacter. We can compile this and save. Now if I press his
five key right now, you're going to see
nothing happened to the actual meter itself. And just to prove that, I'm pressing F5
and it seems like, okay, the health
meters not going down. That's because we need to bind this variable to this meter. So that's going to
involve us going over to the WPP HUD asset, doing some work inside of there. So we can locate this asset by coming to
this node right here, clicking right here to
browse through this asset within the content browser. There it is. And go
ahead and open this up. Okay, inside of here we want to click on
our progress bar. We can either do
that right here in the visual layout or
over in the hierarchy. You can select that
progress bar widget. And then over in
the Details panel, under the progress section, you can see we've got
this present value and currently it is 1.0%. Again, this meter
goes from 0.0 to 1.0. So if I left-click and drag
and move this to the left, look at the meter over
in the left-hand side, that green bar is
dropping down as I decrement this from 1.0 to 0.0. So that's all well and good. But how do we associate our health value over in our
bp ThirdPersonCharacter, this right, that,
how do we associate that over with this
particular widget? Well, we need to
create a binding here. And the way we can do that is with this progress bar selected, right where this
present value here is. You've got this
little bind option. Go ahead and click on this. We want to create a binding. It's going to jump us hear from our Designer tab over
to our graph tab. Once we do that, let's do this. Create a binding. And now what we've done is
we've created a function, is created a graph tab up
here called Get percent. We can rename this. I'm gonna do that now. And it's given us
these two nodes. Firstly, let's rename this. I'm going to click
on this, press F2, and I'm going to call this
Get Player health, like so. And then holding
Control, mouse wheeling. And let's zoom in on
this a little bit. What we wanna do is let's right-click in
some empty space type in get player character. We can drag off of this and
Cast to ThirdPersonCharacter. You've seen me do
this multiple times. Let's where this inlet so
why are the scene like so? And once we do this, we have access to all the
variables or functions, or we can call custom events inside of our
ThirdPersonCharacter. Well, we want to extract
that health variable. So let's drag out of here, type in, get health. There's that float
health variable. And look, this is looking
for a float inputs. We can plug in our health as extracted from our
ThirdPersonCharacter and return that. So we can compile and save this. All we're doing now is associating are
ThirdPersonCharacter is health variable
with this meter. And it's going to
drive this percentage. Maybe I should change the
color of this from lime green. Does something a
little bit darker. Let's go dark blue,
something like that. Make it a little bit more
visual here and compile save. We can click Play from here. Actually, let's do it from
our ThirdPersonCharacter. We can see this script working. Click Play from here. Okay? And we have created our health widget
upon beginning play. And now when I press the five key or health is
going to decrement by 10% every time we
should see that reflected in our health
meter up here as well. So here we go. 555-55-5555 by five,
all the way on down. And now check this out. Now that we have a
health float variable associated with our
ThirdPersonCharacter. And now that we have
that variable bound to that meter inside
of our WPP HUD. We can go back to the
very beginning portion of the course where we created this BP example
pickup and make it so that when our character
actually picks this up, that some of our character's
health is restored. So if you forgot where
that blueprint was, we had an in this
directory right here, content
scripting overview. I'm going to double-click
on this to open it up. Inside of here, we're going
to create a little space between our
ThirdPersonCharacter node right here and this
playing of the sound, so you can shove that
off to the right. Well, we're gonna do here. Let's try to frame this
all up so you can see it. We're going to drag out of
our ThirdPersonCharacter. We're going to get its health. That float variable. Well, we're gonna do then is add in amount of health
that we want to heal anytime we overlap
this blueprint. So we're going to add
another variable here. Let's call it health to add. This will also be
a float variable. We need to compile
this in order to give it a default value. So let's heel 20% of our character's health that
would be point to remember, our health is running from
a scale associated with our health meter
from 0.0 to 1.0. So 0.2 would be 20% health. We're going to
drag and drop this into our graph. We're
going to get that. We're going to add
these two numbers together, dragged out of here, type the plus button to bring
in an ad node, like so. And then we're going to drag out of our ThirdPersonCharacter and we're going to set that health. So here we're
getting the health. We're adding this amount of Health Anytime we
overlapped his pickup. And we're going to set that
as the new health variable. Again variables, you can
update their values. Alright, so that's gonna
be our script, right? There are updated script. Let's compile this
a little bit of a bonus here I want to
add to our health to add, go ahead and select
that variable. If you check this box
called instance editable, what this will do
is make it so that back in our level editor, we can actually modify how much health that this
particular blueprint can give. And we can change it for
each instance of it. So let's compile and
say that once again. And I'm going to
drag this out and I've got one instance of
it currently in my level. Let me go ahead and hold down
Alt, left-click and drag. So I've got two of them. And with the second one selected over in the Details panel, I've got this health to add
that's been exposed now once we check that box called
instance editable, I'm going to change the health
to add on this one to one. We're going to say that
that's the full health one. I can change the
scale here as well. Let's change it up to be 22.2, just to make that
very apparent that that's gonna be the full healer. Alright, so with that, this one right here is
gonna be the small healer. It's going to add 20% health. This one, we'll add 100% health. Let's go ahead and play this. And if you remember, if I press the five key, I can decrease my health. Or I'm going to overlap
the first one here. We're going to get
20% health back. Five key, little bit more all the way down and overlap
and the big guy, and we're all the way
back to full health. And so there you have it. Floats contain
decimal point values that can be positive
or negative. And oftentimes they're used
to hold time values or to hold a percentage
ranging from 0.0 to 1.0. Guys, that'll do to
offer this video, we will see you in the next one.
45. Name: Welcome back everyone. Our goal in this one is to learn what a named variable is, how to create one,
and how it can be utilized when a
blueprint scripting. So there's oftentimes
a lot of confusion in Unreal whether or not a name, a string, or a text
variable should be used. So over the course of
the next three videos here we're gonna be
talking about some of the subtle differences
between those three. So starting with
the name variable, name is a piece of texts used to identify something
within a game. Now we're gonna be
using a couple of name variables inside
of this video. Identify a level to transfer to. We're going to be transitioning from this level to another one. We're also going to be
using a name to identify a socket that we want
to attach a prop to. This could be
something like a sword to hand, that sort of thing. Now, a name, a
name is a variable that is case insensitive, and that means uppercase or
lowercase doesn't matter. In a named variable is used
for alphanumeric characters, that is all letters and numbers. Alright, we're gonna
get started here inside of our Level Blueprint. So if you don't already
have that open, you can come here and open
your Level Blueprint. And let's create a couple
of name variables. So under the My Blueprint panel, we're going to add a variable. I'm going to call the first
one level underscore 01. I currently do have it
as a name variable. However, if you
wanted to change it, right there is where
you can do it. There's the name. Alternatively,
with that selected over in the Details panel, you can change the type
right here as well. Now I want to create a duplicate of this variable and
call it level two. So a couple of ways
I could do this. Firstly, I could right-click on it and duplicate it that way. However, I could also do control plus D with
that highlighted. In order to create
a duplicate level, O2 is what I want to name this. Let's go ahead and
compile so that we can give these some default values. Starting with level one, I'm going to input my
level one as starter map. And notice how I spell
this all lowercase. Next go on to level two. And with this, set
the default value to be Minimum, underscore default. And I'm doing this in all caps. You do have to make sure
that you spell it correctly. Now if you're wondering why I input those as default values, it is because back here
in our level editor, inside my story
content maps folder, I have two maps that exists inside of this star
content maps folder. One called minimum default. Notice how it's spelled
just the M and the D are capitalized and then
a starter map level. And notice that the S and the M in the vet our capitalize. So I'm intentionally not using the exact same casing
with name variables. You do not have to have
the exact same casing. They are case insensitive. Alright, going back to
your level test map, go ahead and compile
and save that. And then in a graph
of your choosing, it could be the
default event graph or another graph
that you created. Let's go ahead and
create a simple script. I'm going to right-click
and some empty space type in keyboard so that I
have a keyboard events. I'm going to use the L key
because that would make sense for transitioning
to another level. I am way zoomed out
here holding down Control, mouse wheeling up. Let me zoom in on
that L key event. What I'm gonna do is
drag off of here, bring in a branch node. And if this is true, we want to open a level by name. And I'm going to duplicate
this Control C, Control V. And if it's false,
we want to open a different level name.
What level named? Well, check this out. It is looking for a name input. Now I could have hard-coded
this by just inputting this. However, I'm storing
these level names inside of these variables. So I'm going to drag
and drop level one onto here and level two onto here. So if our condition here
turns out to be true, we're going to transition
to our starter map level. And if our condition
turns out to be false upon
pressing the L key, we're going to
transition to level two. That's the minimum default. Now currently our condition
is hard set to true. However, if I was
to right-click and some empty space and
type in random bool. This handy node will simply
output a random ball randomly choosing
true or false every time we press the L
key, pretty handy. Here we go. Let's compile this and
save and give this a play. Alright, so pressing
the L key here, we should be transitioning to one of these two
levels. Here we go. And I get a travel failure. And this must be
because I must have not copied over one of
the names correctly. So level two here, Let's check minimum default. And if I check back into my Minimal defaults are high. We do have to spell
it correctly. I did spell it incorrectly. So let me go ahead
and fix that up. It's good to learn
from our mistakes. Minimal defaults. Leg. So Compile and say, let's try this once again. Again, it's case insensitive. It doesn't matter
if these letters, these characters are
capitalized or not. However, you do have to
have it spelled right? So pressing the L key, we chose level to that time. So we get this weird level here, going to exit out of here. So that was leveled
to those chosen in. Let's make sure Level
one works correctly. Stopping it playing once again, pressing the L key,
one was chosen, and there you go. Next we're going to use
a named variable to attach a prompt to our
ThirdPersonCharacter. So if you don't already have your ThirdPersonCharacter
asset open, come under content
third-person blueprints double-click on
them to open it up. And inside of here, find your mesh component. We need to do a little bit
of setup work before we even make use of
any name variable. We're going to add a sockets
to our skeletal mesh. So select your mesh and over in the Details panel come
under Skeletal Mesh. Click right here to browse to that asset in the
Content Browser. Then you're going to
want to double-click on this SK M Quinn, simple. And then in the upper right
you've got different tabs. Click on this skeleton tab
and what we wanna do is add a socket to our
character's hand. So this is our Skeleton Tree, all the different bones within
our characters skeleton. So I'm going to search
this for a hand. And let's add a socket to
our characters right hand. I'm going to right-click
on this hand. And with right-clicking
on that hand bone, we can add a socket. And we've just added a socket. That's the little icon is, I'm going to click
on this and I am going to rename it here. So the socket name
I'm going to set to be hand socket like so. Now, fun fact here
is you can add a preview prop so you can
see what this looks like. When something is attached
to the socket here, I'm going to right-click
on this hand socket. We're going to add
a preview mesh. And let's add a lamp, preview mesh like
a ceiling lamp. Obviously something
like a sword or a dagger would be better here, but we're not gonna be
too particular with this. I'm just going to
right-click in here, press the space-bar. You can see how this
could be positioned in such a way you could
move it here like so. I'm not going to
worry about being super careful with this. You can rotate it,
something like that. And again, you could
spend a lot of time fiddling where this
socket exists. We're offsetting this
relative to our hand here. So you can input some
numbers up here for the location and the
rotation, et cetera. Or you can fiddle with it here in the preview window as well. Again, I'm not going to be
super specific for this. For the time being. Let's go ahead and save this. And next, let's jump back to our ThirdPersonCharacter and create a couple
of variables. So jumping back to our
ThirdPersonCharacter, we're going to create a variable clicking this plus button. This one is gonna be
called sockets name. I'm gonna change this
to be a name variable. And I'm going to change
the default value here. If I compile, what did we
call that hand sockets, I'm just gonna do all
lowercase your hand sockets. And notice that
that's going to be not exactly the same
casing as how we did it here over in our skeleton. We call it hand socket
with the capital H and S. Back in our
ThirdPersonCharacter, we're just going all lowercase. Now I'm going to add one
more component here as a prop to attach to our socket. So let's pretend like we've
got a sort of source. I'm going to add a
static mesh components. And we will call this our sword, even though it's gonna
look like a lamp. And with that sword
components selected, that Static Mesh Component
over in the Details panel. Let's slot in as a static
mesh or lamp, ceiling lamp. I'm going to position
it very, very shoddily. Let me just turn off movement, Snapping right up here. And I am not going to spend
a long time on this at all. We're just going to go
something crazy like that. Sure. Like That. Looks like the buster sorted
from Final Fantasy. Sure. And then we're
gonna go over to our event graph and we're gonna right-click
and some empty space, I need an event key. Let's do the R inputs, or actually let's do keyboard. Let's see what we got for
available keyboard events. Let's go to zero key. Sure, That'll work. We're going to drag out
of this and attach. And what we're looking
for is attaching one component to another. I've got several options here. Let's do attach Component,
two components, sword. The sword. Whoops. That is a thing that
we want to attach. The parent is the thing that
we want to attach it to. In this case, it is our mesh. And remember, the mesh is the thing that has a
socket associated with it. So let's drag and drop our
socket name right there. So couple of things we need to fix up here is our location
and rotational rules. We want to set this to be
snapped to target, like so. So this should be our script. We want to attach our
sword, That's the target. We want to attach that
to our parent mesh. And where specifically,
well at are named socket and we set our
socket name as hand socket. So compile. Let's say, let's play. Now, look at that fine
sword on my characters bag. While it looks
terrible, let me press a zero key and boom, it is now attached it
to our hand socket. All thanks to that name,
variable, saccad name. Now let's summarize. A name variable is a
piece of texts used to identify something
within a game. Name variables consists of
alphanumeric characters, that is all letters and numbers. And they are case insensitive, meaning casing, capitalizing, or lowercase does not matter. Guys, that'll do it
all for this video, we will see you in the next one.
46. String: All right, welcome
back everyone. In this video, our goal is to learn what a string variable is, how to create one,
and how it can be utilized when
blueprint scripting. For this video, we're gonna be doing work inside of our bp, a ThirdPersonCharacter, that's the directory
where you can find that. So let's go ahead and
open this up right away. So as you may expect, you can create this String
variable over here in the My Blueprint panel
by either clicking Add variable or under
the variable section, clicking this plus button. And I'll create our first
two string variables right from the get-go here. This first one I'm gonna
be calling first Name. And once again, you
can change the type of the variable either from this dropdown string is what
we're looking to do here, or would that variable selected over in the Details panel
under variable type? And I'm going to duplicate
this right away. I can right-click
and duplicate it. Or with that selected, I can use that hotkey there, which is control plus
D. And I'm going to change this one to lastName. Then I'm gonna go ahead
and compile this so that we can give this
some default values. So for the first name,
I'm going to come under the Details section
and type in mr. With a period. And then I'm going to add a
whitespace right after it. Last name, I'm going
to add one drop. Alright? Now let's talk about what
is a string variable? Well, a string variable
is a variable that can contain any letters,
numbers, or symbols. Or strings are useful for dynamically manipulating text at runtime using some
ready-made functions and we'll explore some of
those later on in this video. Strings can be searched, they can be modified, and they can be compared
against other strings. Note, because of this, strings are preferable to
name variables if you want to manipulate text in some way
while the game is running. So strings are a little bit more expensive than name variables. But I mean, if you're running a smaller game or
even a larger game, I mean, the cost isn't
that much greater. Okay, So let's create our first
script that's going to be utilizing some of these
string variables. So here's some empty
space in an event graph. I'm going to right-click. I'm going to bring in, Let's try the seven key. Any keyboard event will do. Let me zoom up on this. And you've seen me use
this function many a time dragging off of
here, print string. So this node can take
in a string variable. Now there are many
things that can be converted into a string, but that pink pin right there, if you hover over
it, it says it's looking for a string variable. If I was to plug in
our socket name, it will convert it to a
string, will actually, if I go like this and drag
out here and say toString, I can convert that to
a string variable. Many other variables can be converted as well into strings. But let's show off our two string variables and how we can append them together. That is to attach
one to the other. So I'm gonna hold down Control, left-click and drag
in my first name and holding Control left-click. And I'm also going to get
my last name as well. As many names are presented. It's firstName
followed by last name. So a way that we can manipulate these two separate strings
is by appending them. So if I right-click in some
empty space and I come under the utilities section way towards the bottom
because it's all in alphabetical order. Utilities. We can come under
Utilities string. And at the very top there's a function called append that is to concatenate two strings
together to combine them. So we can take our firstName and append
the lastName onto it. And that'll give us
the final result. Like so. If I compile this, make sure my script is looking good here. Save, let's go ahead and play. Now when I press the seven key, you should see my first and
last name combined up here. Here we go. Seven, you see Mr.
wander all combined. Now in that utilities
string section, there are a lot of functions that can be used to
manipulate strings. Let me just find
another one here. I'm gonna drag off my
last name, like so. And I'm going to
type in two upper, again, it's going to find it in the utilities string section. I'm going to go like this, hooking this into the
B section as well. Now if I was to compile,
save, and play, what you will notice in
the upper left when I press that seven
key is notice how it changed the entire
last name string into all uppercase. So that's kinda handy as well. A lot of ways to
manipulate strings. That's one of the main
benefits of making something a string is all those different functions
to manipulate them. I'm going to show off
some of the other manipulating functions over in the Level Blueprint because I've prepared some prior
to this video. So I'm going to jump out of my ThirdPersonCharacter and go into my Level
Blueprint once again, that's how you can do that by clicking right there,
open Level Blueprints. Here I've got several
different functions. There are many more that we're
gonna be exploring here. Again, you can find that
by right-clicking and some empty space going under the utilities string section. Here, all the string manipulator functions you saw append. So if I was to, I'm going to drag and
drop each of these into my ready-made
function here, my print string function script that can fire off
with the S key here. So if I was to try this out, you can see how by
pressing the S key, I can append that dollar amount
after the texts of money. Pretty handy. Alright, let me get rid
of that guy and we will move time seconds to string. This is another
one I really like. What this will do, and I
prepare this one ahead of time, is I changed this float variable
to have a value of 500. So if I was to change
that into seconds, how many seconds is that? Well, this will do
the work for you. So if I press the S key now, you can see how that prints
it out in a nice time form. Let's delete that one out. Let's try splitting a string. So if this is my source string
July 4th with a comma 17, 76, and I want to
split it at this in STR, this little alright. Here, to the left of that
I will get July 4th. To the right of that,
I would get 17 76. So let's go ahead and
give this a try quickly. Splitting a string. I'm just getting to the
left of that comma, pressing the S key. July 4th. And if I was to hold down control and getting
to the right of that, now I would get that
actually it'd be a whitespace in 17 76, but you can't see
the whitespace, it's just going to show a 17 76. Now something cool you
could do here is we could convert these into variables that we
could change out. So you could
right-click on this, promote that to a
variable and call this independence date
independent state for the United States anyways, those internationally,
that would be some other date hopefully
for your independence, should you enjoy that luxury? And so in doing that compiling, you can see how we
created the variable in that fashion by right-clicking and we promoted it to variable. Note that it automatically takes that information that
you had hard-coded in that their function
in that spot and automatically populated
that string variable. So just thought I would throw
that out there as well. Let's look at another one
here, this replace function. You can also find this under the utilities strings section
and you right-click menu. Super handy because you could
see a scenario like this. And again where you've
got a source string that says the door is locked. You can change some
texts that you specify, in this case locked
to the text open. So that's another advantage
of these string functions. You have all these
different ways of manipulating the texts. So here we go. This should say is that the door is locked, I'm saying changed
locked to open. So pressing the S key, the door is open. And so there you have it. A string variable is
a variable that can contain any letters,
numbers, or symbols. They're useful
because they can be dynamically manipulated
at runtime. And once again, to find
all those functions right-click and you want
to come under Utilities. Way at the bottom here,
utilities string and you've got a whole host of functions to
manipulate those strings. Well, that'll do it
all for this one guys, we will see you in the next one.
47. Text: Welcome back everyone. In this video we're going to be learning what a
text variable is, how to create one
in how it can be utilized when
blueprints scripting. So this is the third out of
this category of variable, namely the name variable, the string variable,
and the text variable. What is the text variable
and when should it be used? Well, texts variables
should be used for any texts a user may
see during a game. Texts you may see
on an in-game HUD, or maybe some texts that
you see in menus or maybe on a high score
screen, that sort of thing. Use this type texts that
you want to localize. So if you're looking to
translate your game and all the text that goes
with that into German, French, Spanish, all
that kind of stuff. You're going to want to
make sure that that text is in the text variable type. Now, text variables
are case sensitive, whereas named variables
were not case-sensitive. They were case insensitive. Tax variables are
case sensitive. Alright, we're gonna be
doing a little bit of work inside of our WB P HUD. So that's where
you can find that we created that some videos ago. We're also going to be
doing a little bit of work inside of our
ThirdPersonCharacter Blueprint. So you can find that in the third person
Blueprints folder as well. So open both of those guys up. I'm going to start
off in my W BP HUD. Now, you may remember when
we did this some time back. All we did is we created
a horizontal box. And inside of this
horizontal box, we added a text widget as
well as a progress bar. Now, I have this thing
health for the time being, but I'm gonna change this
over in the Details panel. Do you simply say
character name? Character name. This is of the texts
variable type. In fact, if I hover over
this flag right here, you can see that this
is some texts that can be localized that
checkbox is on. I'm also going to change the name of this
particular widgets to character name or character
texts. How about that? We are talking texts
variables here. Just to make that a
little bit more clear. So what we're gonna
be doing now is E inside of our
ThirdPersonCharacter, I'm willing to be
creating a text variable. And I'm going to give
it the name that I wish to name our
ThirdPersonCharacter. So I'll hop on over there. We're going to create an association here
in just a little bit. But hop on over to your
ThirdPersonCharacter. And we're going to
create a new variable. And we're going to call this our character texts just
to make it extra clear. And we're going to change
this to a text variable type. We're going to compile that. And I'll call this my superhero. That sounds like a fine name. Now with this text
variable created, I'm going to compile
here and save. And now we're going to associate
this variable to our W, B P HUD so that we can actually read in this superhero texts. So jump on over to your WPP HUD. Select where it says
character name. And over in the Details panel where it says text
character name, we need to create a binding. I'm gonna do that by
clicking on binding. Create binding. And this is going
to jump us from the Designer tab over
to the graph tab. That's just what happened there. Designer tab takes you back
to this visual layout. Graph tab is where you
can create some script. And more specifically,
it jumped us over to creating a brand
new function. So right now our function is
called get character texts. Texts is zero, which
is a horrible name. What it's done is it's opened
up a brand new tab here. And here is the name of the function that we're
putting together. I'm going to rename this
by hovering over this. And we will rename it. F2 will also lie to rename it, and I'll call this
gets character texts. So now what we wanna
do out of here is much like we did with
our Get Player health. I'm just going to jump
over to that function really quickly by
double-clicking on it. We were getting our player character and we were casting to our ThirdPersonCharacter
so that we could get that variable information. I'm going to highlight
these two nodes, left clicking and dragging. I'm gonna do Control C.
And then I'm going to double-click on the
function I just came from. I get character texts. And then in here I'm gonna
do Control V to paste that. I'm going to wire this
through like this. And once again, once you have a reference to your
ThirdPersonCharacter, you can extract some
information from it, including any variables
that live inside of it. So I created that variable
inside of my third-person character here called
character texts. So back here to my WB P
HUD, inside that function, I'm going to drag out here
and I can do a search for a character texts. I want to get it and look at the return value that this
function is looking for. I mentioned that over in the Designer tab that this
particular text widget, we're binding this to
some actual texts. That's the output
we're looking for here in our graph tab. That's looking for the return
value of a text variable. So we're going to
plug this texts right into here. Like so. And if I compile and
save and I now play, you'll notice that
in the upper left, it now says superhero, the name of our character as we specified inside that
character texts variable. Okay, something else
I wanted to show off with a text variable
here is the way that you can format some texts
because I think a lot of you will find
this useful as well. Now in order to do what
I want to show off, we're going to jump back into
our ThirdPersonCharacter. And then we'll jump back
here into our WPP Hudson. Don't just close
this out just yet. Let's go back into our
ThirdPersonCharacter. Like so. Let's create a brand
new texts variables. I'm going to come under
Variables click plus. And I'm going to call this
one health status leg. So I'm going to change the health status default value to be something kind
of interesting. So we're going to compile here and watch what I'm
going to type in here. Let me expand this
out a little bit. I will put you have, and this is gonna be
a curly bro, sorry, curly bracket, not
straight bracket holding down the shift, left curly bracket, health. Right curly bracket holding
down Shift and pressing the bracket button,
HP remaining. Now while. Now why I have done this is because with our
text variable here, we do have the ability
to format our texts and change out these contents
right here to have this read, you have 100 HP remaining, you have 50 HP remaining, that kind of thing. Now the way that we
can do that is through a format texts node. So I want to format this. I will do some scripts
here and then it will bind this back to our WPP HUD. So herein are
ThirdPersonCharacter Event Graph. I'm going to right-click
and let's try the nine key. Any input key will do. Nike will work
just fine for now. And I'm going to
drag off of here. Actually, let's not drag
off of here just yet. I want to bring
our health status, drag that and we're
gonna get that. And then I'm going to
drag off of here and type in format text. Okay, so current leaves
only has one pin, but we're going to
add a pin here. And currently it's
labeled as zero. However, if I select
this format texts node, I can change up
here the argument that is gonna be this input pin. To be often this should be spelled exactly as we have a written in our health status. So I have capital H E, H E a L T H, health. Just like that. With your format,
text nodes selected change the argument there
to be the exact same, and that will show
up as an input pin on this format text node. Next, what I'm gonna do
is I'm going to take our health variable
here, like so. This is currently a float
and plug it in down here. Now this is currently gray, meaning it can take in anything. So I'm gonna plug in a float variable,
and so it will say, Okay, you want to
plug in afloat, this will now be a float input. It'll change it to whatever type of inputs you put
into it like so. And the result here, I am going to promote
this to a variable. Right-click promote. And it created this new text variable down here
called results. I will change this
to help result. I think that'll be a little
bit more descriptive. So now what we're doing here is when we're
going to press the nine key, we're gonna take our
current health status here, this sentence, if you will, we're going to swap out what
we specified right here, this health and
the reason we have this exact health in the
curly brackets is the exact same here in the arguments
is so that it will read that is the texture that
we're trying to swap out. And then the result here
will be the result of this line with the health being swapped out for whatever
this float value is. Now realized that this is
in a decimal point form. So we're gonna get
a value here, 0-1. And normally you
would want to read in 100 health, that
kind of thing. But that's going to be fine
for demonstration purposes. I'm going to compile this last bit I need to
do here is I need to bind this health results
overnight, WB be HUD. So in order to do this, I'm going to hop
back on over here. Let me go back to
my Designer tab. I'm going to quickly
drag and drop a text widget
somewhere about there. This is not asked to
be super precise. This is just gonna
be hanging out here. I'm not gonna show or hide
it or anything like that. I'm just going to call
this my health status. And currently if I was to
play this is just going to show us health status
on the screen. Like so, health status. However, I want to bind
this to our variable, our health status variable inside of our
ThirdPersonCharacter. So we need to create
this binding by going here, bind, create binding. And as jumped us over
to the graph tab, we're going to change the
name of this function, hitting F2 over here to
get health status like so. We're going to do like we did with our
other functions here, I'm going to double-click
on this other function. We're going to grab
these two nodes, control C. Jump back to our health status
function that we're working on, control v. Like this. And now we can do is find inside of our
ThirdPersonCharacter, make sure you've compiled this. We want to grab this
health result variable. I shouldn't change
this to Help Desk, I'm going to call this
health good health results. Let's be a little
bit more precise. They're dragging out of our third-person character
type in health results. We want to get the
health result, not the health status
of health results. There are two similarly named. And now, if I was to compile, save, notice that our
ThirdPersonCharacter, once we pressed the nine key, that's what we're going to
update our health result here. So I'm going to press
the play button. And once I press the nine key, you have one HP remaining. Now, somewhere here in
this ThirdPersonCharacter, I was decrementing our health. Well was that with the sick, the five key, right? So by jump back in here. And I'm pressing the five
key to lower my health. Now if I press the nine key, it should update this. Now I have 50% health, the five key lowering,
lowering, lowering. I shouldn't have 20
per cent health. So I'm going to press F9 key. Once again, you have
20% health as well. And I could format this
to be more sensical, but you get the point. And finally, I did make mentioned that any
user-facing texts, be it in the HUD
or in the menus, that kind of thing that you
want to have localized. It should be within a text
variable, that kind of texts. It should be within a text
variable if a user is going to read it in
different languages. Now, how do you go about
with that whole process that is way beyond the
scope of this video. However, I will point you to this particular
bit of documentation. In the Unreal Engine five
official documentation, you can come under docs
dot Unreal engine.com. You can see the
address right up here. A lot of information
about how to get texts localized with that guys. That'll do it all for this one. We will see you in the next one.
48. Vector: Welcome back everyone. The vector variable is
the topic of this video. So let's learn how to
create one and how to utilize one within some
blueprints scripts. So firstly, what is
a vector variable? Well, a vector
variable is one that contains three float values, that is numbers with
a decimal point. They're typically
used to specify x, y, and z 3D coordinate data. However, they can be
used to contain R, G, and B, that is red, green, and blue color data. Alright, to show off
a few examples here, I want to make use of
our Level Blueprint, but before you even
jump in there, let's make sure you've got a Trigger box place within
your level because we're gonna be making use of that to show off some use of
vector variables. So if you haven't
already done so, come under right here under
the place actors panel, with the basic tab selected, you can find a Trigger box. Go ahead and place one
of those in your level. And then all I did here was I set my box extends to be 200, 200, 200, line thickness of ten. And under the rendering section, I just turned off actor hidden
and games so that I can see this trigger volume
when I am playing. Alright, with this
Trigger box selected, then jump into your
Level Blueprint. Right away. What we're
gonna do is right-click. You've seen me do
this 1 million times. Now. We're going to add on
actor begin overlap event. We want something to happen when we overlap this Trigger box, and we want it to
happen only when the ThirdPersonCharacter
is the other actor. That overlaps us to
drag out of there typing Cast to
ThirdPersonCharacter. The first thing I wanna
do here is simply warp to another location. Now, in order to determine which location
we want to work too, we could hold that in
a vector variable. So let's come under
our variables section. Click the plus button
and let's call this our warp, too locale. And to change this to a
vector variable, once again, you can click here and set
it as a vector variable. Or with that selected
over the Details panel, you can change the variable
type to a vector as well. I'm going to compile here. And we can see that once we do, the default value is set to 00.0 and these are
decimal values. These are three float values. And you can see as I'm
highlighting over these, these are x, y, and z coordinates typically. Also you can click this
little down arrow to expand that and show
the x, y, and z. What I'm gonna do
here is set this to be a value that is above, up in the air, above
my trigger box. So what I'm essentially going for here is I want
to overlap this. I'm going to spawn
in right here. I'm going to overlap
this and then I want to warp to a location
that's right above it with the idea
that I'm going to fall somewhere down close to it. And then I can repeat
it again and again. So I'm going to copy
the location of this Trigger box with this selected over in
the Details panel, I'm going to
right-click right about here and copy these coordinates. Then I'm going to jump back
to my level tests map, Level Blueprint, come
under my warp to locale. And right here I'm
going to right-click and paste it to paste
in those same values. However, I want to
set my z value to be higher so that I'm not warping right back
into the same box. So I'm going to set my z
value here to be 2000. Know that depending on where
you place your trigger box, your values here
will be different. You just need to
know that your x and y can say the same
as your trigger box. The Z you're going to want to set to be a bigger
number so that you end up warping above
the bounds of that box. Now what we wanna do
here is when we overlap this box with a
third-person character, we want to drag out of our
ThirdPersonCharacter and type inset actor location. This is a function node
that can move your target. In this case, our
third-person character to a new location. And what do you
know we're storing that location inside of
this vector variable. So I can left-click
and drag and drop this right on top of
our new location. And I'm going to compile
this to make sure our script is looking
good here and it is, let's save it, and let's
go ahead and play. So once I overlap this, I should warp to a location that is above it
somewhere. Here we go. There we go. You can see I just keep falling down through it again
and again and again. Let me try to move
myself away from there. Infinite loop. But you get the idea. Now you can see how you could expand this script right
here at a sound effect, maybe smaller particle
effect at the location of where we overlap
that trigger box and at the warp to locale. But the location of
the Trigger box, that is an example use
of a vector variable. Now let's make one more use of a vector variable and use
it to specify a color. For this, I'm going
to left-click on this warp to locale
Control D to duplicate it. It'll duplicate that variable
and I'm just going to call this new color. I'm going to simply
add an input key here. Let's try the, I don't know the nine key and see
if that's available. The nine key, Sure, Any input event will do. And I'm gonna drag off this
and type in print string. And it's going to print
out the text Hello. However, if I expand this down, I can specify a text color. Now if I hover over
this input pin, it says that this variable type is a linear color structure. That's the type of
variable it's looking for. And we can create
one of those by right-clicking on it and
promoting to a variable. But the idea here
is I want to show off how a vector variable could be used to
specify a color. Now, if I select my new
color variable here and I compile so I
can add a value here. It's copying over the data that came from my
warp to locale. So let me just set
this back to 00.0. Now if you're using
a vector variable to specify an RGB color, you need to know that
these values would essentially run from 0.0 to 1.0. You're essentially specifying
what percentage of red or percentage you want of green and what percentage
you want a blue. I'm going to set my
new color here to be 1.0 for the r-value, the b and the g,
I'll leave as zero. So I'm essentially
saying give me 100% red, no green, and no blue. Now if I try to drag
and drop this on top of my text color is because
they Nope, can't do it. However, if I drag and
drop it in, I get it. And then I drag this into
the text color input. It's going to
convert my vector to a linear color structure type. Now in doing this,
I can compile, save, make sure
my script is good to go. Let's go ahead and play. Now when I press the nine key, you will see that the text Hello shows up in
red and that's being driven by my vector variable where I'm using that
to specify an R, G, and B color value. And there you have it. Common uses of vector
variables include using them for spawn
or respond points, or perhaps for starting and ending points of a
moving platform. And we'll explore that one
later when we do a lesson on making use of timeline nodes
within blueprints scripting. Guys, that'll do it
all for this one. See you in the next one.
49. Rotator: Welcome back everyone. The rotator variable is
the star of this video. So let's learn how to create
one and how it can be utilized within a
blueprint script. First of all, what is a rotator? Well, rotator is a variable that contains
rotational information. Now, objects can be rotated
around three different axes, the x, the y, and the z. And this can inform
how much we want a given object to be rotated, storing it within these
rotator variables. Now before we get to
any of that stuff, I just want to
point out here with any objects selected
in your level about how rotation revolves
around a given axis. So right now you
can see I've got my trigger Volume selected here, my trigger box, and I'm currently within
my movement mode, indicated by that
for arrowed widget. Now, if I was to switch
this over to rotation mode, we can see how if we rotate around the x-axis
are red arrow here. That involves moving like that. It moves around that axis. Likewise, notice our y-axis here pointed off
in this direction. If we were to change
this to rotation, we will be moving it
around that axis. Likewise, if we've got our z-axis here
pointed up and down, if we're rotating
around that axis, we're essentially
moving it like this. Rotating it like this. I need to be
grammatically correct. Alright, with that, I also made one more
change between videos in that I created
a brand new folder here and our scripting
folder simply right-clicked, created a new folder
and call it actor. Bp's. What I did here
is I moved all of my blueprints that were
in my overview folder. I simply drag and drop them, left-click and drag
them inside of my new actor BP's folder. Because that just seemed like
a more descriptive name. Overview folder. It's kind of outlived
its useful life. So I'm going to create
a new blueprint here inside of my new
actors BP's folders. By right-clicking, we're going to be creating
a new blueprint class. This will be an actor
class blueprints. So choose actor. And I'm going to name this
BP underscore rotating door. We're gonna be creating
some rotator variables inside of this blueprint. Firstly, let's go ahead and double-click on
this to open it up. And I don't want to add
a couple of components. So the first component
I'm going to add by coming under my
components section, is going to be a
box, box, box box. Let me just do a search
for box. There it is. Box Collision. And with that selected, I do have some details
I want to set for this over in the Details panel. I want to set the location
to be negative 45 and the z location to be 110. You'll see why here
in a little bit. Let's kinda up in
the air like that. Also, I'm going to
change the box extent to be 170 in the x, 60, in the y, in 110, in the z. So it's kinda tall,
something like that. Alright, with that done, we're going to add a
static mesh component. I'm going to add this. We're looking for a static mesh. And currently this Static
Mesh is attached to our box. We'll fix that in
just a little bit. I'm going to call
this my door mesh. Alright, with this selected
over in the Details panel, I want to set our
static mesh to be, click this little drop-down, S M underscore door. Now this is an asset that lives in the starter content
prompts folder. Honestly, you can use any
sort of door like mesh, but this one works well. So let's go ahead and use it. Side note here, this mesh does not have any
collision on it. I know you can just
walk right through it, but it's going to
be fine for showing off the rotation of a door mesh. Let's go ahead and place that. Now, I mentioned that this is currently
attached to our box. I'm just going to drag
and drop this on top of our box to make it so
it's not attached. It shouldn't be
too big of a deal, but just to play along
with me at home. Alright? Next one we're going to do
is we're going to create a couple of variables. So in the My Blueprint section, under the variable section
and click the plus button. We're going to call this
first one, the start located, start rotation, not
location rotation. We're going to change the
type here to be a rotator. Then I'm going to
select this once again and do Control
and D to duplicate it. This is going to be
art and rotation. So with that, we're
going to compile so that we can set
some values here, are starting rotation,
make sure you select that. We want it to be 00.0. Then go ahead and select
your end rotation. We just want our and rotation
along the z-axis to be 90. So, you know, if you open
a door at 90 degrees, you're essentially going
to be starting with it, like this is a bird's-eye view. And then the end is gonna
be kinda like that, right? It's just going to open
it. Swing this from here up like that with my mouse. That's nice, Mr. Waldroup. Alright, next,
let's go ahead and do a bit of scripting
in our event graph. So we have some event
nodes here by default, we can left-click drag,
get rid of these. And now we want
something to happen when we begin overlapping that box. And then when we end
overlapping that box, and that is this box
right over here, I jumped over to
my viewport tab. So let's go back
to my event graph. I'm going to right-click
on my box component. We're going to add
an event for when we begin overlapping it. And then let's
right-click on it again at event for end overlap. Now we want to
specify that it is the player character
that is overlapping us. Now, I could cast to my
ThirdPersonCharacter. However, there's another way
I can go about doing this. So I'd like to show off
different techniques. I'm going to Right-click type
in get player character. And what I'm gonna do
here is check to see if the other actor is equal to. I'm just going to type
in the equal symbol. If that's equal to
my player character. If they are equal, I'm gonna hold down
the B key and bringing a branch node like so. Other actor is equal to
my player character. What I wanna do is
rotate the door open. Now in order to do
this, we're gonna be making use of a timeline node. Now I've got an
entire video later on in the course that's
gonna be dedicated to this. So we're gonna be jumping
the gun here a little bit. This video is not about
creating a timeline. So if you don't even fully understand what's
happening here, just bear with me. Even though I'm
gonna do my best to explain it as
quickly as possible, right-click and some empty
space and do a search for a time line node. Once you type in
the word timeline, it's gonna be weighed the bottom here for adding a timeline. And this is a very special node. And one of the things that's
going to allow you to do is give it a name. I'm going to call this
my door rotation. You can see it's got
a lot of input pins, a lot of execution input
pins where we can play it. We can stop at this node, can be double-clicked
upon in order to specify an animation
of this is a timeline. We're gonna be animating our
door over a given timeline. If we double-click on this, we can add a timeline
to our window here, so I just double-clicked on it. We've got our door
rotation timeline node right up at the top here. We want to add a track. We want to add specifically
a float tracks. If I go into track right
here, click the Plus button. We want to add a float track. A Float Track allows us to change a float
variable over time. So we're adding a Float Track. We can rename this track and I'm going to call this rotation. Now what I wanna
do is I wanted to specify some points in time. So the way I can add a point to this graph is by right-clicking
and adding a key. That's one way to add it. And with this first point, added this first keyframe, as it's called, I'm going
to specify a time of zero. A value of zero. Hit Enter. And that's going to place
it right here in my track. Next, I'm going to right-click
again at another key. That's a way I could
do it, or I can hold down the Shift key
and left-click. That's another way to add a key. I'm going to select this key. And I'm going to set
the time at one, meaning 1 s, and
the value at one. Now it's going to jump it off
the top of the screen here. But if you click these arrows, you can frame it up like that. Now I also want to change
the length of my track here to currently be 1 s as opposed to 5 s.
That's essentially specifying how long I
want this track to be. I want this to be as long
as my last keyframe here, I want this to be 1 s. So what essentially I'm
gonna be doing here is I'm going to be changing
the value of a float variable named
rotation from zero, a value of zero
at 0 s to a value of one 1 s later it's
going to be slowly, gradually changing that
0-1 over the course of 1 s. Now this rotation
float variable, if I jump back to my
event graph here, notice this is called rotation. You can now see that my door rotation
timeline has an output, and this output
is a float value. It's going to output
this float value. And again, if I jump back into this timeline by double-click on it, double-clicking on it. I'm going to be changing
the value of that 0-1 gradually over 1 s. Now this is useful
because we can use this to drive something
called a loop. So if I right-click
and some empty space, I can do a search for
a node called rotator. Now this is going to
be confusing at first, but I'm going to
describe how this works. Alert node allows us
to go from one value to another over a
given amount of time. And in fact, if we rotate or if we mouse over
the top of this node, it says we're going to
linearly interpolate between a and b based on the Alpha
value that we provide it. So it's going to work like this. A rotation is gonna go 0-1. That's the value. It's
going to go between 0-1 over the course of 1 s. When Alpha is zero, it's going to read
in the value of this node are starting rotation. Note that our starting
rotation is basically 00.0. Now, as our rotation
value here goes 0-1, we're going to gradually
be moving from our a value, our b value. So as our rotation
here goes like this, 0-1 over 1 s, it's gonna be continually
moving away from a to B over 1 s from 01 is
going to move us from a to b. So our end rotation is going to specify our ending rotation. We're starting at this rotation. We're ending at this rotation. Now this is all well and good, but the return value
here needs to be plugged into set relative
rotation function. Or we're gonna be doing here
is saying, hey door mesh, that's the component
that we want to rotate, drag and drop that in our graph. Then drag out of this. We want to set your
relative rotation. That is changing your rotation relative to where from
where you started. So our final setup is
going to look like this. Let's walk through this to understand this a little
bit more thoroughly. Now upon overlapping
that trigger volume, we're going to find out if it is the player character that
was the overall factor, the other actor
that overlapped us. If that's true, we're going
to play, play this timeline. It's going to go 0-1,
a rotation value if float value over 1 s. And as it's doing this, changing the value of
this variable 0-1, we're gonna be going from our starting rotation to our end rotation over
the course of 1 s. That's what this is doing. And the return of this going
from a to B is going to be telling our door mesh to
rotate over that one seconds. Let's go ahead and
give us a tribe. We won't even worry about
our end overlap for now. But in order to do
this, we need to drag and drop this
into our level. Let's drag and drop
this into our level. I'll place it right over here. We're gonna go ahead
and click Play. And you know what? In order to do this, I should make sure we are doing this in a new
editor window like so. And also, I'm gonna do
this from inside of our, our blueprint here so you
can see the script at work. So let me just kinda
tuck this way up here. We're going to click play here. We've got our debug setup
to a rotating door. Bring it on our
Playing window here. And as I overlap this, you can see it rotated
it 90 degrees. Now, as you can see, once I get away from that
trigger volume, it doesn't set it back
or anything like that. And it's already set the
rotation of this to be open. So it's open. Now I want to make this close. We just need to tap into a similar setup like
we've got right here. So what I'm gonna do is I'm
going to drag out a here. Type in the equal sign. Once again, we're
going to find out if other actor is equal
to our player character. Once again, we're going to copy our branch
control C, control V. And if this is true that the other
actor ended our overlap, if that's true, we're going
to reverse this timeline. We're going to reverse
that door's rotation. So let's compile this. Save in play. Going to take this
away over here so you can see the script firing off. Alright, So timeline is played. Then let's end our overlap. Watch for the
script to fire off. Open Sesame. Lows,
just like that. And so there you have it. In this video, we use
the rotator variable to specify a starting
location for our door mesh, as well as an ending
rotation for our door mesh. It's as simple as that guys that'll do
it all for this video. See you in the next one.
50. Transform: Welcome back everyone. The transform variable is the one we're dealing
with in this video, we're gonna show how to
create one and how it can be utilized when
blueprint scripting. Now an excellent use of the transform variable
is when you are specifying a point within a level that maybe you
want to respond at. Now, transform variable is a variable that
contains location, rotation, and scale data. In fact, if you look over
in the right-hand panel, in the Details panel
for any actor that you have selected
within your level, you can see some transform
information about it. In fact, if I select my
player start actor here, you can see the
location specified, the rotation of
it, and the scale. So this essentially
is a variable that consists of nine float values, three each in the location, rotation and scale nine total. Now, in the interest of time, I set up a bunch of stuff
prior to shooting this video. So let me show you what
I've done and I'll walk you through
this step-by-step. For starters here I
have my player start actor located right there. As with many other videos, I have a trigger box
added to my level. And as long as you've
got your player, your place actors
panel available, which you can bring
on right there. You can grab a Trigger
box right there. And then I also have three
target point actors, 12.3. And you can find these
guys if you search in the place actors panel and
just search for target, you will find a
target point actor. These are essentially excellent for specifying a point in space. These icons will not show
up while you're playing. However, when you select them, you can see their location. Use their location or their
rotation data as well. And I like to use them
for those purposes. Now, jumping into
our Level Blueprint, let me show you the script
that I've put together here. So let's check under
our Level Blueprint, starting with our setting
a random spawn points. So this whole video, we are going to be making use
of a transformed variable. So what you wanna
do here is over in the My Blueprint panel under
the variables section, click on the plus button and
create a brand new variable. It should be of the transform
variety right there, and I call it respond point. Now if you compile it, you're going to find
that your default values are zeros, zeros, zeros, and the scale is 111, essentially the true
default values. Now what we're gonna be doing here is upon beginning play, upon our play starting, you can find this by
right-clicking and doing a search for
Event Begin Play. We want to set our
Respond point, that is to populate
it with some data because we don't want to keep the location and the rotation, all this kinda stuff
at zeros, zeros, zero. So what are we going to set
this value to that again, variables, the contents of it can be changed, they can be set. So what I did here, I grabbed a reference to
all three target points. Now I name these target points, target 0.0, target 0.1,
and target point to. And then what you can
bring in references to these is back in your level. You can select it and then
one-by-one with it selected, you can hold down the R key
and left-click, like so. Fun trickier. If I was to select all three of these
target points there, they're all selected and then
hit the RT and left-click, I can bring in references to all three of them right away. Nice trick. I like that one a
lot. Then what I did is I dragged
on each of these. And I said, give me
that actors transform. I'm saying, give me, give me this data right
over here for each one of these given target points. Then what I did is
I drove out of here and I typed in make array. So essentially I'm creating a list of different transforms, different transform
data from target 0.0, target point, and target 0.2. So I have a list of three
possible transforms. What I then did is I
drug out of here and I typed in gets and I wanted
to get a reference, that guy right there. And then I drag out
of this backwards and I typed in random
integer in range, I am saying give me one of these transforms from this
list and make it 0-2. You may need to adjust
these numbers depending on how many different target points you have plugged
into this array. So I'm saying give
me either 01 or two, That's my range, zero to two. And the output of this, I am going to set as
my respond point. So it's going to be changing
upon beginning play. We're going to update
our respond points to a given location. One of these three, it's going to pick at random. Now that's just setting this respond points,
this transform variable, but we haven't actually
gotten and made use of this respond Point Transform. So down below, I have
an additional script. And it should be as follows. What I did here is on beginning overlapping that trigger
box and once again, with that trigger box selected back in your Level Blueprint, you can right-click
at an event for that and do in an
actor begin overlap. We can drag out here and then do a casting to our
ThirdPersonCharacter. We want to do something when our ThirdPersonCharacter is
overlapping that trigger box. And what we're doing here is we're doing a
couple of things and that's where a sequence node comes in, where they
sequenced the other. We can say do this,
then do this. And we can actually
add additional things if we click this plus
button down here. But it's essentially a nice, tidy way of saying do this, then this, then anything
that comes after it. So the first thing
we wanna do after our ThirdPersonCharacter
overlaps Is Trigger box is we want to destroy our current player character, our current
ThirdPersonCharacter. We wanted to destroy him. Then what we're going
to be doing immediately afterward is spawning
an actor from class. Now, note that this is a
spawn actor from class node. However, once you populate the class to our
ThirdPersonCharacter, it's going to update
the name here, but this is a spawn
actor from class node. Now what you need to
do here is you need to specify a spawn transform. And this is where
we're making use of our transform variable that we created and we're populating, we're back here
when we begin play. Without this. If you compile, it will throw an error and let me
just actually do this. I'm going to break this, holding down the Alt
key and left clicking. So if I was to compile,
it's going to say, Hey, you need to have
a spawn transform plugged in so we can go
ahead and plug that in. And then what we're
doing out of here is we right-click in some
empty space type in get player controller. And out of this, and it must be out of this. If you drag out of this because the target
is a controller, you can search for
this possess node. By possessing, by dragging out of there and
grabbing a possess node, you can choose a
pawn to possess. Here we're spawning a new
ThirdPersonCharacter. Here we're saying, Hey, we want to spawn or
we want to possess that ThirdPersonCharacter
with our player controller. We'll talk more about
player controller's later on in the course. Let's go ahead and compile here. And this is our
script for destroying the player and then responding another, end possessing it. So that's all framed up here. If you want to pause
the video here and take a good look at
that, there you go. Okay, let's go ahead
and play again. And let's see this in action. This is gonna be a
little bit small here. But hopefully you can see some
of these wires firing off. Let's go ahead and play. And we've already
set a respond point. Let me go ahead and set my debug object there to my level. Now, once I overlap
that trigger box, you're going to see us
destroying the actor. And then immediately
after spawning a new ThirdPersonCharacter and
possessing it. Here we go. And it shows that point
beyond behind the level. And it's currently choosing
that same one again, again, because only upon beginning
play are we setting our transform variable to one of these three
target points. However, if you were to
do something like this, drag out of here, drag right back up here. Every time I overlap that
trigger box and I am resetting, I'm choosing at random one of these three target
points that I want to set my response variable to be. So let's try that. So overlapping. I spawn behind it. Let's run into it again. Off to the left,
that time behind. Again, this is
choosing it at random. There's something else I
want to show off here with. The transform variable
is you can actually extract that unique location, rotation, and scale data. Now, this transform variable
contains all of this data. But if you wanted to extract just a portion of
that data, you could. And the way you could
do that is by dragging out of this pin right here
and typing in splits. Let me just break
this wire here. Rather right-clicking on it and things split the Struct Pin. Sorry about that. Here we can break our respondent points transformed down
into the location, the rotation, and
the scale data. And as you can see, a transformed
variable essentially consists of vector data, rotator data, and vector data. Likewise, out of
this spawn transform here in our spawn
actor from class node, I could right-click
on this and split this pin is well
into the location, rotation and scale data. If you don't like this
level of granularity, you could right-click on a
these pins and recombine that back into just one
singular transform. Recombined, struck pin
is what that's called. So just thought I would throw
that out there as well. So there you have it. A transform, a
variable grade for something like specifying
a respond point. That'll do to offer
this one guys, see you in the next one.
51. Actor (Object): Welcome. In this video, our goal is to learn what an actor,
a variable is, how to create one,
and how it can be utilized when
blueprint scripting. Now full disclosure here, this video is very much
going to be a review of our class BP runtime object references video that we
did earlier in the course. Now if I jump in and play here, this is going to serve as
a little bit of reminder. When we press the arrow key, this is what we
scripted in that video. When we press a zero key, we were sending out a line trace into the world like that. And when a hidden object
in the upper left, it's showed the name of that
thing that we are hitting. And once we set that
actor a variable, we can then press the nine
key to make it disappear. Now in doing so, while
we were doing is setting an actor variable anytime our
line trace detected a hit. Now let's jump back to our bp ThirdPersonCharacter
located in our third-person
Blueprints folder and see the scripts that we
put together there. So what we're doing here is
upon pressing some input key, I was using the arrow key. We were sending out a
line trace starting at our actors location and ending at our line
trace endpoint, which was a variable that we had created over in our
components section here. It's in our viewport
right over here. This is an error component
that also is listed as a variable under your
components line trace endpoint. That's what we named
that arrow component. So you're starting a line
trace at our actors location. We're ending it at that arrow. And we're sending that,
that line trace out into the world along the
Visibility channel. We also have this Draw Debug
type set to four duration. So we can see that line trace. And if we detected
that we hit something, if this indeed did
hit something, that return value
turns out to be true. We're going to play a sound. And then we're also going
to break out the hits here. That's what this is all doing. We dragged out of here and
we're breaking out the hits. And we were finding
out what it is we hit. And we're setting that inside
of an actor variable type. Now, we could create this
by either right-clicking on here and choosing promotes two-variable in that
right-click menu. Or the way you can create an actor variable is over
in the variable section, you could click the plus button and just type in actor var. And then here it's setting it to actor right away because that's
the last variable I said. But you could do a
search for actor. And in the object
types you'd want to choose actor object reference. Now let's talk about what
are valid object references. Well, example objects
could include lights, it could include static
meshes, cameras, sound cues, or other
blueprint actors. Here we are just detecting what we hit and setting
that as our actor. It doesn't really
matter if it is a static mesh chair versus
whatever this thing is. Whatever that mesh is, it
doesn't really matter. Whatever our line trace
is colliding with. It's going to set that
as our actor variable. Then we're just
printing out the name of that to the screen. Now, the reason we were
storing this inside of an actor variables because once our line trace hits
something and it sets us, we want it to be
able to destroy it. And that's what this script
was doing down here. Upon pressing the nine key, we were then finding out, hey, what's the contents of this Hit Actor variable,
this actor variable? If that is valid, meaning
there is something in it. If that is valid, we
want to destroy him. So the contents of this
Hit Actor could change. Let me just go and demonstrate that I'm clicking play here. And again I'm going
to press the, let me just set my debug object. Here's my b, my
ThirdPersonCharacter. Bring on my character
once again. So I'm going to send
that line trace out into the world by
pressing V zero key. And then in the upper left
here you're going to see the name of the thing that
I'm hitting. Zero key. I'm not close enough. Gotta get a little bit closer. There we go. Stat, preview, mesh,
whatever that is. So if I hit the Nike, that's obviously going to disappear. But if I said to replay that scenario and kinda
do the same thing, I'm going to start off hitting the zero key here
is setting that. However, I can
reset the contents there by coming to this
chair pressing the zero key. So now if that is what is
set as my hit actor here. So now if I press the Nike, it's not going to destroy this. It's going to destroy
my chair because that was the most
recently set Hit Actor. Here's the Nike, boom By Chair. Now, just to show off that this actor variable does not
have to be a static mesh. It could be something
like a light. I'm going to set this
from another blueprint. And also just to
show off that you can set this from
another Blueprint. So I'm gonna go back
to my level here, and I'm going to place
a light in my level. You could place when in
your place, actors panel. Here's where you can
find the lights. Or alternatively
you can come under here and then the lights flower. You can add a light by this
means point light will do. Let's just drag and drop
one of these in our level. I'm just going to
make this sum of noxious colors like pink. And then what I'm gonna do
is I'm going to jump into my Level Blueprint,
open Level Blueprint. And we're going to
say that when I press some key inside of here, and let's see what kinda keys
have got available here. I've only used the one key near, so let's use the two key, right? I'm in my event
graph right here, we're going to Right-click
type in the two key. Let's go do a search
for keyboard. That's how you can find these keyboard events
really easily. Hit the two key. And
upon doing that, we're going to right-click
gets player character. Then if we drag out of this, we can pass to our
ThirdPersonCharacter. Again. Once you have access to
your ThirdPersonCharacter. And yes, I do realize I have a character reference stored
over here on the left. I could use that as well. But once I have that, I can drag out of here and I can find this Hit Actor variables
so long as that has been created and
I have compiled. So again, we're trying to
extract this actor or a variable and set it from
our Level Blueprint. Let's drag out of here,
type in hits actor. We're going to set
the Hit Actor. And what do we want to
set the Hit Actor to? Well, if I hold down the
R key and left-click, I can set it to be
my point light. Let's understand what
I've got going on here. Let me compile this quickly, make sure that
scripts good to go. So from the Level Blueprint, I'm reaching over to my Character Blueprint whenever
I'm pressing the two key, and I'm going to set
the actor variable inside of my ThirdPersonCharacter
to be the point light. And then inside of my
ThirdPersonCharacter Blueprint, I'm going to then press
the nine key in order to destroy the contents of
that Hit Actor variable, which in this case it would be populated with that point light. So let's go ahead
and give us a play. I don't really have a good
means of showing off both, actually, I can show
off both of these. Never mind. I'm gonna play here. So we're starting in our
level test map right here. I'm going to set my debug
option to be the test map. Okay, So let's find out light. You can't see the light icon, but you can see that light on the floor so you
know it's there. I'm going to press the two key. So that's going to populate this actor variable
with the point light. Alright, that's now been set. Now let me jump to my
ThirdPersonCharacter. And once again, I've got to
bring this window back on. Whoops, see, there we go. So now when I press
the nine key, Watch this light disappear,
and there it goes. So in this video, you have learned how to
create an actor variable and how it could be set and
manipulated in some way. And we even did some cross Blueprint communication as well. What could you use
something like that for? Well, imagine like
a crafting system in a game where maybe you need to interact with some harvestable items
out in your world. And your object, your harvestable object
could be whatever your character is
closest to a flower, a piece of wood, that kind of thing
can always be set as your harvestable actors that you're trying to interact with. Alright guys, that's gonna
do it all for this video, we will see you in the next one.
52. Variable Things to Know (Part #1): Alright, welcome back. In this video, our
goal is to learn some important
things to know when working with
variables in unreal. Now these aren't really
Tips and Tricks per se. They're more an explanation of some key concepts in
variable options, you should know about things like how to initialize
a variable, how to set a variable
to public or private, and even what that means. And how to expose
the variable to cinematics or when spawned. First of all, we're going to be talking about variable
initialization. And to demonstrate this, I'm going to be working inside of my ThirdPersonCharacter
blueprints. If you forgot where that guy is, I access it in our third-person
Blueprints folder, there is your BP,
third-person character. So what does it mean to
initialize a variable? Well, that means to give it
an initial value in some way. Now oftentimes we
give a variable a default value when we create the variable,
but not always, we can initialize and otherwise empty variable when
an event occurs, this could be an overlap event, it could be an input event, something of that nature. Consider this example
that I've set up prior to this video in
my ThirdPersonCharacter. So first of all, I created in the My Blueprint panel a
variable called warp to locale. And it is of the
vector variable type. Now what I'm doing here is
I took event begin play. Remember you can
only have one event begin play in a graph here. I added that. And what I'm doing is as soon
as we are starting play, that's when this character
is spawned in my level at my player start
locale right there. When it's spawns in, we are just simply getting
our actors location. In this case, our
ThirdPersonCharacter. And we're setting
this location as the coordinates inside
of this vector variable. So by default here, my values for this warp to
locale variable are 00.0. However, once I begin play, the contents of this
are initialized. They are swapped out to
my actors location where my third-person character
is spawning in. Then over here, I'm simply
adding a bit of script to make use of this now initialized variable,
this populated variable. Once I press the number
key on my keyboard, I'm going to set
my actor location. That is this blueprint, that's the target actor self
to this given location, the warp to locale location. So check this out
back in my map here. I placed this chair right
near where I am spawning in. Because remember,
we are a character spawned in right
at this location. Upon beginning play where
our character responds in, we're going to set our
actors location as the place we want to warp to
our new actors location or, well, our third-person
character is accurate location. So essentially
what's at play here. Now, this variable has
already been initialized even before I set my
debug object here, so that already occurred. And now once I get
this back in place, you're going to see, I'm
going to move off this point. But this warp to locale has been set at the spot that
I've spawned in. And so whenever I
press the number key, the a plus number of key on
my keyboard, the plus symbol. It's gonna go right back
to that spot because that's the initialize location. Plus button, doesn't
matter. Plus button. Very habit that is initializing a variable to assign
it an initial value. Next, let's talk
about public versus private variables and
what that even means. And for this example, I'm gonna be using my
BP example pickup. I have one of these placing
my level and then I've double-clicked on it to
open it up, up here. So if you remember
from an earlier video, we created a health to
add float variable. And over on the right hand
side over here where we've got this close eyeball for some of these other variables
for the health to add, we simply click this to
show that eyeball icon. And in doing that, that made this instance editable
field have that checkbox. So this checkbox equals
unexposed eyeball over here. So it doesn't matter if
I click this to close. It's going to set this
instance editable checkbox to be false. And if I click this, it's going to set that to be on. It doesn't matter which
of these you toggle, you're toggling
the same property. Now with this on. And you can see from
the tool tip here, it's saying that this is a
publicly editable variable. What does this even mean? So once you have set that, you compile this, you come
back to your level editor. For any instance, that
is for any copy of this, this blueprint added
to your level. That variable that you've set to be publicly editable is now accessible once you
have that object selected over in your
details panel, check it out. This healthy add variable
can now be modified for each instance
of this blueprint. If I was to hold down Alt, left-click and drag, I now have a second instance of this
blueprint, MI level. So for this instance
of the blueprint, I could change my health
to add to be 0.5. While on this instance
of the blueprint, I could set it to be
point to that being 20%, this healing 50%. That's how we had that setup. So that is a public variable. It is equal to this instance
editable field right here. Now, down a little ways from this instance, editable field
is this private option. If we check this box
on a given variable, what we've done is we've made
it so that this variable cannot be modified from
external blueprints. So what I'm gonna do here is
I'm going to compile this. I'm going to save,
then I'm gonna go into my Level Blueprint here. Notice I've got my
BP example pickup, one of these selected, it's fine. Either one
of these will do. I've got number
two selected here, but either of these will do. I'm going to jump into
my level blueprint. I'm going to hold down the R
key and left-click to bring in a reference to that
example, pick it up. And now I'm gonna
do a search for that variable called
Health to add. And here we go. I'm going to drag out of this
and type in health to add. And you can see, I can't
even find it here. It doesn't show up because
it's set to private, meaning I cannot
modify or access that variable at all from an external blueprint
like the Level Blueprint. However, if I was to go back into my BP example pickup here, I'm going to uncheck this. I'm going to compile, save, and go back into
my Level Blueprint. I'm going to drag out
of here and type in health to add and there
I can get or set it. So the weird thing
is here is you can have a variable that
is set to be public. That is, you can access and
edited from the editor. You can also set it
to be a private. Those are not one or the other. You can have it set to both. That confuses a lot of people, but it could be
set to be public, meaning you can edit
it from the editor. And it can also be
set to private, meaning that once it's set
to private and you tried to drag out of it saved
from another blueprints. You cannot find or
access that variable. Why would you want to do that? Well, it could just be a
fail-safe to ensure that you don't modify something
that you didn't mean to. Next, let's explore
this exposed on spawn option that you find on variables. What does that do? For this? I'm gonna be using
our bp rotating door. We created this actor
class blueprint when we were exploring the
rotator variable type. And if you forgot where that is, this is inside of our
actors a BPS folder. We moved it all. We
moved all of these after class blueprints from
our overview folder to our actor BP's folder. Inside of here, go
ahead and select your end rotation
rotator variable. And in the Details panel, we want to set this to
be exposed on spawn. Now, when you go
to compile this, it's going to yell at you. And when it does, it's gonna
say, hey, that's great. You marked it as
exposed on spawn. But for this, we also need to mark this as instance editable. So go ahead and do that as well. Both of these need to
be checked to show off are exposed on
spawn feature here. So once both of those are
checked, compile it again. And then what we're
gonna do is we're gonna jump on over to our
Level Blueprint. So if you don't already
have that open, Come here, open Level Blueprint. And we're gonna set
up a simple script. I'm going to right-click
in some empty space. Any input event will do. I'll just bring in F h because that seems like
a fine input of m. We're going to drag
off of here and do spawn actor from class. Now remember with
these nodes you do need to feed it a
spawn transform. So I'm just going to
grab the transform. Let's grab the transform of our players start actor here I have that selected in my level. So with that selected, going back to my Level
Blueprint holding down the left clicking to get
a reference to that. Dragged out of this
yet actor transform. We'll plug that in. And what do we want to
spawn at that location? Well, we're going to spawn
one of our bp rotating Doris. I'm going to scroll
on down here. Where does that
rotating door there it is BP rotating door. Now, the moment I did that, I set that as the class
that I wanted to spawn in. Check this out. My end rotation
variable has been exposed upon this
spawn function. So here we can set the rotation to be something other
than the default value. Now I had set so that the
door would open 90 degrees. Meaning it would open. A door normally opens, but I can open it
even more here. So let's go ahead and try that. And I'll set that to be 135. Now if I was to go
ahead and play this, going to click Play up here. And I'm not even going to set my debug option here to show
this script firing off, just trust that it
well, I'm going to move off of this player
star right here. So removing off of this, I'm going to press F8. Boom, that Doris bonding, albeit a little bit
higher than being placed perfectly on the
ground with that's perfectly fine that it's
floating in mid air. I'm going to overlap
that trigger volume. Remember there's a trigger
volume is going to detect when my characters overlapping
and when I overlap it, it opens more than 90 degrees, it opens 135 degrees.
So there you have it. Expose on spawn, you've got
to have that checked as well as instance editable checked
in order for that to appear. When you spawn actor from class.
53. Variable Things to Know (Part #2): And lastly, I wanted to
show off this exposed to cinematic checkbox that you find on some variables,
not all of them. And I'll explain which
ones you can and cannot find it on later
on in this video. So for this example, I'm once again inside of
my BP example pickup. In the My Blueprint panel, I have created a new
vector variable. I've named it scale. And after I've compiled, I've set my scale to be 11.1. Let's go ahead and
check this exposed to cinematics checkbox as well. Then go ahead and compile. Now to show off what we
want to show off your exposing this variable
to a cinematic. We need to add a
cinematic to our level. Not to do that, we're
going to jump back to our level right up here
along the toolbar, you've got this little
clipboard icon. Go ahead and click on this, and we want to add a level sequence that is a cinematic. Let's
go ahead and do this. And once we click on
this, it's going to say, where would we like
to save this asset? Let's put it inside
of a new folder. I've got scripting
selected here. I'm going to right-click. I'm going to create a new
folder, call it sequence. Actually, I'll call it
cinematics, like so. And I'll leave it at
new level sequence, that'll be my name shore. And once I do this,
I'm clicking Save. I've now added a new
actor to my level. It's called new level sequence. It is of the type of a
level sequence actor. And also next to my
content browser here I've exposed a new window
called sequencer. Now what this whole window
enables you to do to modify something over time to
create a cinematic of sorts. So in order to do that, we need to add a track. So if I click this
track button down here, I want to add an actor
to my sequencer here in, in the little flower menu, I can choose an
actor in my level. Notice that all of the
actors here also exists in my outliner and the
far upper right here, I want to add my
BP example pickup. I've whittled it down to just
one in my level currently. So I'm going to add that. And now I can click this Plus
button right here to drill down further inside of my BP example pickup
and look at the bottom. I have a scale property that has now been exposed
to a cinematic. This sequencer is a cinematic. Now on this little fly out, I see that it is a vector
and I can modify it. I can choose x, y, or z. It doesn't matter which
one of these you pick. I'm going to choose x here. It's going to now expose that variable to this
timeline, to this cinematic. And if I click this
little drop-down, you can see I can
now modify the x, y, or z of that vector
variable over time. Now this scale currently is
showing in frames per second. That's what this 30 FPS means. We can modify this either frames or what I like
to do is click on this. And I like to change
this as a time instead. So Showtime as seconds, like so. And now to me this is a
little bit more sensical. I can change things from 0 s currently up to 5 s. I
can expand this out as well, but we're not going
to create one. That's quite that long. Alright, so what do
I wanna do here? I want to modify one of these
scale properties over 5 s. So I'm going to modify
just the z scale. I could modify all of them, but I'm going to
add a keyframe at 0.0 s here by clicking
this plus button. So we're saying I want
the scale value for that vector variable to be
one in the z at 0 s. Then I'm going to move my timeline
slider all the way out to 5 s. And then I'm going to
click the plus button again. Only this time I'm going to say at this point
in the timeline, I added another keyframe. That's what that red dot means. I'm going to say at this point, I want the Z scale to be
five, so we're going 1-5. And if I move this slider, notice that the value of the
Z scale changes over time. This is all well and good
except for we're not actually making use of this variable it all inside of our
bp example pickup, we've exposed it, we've exposes scale vector variable
to our cinematic here. And we are going
to be adjusting it over this cinematic here. But we don't have any script yet that's actually going to
take advantage of this. So let's do that next. And so for this, we're going to add a trigger box to our level. And I'm gonna do this
relatively quickly here. I'm going to scale it
up in size is going to change the box extent
to 200 again by 200, 200 over in the Details panel. Going to change the
line thickness to ten once again, like so. This level sequencer, actor, actor right there, it
doesn't matter where you place that in the
level, by the way. And then I'm going to make
this so that we can see it. The rendering actor
hidden game to false. And then with this
actor selected, I'm going to jump on over to my Level Blueprint,
going to right-click. I'm going to do something
when we begin overlapping it. First thing we're gonna do is
we're going to drag out of here cast to a third person. We're gonna do something with our ThirdPersonCharacter
overlaps at. What we wanna do is then grab a reference to our
level sequence here. So go ahead and click on that back in your
Level Blueprint. Going to hold down the R key, left-click to bring
any reference to that. And then I'm going
to drag out of this and type in the word play. We want to play our
sequence player. That's the option
we're looking for. We're essentially saying, Hey, play this cinematic, so it
should be hooked up like so. That'll play the cinematic. So it will actually
modify that property. But it's going to modify this
scale property over 5 s. But we aren't actually creating any script yet to actually
show that growth happening. So for that to occur, this is a very
convoluted set up here. I'm going to right-click,
bring in an event tick. Every frame. We want to. Select your example, pick
up there in the level. In back at our level blueprint, we're going to hold
down the archae left-click to bring in
a reference to that. We're going to drag out of here. We're going to set a world scale three D for the
sphere collision. Because our sphere collision, everything is attached to that. And move it like so. And then we're
also going to drag out of our example pickup and find that scale variable. I got to scroll way down to
the bottom to get our scale. Like so. So notice that our
scale is by default 11.1. So every frame, it's
going to read that in. It's going to set our
sphere collision here, which is the most
roots component in everything's
attached to that 2111. However, once I overlap
that trigger box, we're going to
tell that sequence or to play that's
going to act as a timeline to modify the
value of this variable, 1-5 over 5 s. That's our cinematic. So you can pause the video here, check this out if you want
to play along at home, I'm gonna compile this. Let's go ahead and
give this a play. Move this off to the side
here just a little bit. So you can see our example
pickup there in the back. The scale is remaining constant. Let me set my debug object right there
so you can see event tick firing
off every frame. Bring it on my play
window once again. So once I overlapped
is over 5 s, you should see this increasing
in size. Here we go. Pretty sweet. And indeed that did happen. So that is a very long-winded
way of showing off what exactly the heck this exposed
to cinematic option does. So just to bring
this back around that exposed to
cinematics checkbox, you can find that on
Boolean, integer, float, string, vector transform,
an actor variables. You will not find that for name, texts or rotator variables. Alright guys, that's gonna
do to offer this video, we will see you in the next one.
54. Variable Tips and Tricks: Welcome. In this video we're going to be reviewing essential
tips and tricks you absolutely should know
about in order to work with variables in the most
efficient way possible. We're going to talk
about the different ways of getting and
setting variables. We're going to review how
to promote a variable. We're going to talk about how to categorize variables
and give them tooltips. And lastly, we're going
to talk about how to change variable types. Let's start out in our bp
ThirdPersonCharacter Blueprint to help aid in this discussion. So if you don't have that open, you can find that in
third person blueprints. That's where you can find
the ThirdPersonCharacter. And once inside of here, Let's
explore how to get and set variables three different ways we're going to talk about here. Firstly, let's explore
the three different ways to get a variable that is to find out what contents
exists inside of that variable. And for that, we're
going to get rid of this health GET array here because we're gonna
be exploring that. So the first way is we
can left-click and drag. And then in our little
dialog box here, when we release our left-click, we could get the health. That's way number one. Way number two, I can hold down the Control
key, left-click, drag, release, left-click, that can get a getter
of that as well. And the third way, less common, but
super effective, is to simply left-click and drag this on an input pin
for a given node. So once we drag and drop
it on top of there, it's going to get
the contents of that variable quite handy indeed. Alright, let's talk about
setting a variable. So right up here we've
got a center in place. I'll leave it there
for the time being. But what we're gonna do
here is left-click drag when number one
here is to simply choose Set Health
from that menu. If you left-click, drag,
release, left-click. The second way is to
hold down the Alt key. Left-click, drag,
release, left-click. That's the second way of
getting a center of that. And the third way to set
the contents of a variable. So I'm just going to delete this guy out for the time being, is to simply drag and drop
on the output pin of a, of a given node, and that'll
bring in a center as well. So setting once again, allows you to alter the
contents of that variable. Next, let's talk
about promoting to a variable you
already know you can create variables
by clicking here, adding variable,
or by coming under here variable and
clicking the plus button. However, promoting variable is the third way of
creating a variable and it is quite handy for
a couple of reasons here. One, it can give you the variable type that you
need right from the get-go. So using this node
as an example here. So say we've got our
health variable and we want to add
some amount to it. Well, we can simply
right-click on this pin and that's
gonna give us the variable type
that we already need, in this case a float
so it can right-click, promote and I click, I can call this health to add. The second benefit
of promoting to a variable is if
we compile this, we can see that it automatically grabs the value that was
inside of that node. If you had already
placed a value inside of there and you've promoted
that to a variable, and you then compile it, it's going to automatically
populate that variable with the value that
was inside of it. So that's super handy. It's worth pointing
out here that you can promote a variable on any node, not only from the input side, but also from the
output side as well. So output side of
this health center, I could right-click on this, promote this to variable, and call this my
health again variable. Don't know why you'd
want to set your, set a new variable after this, but maybe you'd want to
do something like that. So promoting a variable
super handy way to get the variable type that you are in
fact looking for, as well as setting it to the contents that were
already hard set in there. Now, what I really like about
promoting to a variable, let me just jump over to
my BP example pickup is, we've talked about some very
common variable types here, but there are some more
obscure ones as well. E.g. I've got this
play sound 2D node here am IBP example pickup. And I've got something
called concurrency settings. You may be wondering, I have
no idea what that even is, but I want to fiddle around with this and see what I can change. Well, you could
right-click on this pin. You could promote that to
a variable, compile it. And then in the Details
panel you can see what things about this
variable you can set. And you might not be
able to see anything, might not make sense to you. But that's a great
way to learn what these different
pin types all are, what these different
variables all are on the input side of a node or
the output side of the pin. Great way to learn those things. Alright, Next, let's
talk about creating categories for your
variables to live in. Now, as you get more
complicated with your scripts, you might have more and
more variables over on the left-hand side
and you want to have some way of categorizing them. Well, you can create categories
for them to live in. Let me just select by health
to add right over here. And over in the Details panel, we've got a category and
currently all of these are in my default category from pick-up sound to
concurrency settings. I could create one by simply selecting this
category field right here. Overriding it, I'm going to
call this my health category. Alright, so now you see over
in the My Blueprint panel, I've created a
health category and my health to add
exists inside of that. Now I can add other
variables to this category. I could say, Hey, scale, I want you to live
in that category as well by simply selecting it. And now if I click this
drop-down, I'm gonna, I'm gonna be able to find health within that dropped down. So you can create a
new category by simply overriding this and typing
in a new category name. However, once you've
created a category, you can choose to set a variable inside of that category by either
choosing this here. Or I can simply drag a variable
up into this category. So five is to try to
drag this pick-up sound and place it right
here on top of the scale. Watch it's going to happen here. It's going to reorder
that it automatically place it inside of
this health category. Now, this is also useful for
creating these categories. Because let's check
this out right here. My health to add. It has this little
eyeball checked, making this instance editable. Any variable set to
be instance editable. Once again, compiling this here just to make
sure I've got that, jump back to my test map. I've got one of these BP
example pickups here in my level over in the Details
panel with that selected, I can see my
different categories that I can change about this. Now, one of the categories
I can change is my health to add
and check this out. It's not listed in a category
called default anymore. It's now listed in a category
called Health to add. Let's go ahead and try to
create one more category here inside of our
bp example pickup. Let me change my scale. I mean, it doesn't really
make sense to have that in a health category per se. Two, let's change it to
a category called scale. And I'll set this to
be instance editable. We must compile after we set this to be instance
editable in order for us to then find this variable
exposed in our editor. So with this selected, I'm now have a health category with health to add inside of it. And scale category with a
scale variable inside of it. Now, what would you want to
create these categories for? Well, in something like your
BP ThirdPersonCharacter, you might have some
variables that are all related to the name
of your character, first name, last
name, middle name. It could be some character attributes that you all
want to categorize. That would be a common thing. Could be things related
to health or damage. You could create a health
and damage category, that sort of thing. Next, let's explore adding
tooltips, two variables. Then I'm going to jump back
to my BP example pickup. So for any of my variables, I can add a
description, a tooltip. Notice that when I mouse
over my variables currently, it says my health
to add is simply a float by pick-up sound that is the base description scale simply says that's
a vector variable, but you can change
the contents of that, the tooltip texts if you will. With my health to
add selected over in the Details panel,
my description field. I can change this to be this is the amount of health
to add Enter. And now if I mouse over this
health to add variable in no longer says float
double-precision or whatever it's said before, used to say float
double-precision. It now says this is the
amount of health to add the texts that I put
in right over there. And lastly, I just wanted
to point out that if you really want to
change variable types, you can, and you know, you can change the variable type either right here by
clicking on this, choosing a new one from
the pop-up box here, or in the Details panel, you can change it
right here as well. However, if you do, there are some things
you need to know about. So with my health to add float variable
selected over in the, My Blueprint panel,
I'm going to change the variable type
to be an integer. Now once you do this, you're gonna get a little
pop-up box saying, Hey, you could break
some connections here. Are you really sure
you want to do it? So let's go ahead and
change that variable type. But you'll notice
that when you do, you're gonna get this saying, alright, we have found this
right here in the graph. Your BP example pickup
add your health to add. There it was. Now I'm going to
exit out of here. And you're going to see
this right here being like, Well it was a float, it is now an integer. So what do you do here? Well, you can fix this up by right-clicking on this
node, refreshing it. It now recognizes that, hey, you change that to an integer. But now you've got
some work to do here. We broke this link and I could plug this
into here as well. And in this case it's
going to bring in a, it's just going to convert
that in real nicely. But other cases that's not
going to play so nicely. So you really gotta be
careful about breaking your connections whenever
you change your variables. Now, we only had this one instance of this
variable added right here. However, if you wanted to find every place where
this could possibly exist into fix up all of these references
of that variable. You can right-click on
this, find references. And in doing so, you can
find where this variable exists anywhere in this graph. And you can find even
beyond this graph, if you were using this variable, you are calling this variable
from another Blueprint. You can click on
this little button over here to find where that variable was being gotten or
set in any other Blueprint. So that's really handy to know about right-clicking,
finding references. You'll bring up
this little pop-up. You can double-click on
this to jump right to it. And then also if you
want to find where this variable is referencing
other blueprints, you can click right here
in order to do that. Alright guys. That's going to wrap
it up for this video. That's gonna do it
all for variables. We will see you in the next one.
55. Functions Overview: All right, welcome
back everyone. In this section of the course, we are going to be
officially changing our focus to the
topic of functions. And although you've seen me
use a bunch of functions in our discussions of other things related to Blueprint scripting. Here's where we break
them down in full, talking about all the
nuances of functions. So our goal in this video is to quickly cover
what functions are. Give some examples of how
they're utilized in Unreal. And lastly, talk about
where you can find them. So first of all,
what is a function? Well, to help facilitate
this discussion, I'm inside of my
Level Blueprint and I have placed down
some function nodes. A function is a blueprint node that's simply does something, it performs a
specific operation. So what kind of things do I
have placed before you hear, well, you could spawn and actor. That is to spawn some object in your game that could
be useful to you. You can spawn a particle effect. This is the old VFX system, the cascade visual
effects system, or a newer particle
system known as Niagara. You could create a widget that is to show a
Widget Blueprint, which is oftentimes used
in Endgame HUD, or menus. You can play a sound. You could change an
actor's location, all kinds of things that
can be done with functions. Now functions can take
inputs and return Albert's. Just as a reminder, inputs are found on the
left side of a node. Outputs are found on the
right side of the node. Unreal comes with a whole
host of functions already, if I was to right-click and some empty space and drill down in any of
these categories, you see all these
fancy looking S Here. They are either
in blue or green. These are all kind of ready-made function nodes
that you have access to. Now you can create
your own functions in a blueprint and call
them when desired. We'll talk about that in
a few videos time here. Now a few things worth noting in this generalized
overview of functions is that as you're working
with functions in Unreal, you'll notice that they come
in two different flavors. You've got blue, which are
known as impure functions, and they have this
blue header to them. And if I go over
to the right here, you've got green functions and these are known as
pure functions. Now, the key difference between these is that these
green and pure functions do not have execution pins
on the input or output side, whereas the blue
impure functions do. Now we have a whole
video dedicated to impure versus pure functions. So we'll talk about
those more later on, but just wanted to point
that out while we're here. Another difference that
I wanted to point out between different
function nodes is that sometimes the header for them is a little bit more
descriptive than others. And well, what do
I mean by that? If we look at some of
our function nodes down here as they are spawn
system that location, that's all this
function node says is spawn system at location. Now contrast that with this node right up here, set
actor location. And then right below it
says target is actor. This one is asking
for a target that we want to change the location of. This one does not have any subheadings sub
descriptor beneath it. Now notice that this one does as well set material target
is a primitive component. I can supply a mesh that we want to change
the material of. If I jump over to my
ThirdPersonCharacter Blueprint, I place some function
nodes down here as well. These all say target
is character, target is character, target
is character, et cetera. So different functions
have different targets. In this case, all of
these function nodes are specific to a character class. Whereas in our level test map, some of these function
nodes are not specific to any given class or
any given component. Functions may have
different targets. It could have a
component target, it could have an actor target, a character target,
things of that nature. And we'll get to that
more in a little bit. And finally, I wanted to
talk about where you can find functions within a graph. Well, a couple of different
ways you could do this. The most common way is to right-click in some empty space. In here. If I click on my
actor drop-down here, Here's where you can find
lots of different functions. Again, they come in the blue
flavor impure functions, or the green flavor, that is pure functions. And these are available
within any given category. You're going to
find a whole ton of these that are already
pre-built for you. Now you can search for a
given function as well. Again, spawn actor from
class is a common one. So if you know what
you're looking for, you can simply type it in there, spawn actor from class. Something else I
want to point out here is that functions can be context-sensitive or
non context-sensitive. And that's this
checkbox right up here. It is checked by default. And let me just show you how this can change
the results here. So I've got this spawn
actor from Class Blueprint, and I've already placed a BP example pickup in
the class here. If I was to drag out of this, now look at my
context-sensitive checkbox is checked and at the very top
actor is my topmost category. That's with
context-sensitive checked. An actor is the
topmost category. Now let me come over
to this Create Widget function right over here. Let me drag out of here. Notice context-sensitive
is checked. However, I don't even
see that actor category across the top here
because these are going to return two different
types of things. This one's going to
return a widget object. This one is going to return my BP example pickup because that's the class
that I have slotted in here. Now, if you in this
right-click menu, hover over this context
sensitive checkbox here. And you click on this
little fly out menu. You can decide in
which contexts it is going to find given
available functions. This blueprint as a tool
tip says it's going to include functions and variables that belong to this blueprint. If components is checked, it's going to include
functions that belong to components of this
blueprint and, or other target classes. And then libraries
that is to include any other functions that
are globally accessible. And once again, we have a
whole video dedicated to function libraries in a little
bit time down the road. Now, if you have some
specific functionality that you want to have built, you can create your
own functions in the My Blueprint panel under
the functions category, you can create your own
functions right here. You can call them what you want. You can create the
functionality that lives inside of
that function node. And then it's as simple
as dragging and dropping that function node from your my blueprints tab
over here into your graph. But we will talk more about
that down the road as well. Alright guys, there
is an overview of functions within
Unreal Engine blueprints. We will see you in
the next video.
56. Actor Functions: Welcome. In this video, our goal is to learn what actor functions are, explore how to find them, and to demonstrate a few. Now we left off in the
last video just taking a general overview of functions inside of
our Level Blueprint. And I was talking about
how some functions had this subheading
beneath them, including this one for set actor location that
says target is actor. So that's what we're talking
about in this video. We're talking about
actor function. So what is an actor function? Well, it's simply a
function that targets, that is to affect a specific
actor that you supply it. Now the target could be itself, but in the case of
a Level Blueprint, self is not very helpful. We need to actually say, Hey, what's the thing that
we're trying to effect? And in this case,
what new location will we be trying to give him? Now, I'm gonna go back
to my level here, and I have added a
static mesh to my level. If you want to play
along at home. This is in my content started
content prompts folder. I place one of these
guys into my level. And with that done, I also changed the mobility
here to be movable. And that's gonna be important
for function that we're going to be trying
to set upon this. So with that done, make sure that you have this Static Mesh actors
selected in your level. And I'm gonna jump inside of my Level Blueprint already
have it open up here. But once again, that's how you can access your Level Blueprint. Now it doesn't matter
what graph you're in. I've got two graphs here, my node types graph
and my Event Graph. My Event Graph is a
little bit cleaner, so I'm gonna go inside of there. I already have a reference
to this in my graph. Now, the way you can get a reference to that is
to simply hold down the R key and left-click or
in your right-click menu. If you do have it selected, you should be able to find
and create a reference to it by right-clicking
and choosing right there. Either option will do for you. So this is the actor
that we want to target. So if we drag out of
here and we release, we have context-sensitive
checked here, meaning that if we
drill down into any of these categories, we can find functions that are specific that will work
for this given actor, including something
like Destroy Actor. Note it says target is actor. I could bring in an input event and upon pressing
that input event, we could destroy the
actor that is our target. We're talking actor functions. So let's try a few out here. We've seen that Destroy
Actor one plenty of time. So let's bring in a few more. So I'm going to
drag out of here. And I'm going to type
in set actor location. And I can see that this is in the transformation category. So that's how you
can see where it is. Now, this one is the
reason that we had to set our mesh
here to be movable. Because if we don't actually
set this to be movable, we're gonna get
some complaining. When we compile. I will set my new location. Instead of plugging
in a variable, I'm just going to hard set
it here to, let's say 1,000. And it'll just move it
somewhere up into the air. Let's drag onto here again, we can do multiple things. I'm going to do set
actor rotation, that's also in the
transformation category. Okay? So we're gonna go like
this and note that we're using the same reference as the target for multiple
actor functions that's entirely
acceptable to do. I'm going to drag out
of this and let's do a set actors scale 3D. This is also in the
transformation category. And then lastly, I'm
going to drag out of this one more time and
we will set lifespan. This is in the actor category, so different functions can
live in different categories, but if you know the name of it, you can simply type
it in up above. Now, I currently don't
have any input out here, so let's right-click,
zoom, empty space in. Let's, let's do what key haven't
I use yet the seven key. Let's do the seven key. Sure, that'll do just fine. So when we press the seven key, we're going to want
to set our actors location to be somewhere
up in the air. The 001000 location
in the world. Then we're going to keep
the flow of execution going and set our
actors rotation. I did not set a rotation here, so let's set that to be 45.45 just to angle it a
little bit so we can see something different
than what it currently is. Then we're going to keep the flow of execution
go in here. We want to set a
new scale for it. Let's do 44.4,
something kinda big. And then let's draw
on here the lifespan. So this is how long that
this is going to live before it is destroyed less
than our lifespan to be. Let's go 5 s. Alright, so notice that all of
these functions take in, in an actor target. We can use the same
reference and plug it into the target input
note of all of these. So I'm going to compile here, going to move this
off to the left. We're going to play, let me set my debug object to
be my test map. And there is my actor. As soon as I press
the seven key, you're going to see
bang, bang, bang, bang. Here we go. Seven. Somewhere up in the air. It is rotated, it is big. And after 5 s boom, it does go bye-bye. So you can see that it did call that function on
this given actor. And it did all of these
things changes the location, change the rotation,
set the scale, and set the lifespan. So there you have
it. Actor functions. You can find them
by dragging out of a given actor, doing
a search for it, or simply searching in here to see what kind of
functions are available to you. Alright, that's gonna do
it all for this one guys, we will see you in the next one.
57. Class Functions: Alright, welcome back. In this video, our goal is to learn what class functions are, explore how to find them, and then demonstrate a few. So firstly, what is
a class function? Well, it's simply a function
that can only be used by a specific type that
is a specific class. Now, what are we
talking about here? Well, if we jump back
to our Content Browser, and he saw me
right-click earlier in the course in some empty
space in my content browser, if I come under Blueprint class, these are the different classes
that we're talking about, the different blueprint classes. Now, we have functions that
are specific to each class. And this is gonna
be most obvious to demonstrate when talking
about our character class, because pretty much every
game that you're gonna be creating is going to have a character or maybe
even upon class, but let's demonstrate
a character. So go ahead and open up your
BP ThirdPersonCharacter. That's where I started
this video with him. And notice in my graph here I have several function nodes. And notice that right
below the header here, the sub-header here says
target is character, the jump function
target is character, the launch character function, target is character, the crouch
in and crouch functions. Target is character. These functions are specific to this class, this
character class. And I can find these by right-clicking in
some empty space. And then if I look for
that parent class name, we're looking for the
character right up here. Let's scroll on down. And if we find C H character there it is, right down here. You can find these events. We've got crouch,
we've got jumped launch character on
crouch, et cetera. So these are very specific to this given class of Blueprint. Now, let's demonstrate these. And I want to point out here before we do if you want to find and make use of these crouch
in and crouch functions, you need to select your character movement
component and over in the Details panel under
the nav movement category, makes sure that you
check can crouch. It is not checked by default. Alright, so let's go
ahead and try these out. I'm going to click play here, going to set my debug object to be by third-person character. And I'll minimize these
a little bit like so. You can see obviously if
I press my space bar, that is going to make my
character jump releasing, it makes them stop jumping. If I press the L key, I've got this launch
character function which have hard set the launch
velocity to be 2000s and z, which is kinda like a
super jump, if you will. However, you can still do
this while you are airborne. So that's kinda fun. And then I've got
the C input set for crouching and crouching
when I released the CQI. Now when I do this, you're
going to notice something. I press the C key and
whoops, let me do that. Once again. I press the C key and the camera goes down
and it rises back up. When I crouch, my character does not go into a
crouching animation. I would need to do some more
work to get that hooked up. But we're not gonna
go into statements, cheese and changing
our animations, all that kind of stuff. But you'll notice that this
is actually under the hood, crouching my character, meaning that it is lowering my camera, it is slowing down my
players movement speed. And then when I crouch, I returned back to normal camera height,
normal movement speed. Now, a couple of things worth pointing out here for
all of these functions, the target is character, and we don't have anything
plugged into this target. The target is
simply set to self, which is valid in this
situation because This is, our self is a character class so we don't have to
plug anything into it. Self is a perfectly valid
thing to have said here. The target is ourself, which is a ThirdPersonCharacter. Now it's also worth
pointing out that you can find access, make use of these functions
within another Blueprint. So let me demonstrate that
quickly by hopping on into my Level Blueprint. You'll note here is
some empty space. If I simply right-click and
I do a search for launch, we had that launch function inside of our
ThirdPersonCharacter. I can't find it. I can find some other functions
with the word launch it, but not my launch character. Context sensitive
is checked here. This is not a character
class blueprint. You will not find it.
Now if I uncheck this, I can now see that we're not searching via
context sensitivity. And now under our character, we can find our launch
character function. This belongs under the
character class of functions. Let's go ahead and add
this to our graph. And it's saying,
okay, you want to call this function That's great. The target is cell, so supply me a target. Now, if I was to simply have a cube existing in my level like I've placed
ahead of time here. Note that that is selected. Let me bring in a
reference to that by holding down the
Archean left clicking. If I try to plug
this in as a target, It's going to say, Nope,
that's not a valid target. You can't do it.
The target we're looking for is a character. So we could get a reference to our
ThirdPersonCharacter and plug it into it. And then this would work. Now, to do this, we need to get a reference
to our character. I've got this
character reference variable that I created
earlier in the course. But if I right-click on
this and find references, I must have destroyed the
contents of this variable, so this is currently
set to nothing. Okay? We can still get a reference to our third-person character
in another means. And you've seen me
do this before. Right-click debt
player character. We've got this pure
function that will return a player character. But it doesn't know
what character we want to be
searching for here. So let's do a
ThirdPersonCharacter Cast to ThirdPersonCharacter. Going to say, okay,
your player character, is that a third-person
character? And if it is, we can Call some functions that are
related to that character. And the ThirdPersonCharacter
can make use of this launch
character function because the third-person
character is a character class that
is a valid target. I just need to simply
supply in input here, Let's right-click to
search for the eight key. I don't think we're making use of the eight key and either of our grass here only
in our event graph here. Okay, Let's go ahead
and plug this in. Compile, Let's save it. And now if I was to play, Let's set our debug object to be that so we can
see this fiery off. And so now if I press the key, woops, it is actually
trying to call it, but I did not sit
a launch velocity, so that would be a problem. That's it or launch
velocity to be 2000. Yeah, that's kind of an
important detail right there. And pressing the Alt key, we can now call that
launch function. So once again, so
long as you have a reference to that given class, you can call functions
specific to that class. Alright guys, that's gonna
do it all for this video, we will see you in the next one.
58. Component Functions: Alright, so in the
last couple of videos, we have explored actor of
functions and class functions. In this video, we're going to be exploring
component functions. We're going to explore
how to find them and demonstrate a few. Now, this begs the
question, well, what the heck is a
component function? Well, it's simply a function
that targets that is to affect a specific component
within a blueprint. Now to show this off,
we're gonna be using our bp ThirdPersonCharacter
Blueprint. That's where you can find it. So double-click on
that to open it up. Before I shot this video, I went ahead and created
some scripts just to make this a little bit
more brief time-wise. And over the event graph, what I have in place
is I've placed the three different
components into my graph. Now, these are respectively my quote unquote
sword component, that is a static mesh component. Next component that
we're gonna be working with here is
our Mesh Component. And that is jumping back
to the viewport here. This Skeletal Mesh that
represents our character, this mannequin
woman, if you will. And then the last component
we have is our follow camera. And just jumping back to the viewport or follow camera is this component right
there, that camera. So how do we add
these to our graph? Well, as you know
from variables, you can simply drag and drop to add these into your graph. Then you get a reference
to that given component. And if you drag out of these, you can find
functions specific to that component that are context sensitive and work
with that component. So what I have here
is out of my sword, I simply drug out and I did a
search for set static mesh. But if you are wondering
where this exists, if you go to set a static mesh, you can see that it is in the components static
image category. And I list that right up above your components static mesh. So if we were to simply
exit this out and come under components and
come under a static mesh. You can see we've got that
function that we can add or we can add the pure
function get local bounds. But this one's a
lot more visual. Now down below here, for
this mesh components, I simply did a search
under the components, components, components
skinned mesh category. You can see we've got a lot of different functions
in here for this. But for this one I just
wanted to simply change out the Skeletal Mesh
associated with that. And by that, what I'm
talking about here is with our mesh
components selected, we're gonna be swapping out the Skeletal Mesh
associated with that. It's very visual. So you
can see the target here is skinned mesh component that is talking about
this right here. Lastly, we've got
the follow camera. So we have some
functions that are specific to a camera component. And you can find these under the right-click menu under
the camera category. So a lot of functions in here to play around
with as well. This one is very visual, the setting, the field of view. So once again, the
subheading under this shows what specific
component may be targeted. Alright, so playing
this super visual here, Let's set our debug option so you can see this firing off. So when I press the F key, we're going to change out our, our sword there to that ball. That's the new mesh
that I slotted in there when I press the G key, our mesh here, that mannequin woman rather than Aaron's
gonna be swapped too. That's right, Just a cube. And this skeletal
cube right here is in the engine content
that's skeletal cube. Lastly, notice the, the field of view here
when I press the age, he is going to
shift a little bit. Alright, so here
we go, Press and the H key kind of zooms it
out a little bit like that. And so there you have it. You can add all kinds of components up here in
the Components panel. There are tons of them. And so just note that for any
component that you can add, there may be
functions associated with that particular component, specific to that component. Explore them, play around
with it, learn by doing, alright, that's gonna do
it all for this video, we will see you in the next one.
59. Creating Functions: Alright, welcome back everyone. Over the last few
videos we showed how to find various functions that
already exists in Unreal. In this video, our goal
is to show how we can go about creating
our own functions. Now, this is an extremely
powerful concept within blueprint scripting. In it essentially allows you to create any functionality
that you want. Now for the bulk of this video, we're gonna be doing
some work inside of our bp third-person character. So I suggest that you
open that guy up. I've also got my Level Blueprint opened along
the top as well. Firstly, it's important to
note that functions can be created within a class
blueprint or a level blueprint. So just to show off, starting with my level blueprint or in the My Blueprint panel. You got a section for functions. So functions can be created in here inside
of a Level Blueprint. Additionally inside of a Class Blueprint like
our ThirdPersonCharacter, you'll find that same functions section so you can create
one in here as well. Alright, now let's talk
about different ways to create functions. Well, we've got this Add
button right up here. You can click on that, create a function that way. Another way is with the
function header right here, you can click on this button
that will create a function. And the third and
less obvious way is on any of these headers, graphs, functions,
macros, variables, etc. You can simply right-click, and let me just right-click
on this graph header here. And it will bring
up this same menu that you got when you
click right here. So you can add a function here. And if I create when this way, it's going to add it to
my functions category. I'm gonna give this a
name right away and call this modify health because I'm going to create a function that modifies our player health. And note that when we clicked to add a function, whether here, here or here function, what we've done is
we've also opened up a new tab right up
at the very top. So what you have before you
is simply an entry node, in entry node to your function. And here in the
rest of the graph, you get to create what
functionality you want this function to have
an at the very end, you need to add a return notes I'm going to
right-click and some empty space and add a
return node right away, just right-clicking
and typing in return at the very bottom, you can add a return node. Now, again, here's where
we're going to be building out what this function
node actually does. But while I'm building this out, I think it would be helpful
if in the event graph, I simply dragged and dropped this function
node into my graph. So here we go, dragging
and dropping it. Now it is blue. It seeing the target is a
third-person character because we are building it here inside of our
ThirdPersonCharacter. So that's gonna be
the default target. And note that all we have
here is an execution in pen and execution out
pin and a target. But we can add more pins, more data pins on the input
side or the output side. And we're going to show
off that a little bit here in this video. So this is what the function
node currently looks like. And throughout this
video we're gonna be modifying it a little bit. Let's jump back into our modify health function and build out some
functionality. So the first thing
that I want to add to this function
is an input. I want to be able to have
the ability to input how much health or damage that our character is
going to be receiving. So in order to do this, I need to select my entry
node here, my Modify health, and over in the Details
panel where it says inputs, Let's click this plus
button to add an input. Now it's going to allow
us to name it right away. By default, it should
show as a Boolean. However, you can
change the type. It's shown as a float
for me because I was doing some prep work
before this video. So change it to a float. And again, you can do
that by clicking here. And let's change the
name of this input to be heal or damage amount. Now, note that if I jump
back to my event graph here, where we place our
modify health function, I now see on the input side of our function the ability
to input a float variable, a health heal or damage amount. So it's a little
misleading when you're building out your
functions here. You select this entry node here, and then you add an input. And the reason it's a little
misleading is you think of inputs being on the
left side of a no-no. But here on this entry note, it's showing it on the
right side of the node. So first time I was
learning all this, I've felt that rather confusing. However, in the final
resulting function that we can see in
our event graph, when you drag and drop this function into
the graph itself, it does appear as an input
on the left side of a node. So you can input a float value of health or damage that
is going to be received. Alright, let's carry on. What I wanna do is I want
to drag out of our health or damaged amount that
we're gonna be incurring. I'll bring in a
greater than sign. We wanna do something if our health or damage amount
is greater than zero, or we're gonna do is
drag off of here, bring in a branch node. We got to keep this flow of
execution going through here. So we're going to evaluate, is the healing or damaged
mountain greater than zero. And if it is, we're going
to drag out of here and we're going to
play sound to D. In fact, I'm going
to hit Control C and Control V to copy this because
we want to play a sound, whether this is true or false. Now if it's true, the
sound that I want to play is going to be called
the laser push. If it's false, the
sound that I want to play is called laser poll. Now, in simply hovering
over this laser pole, you can see that the
path for this is in the engine content folders. So if you're playing
along at home, you don't see laser pushing
laser pool. Right here. You've got this gear icon. Make sure you've got show
engine content checked off, then you'll have
access to these two. Alright, so laser poll for this. So depending on if the incoming amount
is greater than zero, we're going to play one sound. If it is not greater than zero, we're going to play
another sound. Those are kind of like more positive or negative
type effects. Okay, then what we also
wanna do here is dragged out of this amount that
we're going to be inputting. And I'm gonna hit
the Plus symbol. We're going to add
something to it. We want to add to
this is going to be our health right here. So we're going to drag and drop our health right on top of this. That'll give us a
getter right away. So we're going to
add that, the amount coming in to our health. And then we're going to set
that so we can simply drag and drop our health on the
output to bring in a center. Now what I wanna do is I
want to bring this way over here so I can wear
this in like this. And like this when I'm
essentially saying here, is that no matter what, whether the amount coming in
is greater than zero or not, I want to add that to
my current health. I'm going to play a
sound regardless if it's greater than zero or not, a positive or a negative sound, then we're going to set that
as our new health value. Then I'm going to plug
this into our return. But last but not least, I can drag and drop this onto the returned node to add
a pin to our return. To note that once I do this, just drag and drop it on there. It's going to add an
output right up here. But we probably want to give us a better name than
just output gets. So I'm going to name
this current health. Like so. Now something else
I want to do here is I want to be able
to clamp this health because let's just
say we are already at full health and the
incoming amount is going to add to our health than
we could technically have more than 1.0 health. We can have more
than 100% health. So the way that you can ensure
that this is clamped to a given values to
bring in a clamp node. So I could drag out of here. Typing in clamp. We want to clamp our float and we want to
make sure that it is 0-1. That's kinda nice. So I'm just going to
wire this in like that to ensure that even if we're receiving a healthy
amount that is going to add to our health
and make it above 1.0. That no matter what
it's going to stay at 1.0 cannot go above that, so make sure that
you do that as well. Now, take a look. This is our, this is our function right here. This is a functionality
that we're adding in our vent graph with his modify health function
added to our graph, we've got this input
healer damage amount, and on the output side, we can output our
current health. Now some important details
before we wrap this video up over in the Details panel
with your functions selected, take a look at our inputs here. We've got this heel
or damage them out. And we've got this
little drop-down arrow. If you click on this, you can set a default
value for this. So currently it's 0.0, which you can see reflected
on the function node itself. If I was to change this to 0.5, you can see that
once I hit Enter, it's going to hard. Set that in there. Okay. I don't actually
want that for now, but I just thought I'd
point that out that you can set a default value there. Let me set that back to zero. And also you've got this
pass by reference option. What does that even mean? Well, it passed by a ref or
passed by reference option allows you to tell the
function that whatever variable that you are
plugging into this, that's the variable
you want to change. It essentially allows
you to get and set a variable at the same time. Now we're gonna go into this a little bit more
in the next video. But I just want to point out here that if I was
to check this box, note that this pin is going to change from this sort of
a circular shape, too. Little bit more of
this diamond shape. Alright, I'm going to
uncheck it for now. And once again, we'll
show that off a little bit more in the next video. A few more things that you
need to know here is that if I was to double-click on this function note I'm
in my Event Graph. Watch what happens. Double-click. I've jumped from my event graph into
my function graph. So here, That's a
quick and easy way of seeing what is this
function doing. And that'll jump you right
to your function graph. Really handy tip. A couple of other notes about
functions that you create. You cannot have
latent nodes like a delay node or a timeline
within your function. That is a limitation
of functions. And something else to
note about functions. With functions you only get one execution in and
one execution out pin, that is one execution
in, one execution out. If you have a need
for more, macros, are the way to go now, in the future, we will add some videos talking
about macros. But guys, that's gonna do
offer this one follow up in the next video
where we're going to talk about calling functions. See you there.
60. Calling Functions: All right, In the last video, we finished creating a function inside of our bp
ThirdPersonCharacter. And thus we made it the
target wherever you create your function
that will be the target. In this video, we're
going to learn how we can go about calling this function from both a Class Blueprint right here inside of our
ThirdPersonCharacter, as well as a Level Blueprint. So hop right back into your ThirdPersonCharacter
Blueprint. And if you forgot
where that was, you've been living
under a rock somewhere. Here is the pathway for that double-click on
that guy to open it up. Now, I've added this to my
graph in the last video. Let me just delete this
out and do a refresh here how we can add that
to our graph here, I'm going to right-click
and some empty space. So in search for an event node, because we want to start
off with an event F3. F3, I don't know because I
figured it wasn't in use. Now a couple of ways
we can go about adding this function
to our graph. One way is we can
right-click and some empty space here and
do a search for it. Modify health, that's
one way we could add it. The other way, let me just
delete that out is to simply drag and drop it from our functions section over here. Drag. And if you drop it on the
execution pane right here, it's going to hook
it up right away. Then we're going to simply
drag out of this and bring in a print string node. Right? And let's hook this in our
current health into the string just as a refresher if you double-click on your
function node here. Well, we're doing
is we're taking in a health or damage amount. We're gonna be adding that
to our current health. We're gonna be
clamping it between these two numbers
and we're gonna be setting that as
our new health value. And then we're going to
be passing that through out the other side of
our function here. In this case, we're going to be passing it out of this node. Notice current health, that is the output pin of
our function here. And we're going to simply
print that out to the screen. Also, we need to hard-code in a healing or damage amounts. So we're gonna be starting
with how much health? Well, inside of
our modify health, right here, our health variable. This is what we're going to
be starting with 1.0 health. That's the same as
what we see over in the My Blueprint panel with that health variable
selected 1.0. So what do we want
to modify this with? Again, we can heal or damaged. So what I'm gonna do is set
this to a damaging amounts. So let's go 0.5. And because we want
this to do damage, Let's do negative 0.5. So negative numbers
are going to damage. In this case, positive
numbers are going to heal. Alright, let's compile,
make sure our script is looking good. Play. Let me set my debug to my
ThirdPersonCharacter here. If I press F3 here, you can see it reduces
our health in half. And you also saw 0.5 in the
upper left-hand corner here. Remember, our health variable is bound to our health
meter here as well. So if I press this
one more time, you're going to see 0.0 and
now our health meters gone. Now if I press F3 again, it's going to continue
to show 0.0 health. And that is because in or
modify health function, we're clamping this
modification of our health between these values. Alright, now just
to show off that this function can heal
as well as deal damage, Let's modify our
original healthier. Let's modify original
Health value to be, we'll say points to. So we're going to start
off with only 20% health. And then in our event
graph we're going to change our healing or damage MT. Let's just say every
time we call this, we're going to heal by 10%, 0.1. Alright, so this
can work both ways. The way we have this setup,
you're clicking Play. So we can see we're starting
off with 20% health. I press F 3.3, 40%,
50%, 6070809100. And of course, if I
tried to go over that, I cannot because double-clicking on our modify health
function here, it's going to jump
me to that graph. We're clamping our
health value 0-1. Alright, so we've proven
that you can call this function from within the blueprint it
was created within. But can you call it
from another blueprint? And of course the answer
to that is yes, you can. So long as you have
a reference to your ThirdPersonCharacter
in another blueprint, you can call this function. And to prove this,
we're going to use our Level Blueprint. Jumped back to your level here. And I have a little bit of a setup that you can
try replicating. Once again, I have a trigger
box placed within my level. And as you've seen
in other videos, I set the box extent to be 200, 200, 200, the line
thickness to ten. And I simply turned the
actor hidden and game off. Within the rendering
section so that I can see this trigger volume. And then I simply
place a fire particle. This is found in my started
contents, started context. Where is it particles
folder, right there. A place that in the
middle just to make that whole zone look dangerous? And then I simply
scaled it up ten times. So this is going to
be my danger zone. And the idea here is
that when my character overlaps this, they are damaged. So let's go ahead select your trigger box and jump
into your Level Blueprint. So the first thing
we wanna do is have something happened when
we overlapped this. So let's right-click Add
Event when we overlap this. And of course we do need to get a reference to our
third-person character. If you right-click and do
a get player character, and you try dragging
out of here and try finding that modify
health function. You're gonna be like,
why can't I find it? If you uncheck
context-sensitive, you'll be like, oh, there it is. Under class BP,
ThirdPersonCharacter. Oh, there it is. But the problem is you
cannot simply hookup, get player character into here. So that's a problem. The way that you can get
this modify health function, let me delete out of
here is through casting. Or if our character reference
variable right here. If this was actually populated, if we had initializes with our third-person
character inside, we could find the
Modify health function by dragging out
of there as well. However, we're going to use
the concept of casting here. That's a way of checking
to see if in this case the other actor was the thing that was
overlapping this Trigger box. So let's drag out a here, cast two-third person character. And if we do this, if we check to see
if the other actor was the object that was
overlapping the Trigger box, then we can pull out
of here and find that modify health function. And if you check context-sensitive
like I did there, and suddenly it disappears, simply clear out the
search dragged out again, type in Modify health, and you will find it. Once again. Once you have a reference to
your ThirdPersonCharacter, you can call any functions
that live inside of there. You can reference any variables that live inside of there,
get them or set them. You can even modify any of
the components in any of their properties that live inside of that
ThirdPersonCharacter. So getting a reference
to something is huge. Alright, this case,
do we want to heal or damage our character? I'd say it was damaged them. So let's go negative 0.1. And that should be good enough because
we're going to see our health meter decrease. Let's compile this. Let me go back in my
ThirdPersonCharacter. Make sure that I set
my health back to a value of 11.0, 100%. And let's play. I'm going to set my debug
object here to be the map. Ringing my character back on. So we're starting
off at 100% health. I overlap that they're
trigger volume here, a little audio there as well. Every time. One more thing before
we wrap up this video. In the last video, we
talked about a pass by reference option
inside of our function. And I need to get back to that. So in order to jump
back into our function, here I am in my Level Blueprint. I can jump back into this function by
double-clicking on this. And notice that once I do, I'm going to transition
from our Level Blueprint. Double-click into our
ThirdPersonCharacter Blueprint where this modify health
function resides. And it has opened up the Modify health
function tab for us. Go ahead and either select your modify health function
over on the left-hand side, or you can click on the Modify
health entry node as well. And over in the Details
panel you can see that we added a heel or damage MT input. And that equates to this input that you see on
the function node itself, you're am and my
Event Graph jumping back to the function tab itself. Now, this pass by
reference that we started talking about
in the last video, what the heck does this do? Well, visually speaking,
what you're going to see happen here is once
I checked this box, this circular shape
pin is now going to be replaced by a
diamond shape pins. So here we go. It's now
a diamond shape pin. Also, the default
value went bye-bye. Now if I compile this Blueprint, you'll also notice
something else compile, we get an error and it's going to say that
this is invalid, that we should have an
input wired into it. So what is talking about here? Let me jump back
to my Event Graph is talking about this
area right here saying, hey, you need something
wired into this. Now if I was in my modify, how function I'm like Why I have no idea what this
is talking about. This is a link. You can
simply click on it. And it'll jump you right to it. So it's saying, Hey, plug
a variable into this. So to show this off, what the heck does
pass by reference. Does, I need to modify our modify health function
just a little bit. And by doing this, I'm going to change our value. Instead of going 0-1 scale, I'm going to temporarily break our health meter, if you will. I'm going to say we're
going to start off with a health of ten. Let's pretend that we
have a health scale going from 0.02, 100.0. Alright, then what I'm gonna do is I'm going to
add some health. And again, I'm gonna
go with a zero to 100 scale instead of 01. Let's just say our
health to add, we're going to change to be, let's add one health. Alright, let me go ahead
and plug this into here. Now I'll fly. I'm kind of following along with our modified help function. Let me double-click on this. Once again, we're
essentially saying, Hey, we're plugging
one into here. Then we're going to add that
to our existing health, which is ten and clapping this between zero
and let's clamp it to 100. We could then have 11. And if we press F3 again, we would expect it to
go to 12, et cetera. But we're going to
modify one more thing here inside of our
modify health function. What we're gonna do is we're going to add in
increments node to this, drag out of here and
type in increments. We're going to
increment this float. And I'm going to
rewire things just a little bit here,
holding down Control, left-click and drag
where things like so. We're going to take
the result of this and plug it into there. And plug this into there. Whoops, I missed
there, like cell. And so now our function
looks like this. So if I compile here, what do we have going on? Well, essentially, what we
have going on is something whereby we're going
to add one health. This is being plugged
into our function. In adding one health, we are incrementing
that number right here. And if we hover over this, it says it's going to add
one to that specified value, and then it's going to set it. So instead of next time AS
incrementing our health, it being one, it's
then going to be two. And then the next time
it's going to be three, and so on and so forth. Jumping back to our event graph, we should see this reflected
in our print string. Once again, that meter is
going to be of no value. So let's go ahead and player in it saying we have this air also in our
Level Blueprint. Go ahead and click on
this level test map. What is talking about
if you click on that is because we have not plugged
anything into here, I'm going to
temporarily break that. Yes. Anywhere you have that it's going to yell
at you and say, Hey, you need something
plugged into that input. Alright, let's play this. So pressing the F3 key, we now have 12 health, 15, health, 19, health, 24, health. And you can see it keeps adding one to the amount that
it adds every time. Now the reason this
started off at 12, let me just go play
one more time. Again. We're starting off at ten
health than adding one or we think we're adding one
except we go 10-12. And the reason for that
is because right in here, we're taking this value one and we're incrementing
it right away. And in doing so, because this is a
pass by reference, we are incrementing
that variable as well. Remember in the
last video I said in doing this passed
by reference, wherever you have plugged
into this pass by reference. And you're not only
getting this value, you are setting it
right away as well. So even though it
starts off as one, every time you
pass through here, it's going to increment one. So 234, et cetera, et cetera. A little bit of
nuance that I spent way too much time upon. Alright, there you
have it, guys. That is calling functions. You can call them from within the blueprint that you
created them within, or you can call them
from other blueprints. So long as you have a reference to the blueprint
that they were created in. Guys, I'll do offer this one. See you in the next one.
61. Collapse to Function: Alright, welcome back everyone. In this video we're going
to learn how to turn an existing network of nodes inside of any blueprint
into a function. This is called collapsing
to a function. Now this is a super handy trick. Anytime you find yourself duplicating a selection of nodes in different
parts of your graph. So instead of doing
that, we could just turn those notes into a
function and then call that function whenever
and wherever you like. So currently I am inside
of my BP example pickup. And let's just say e.g. I'm going to left-click
and drag that. We're duplicating this
bit of script again and again in various parts of our graph for whatever reason. Instead of copying and
pasting these nodes, we can highlight them all
just like I did here. And then you can right-click on any of your highlighted nodes, and then you right-click menu, you could collapsed to function. That's what this
video is all about. I'm going to demonstrate
this briefly here, even though this isn't where I'm intending on going
with this video. So I'm going to collapse
this to a function. Note that when I do,
I've crunched all of these nodes down into
a single function. In over on the
right-hand side it says, what do you want to
name this function? I'm just gonna leave it
as that name temporarily. So I'm going to hit enter here. And if I dive inside
of this function, there are all of the nodes that created a function out
of all those nodes. And the benefit of
this is we could then simply drag
and drop this in other parts of our
graph and use it just like we would if we copied and
pasted all of these nodes. So that's the advantage of that. Now once again,
this isn't exactly where I intended to do this. So let me do control
Z here a bunch of times and get that back
to its original state. Going to compile and
say that once again. And let's go about creating a brand new Blueprint
Class here. To demonstrate this, I'm
going to right-click and some empty space here inside
of a Blueprints folder. I rename this folder
between videos from actor BP's to blueprints because this is not going to be
an actor blueprint. Let's right-click
Blueprint class. And the Blueprint class we're
going to create here is a camera shake search under the all classes
section under camera shake. And we're looking for
camera shake base. And then we're going
to click select down here in order to create this,
Let's give this a name. I'll call this BP
underscore, camera shake. Alright, then let's double-click
on this to open it up. So long story short, what this camera shake base
parent class allows us to do is it allows us to specify some camera
shake parameters. I realize there's a my
blueprint graph over here. There is an event graph
and all this kind of jazz is consistent with
other blueprints. But the hearts of a
camera shake parent class is that you can specify some
cameras shake parameters, and then we can play those
camera shake parameter. So what we're going
to do over here in the Details panel is
under root, shake, param, click this little drop-down, and we want to set this to wave oscillator camera shake pattern. Once we do, we can click
this as a drop-down. And I do have some parameters set up ahead of time for
the interests of time. Come underneath this F0 v
field of view settings. Open that up a couple of times. We want to set our amplitude to five and our frequency of five. And the initial offset type
is going to be set to random. Later on, you can play around
with these parameters, but I suggest you
just play around or you just play along at home. So you can see how
much this does. And then later on
you can go back and play around with it and see how much different
values shake things up. Under the timing category, we're going to set a duration
of 0.5 half a second. Aaron are blend time
in and blend time out. We're going to set to
be 0.2, 5.0, 0.25. Great. Go ahead, save this out, and we are going to next jump into our third person character. So let's head on back
to our Content Browser. Thirdpersoncharacter blueprints. Double-click on your
ThirdPersonCharacter to open it up. Now we're going to jump
over to our event graph. So we don't need this modify
health function anymore. And in our event graphlets
find some empty space. We need an event input here. So an input events, Let's do F. Well, sure, F2 seems like a
good random input event. And offer this, we're going
to drag out and type in a function node called
play world camera shake. Here with this function
node, look at that. It's a blue noted it
is a function node. We can specify a class. And this is where our B P camera shake comes
in because if we Click on this drop-down. We can slot in the camera
shake parameters that we just set up in our camera
shake blueprint, pretty handy. Now we do need to
specify an epicenter. That is, where do we want to base this camera
shake off of like, what is the epicenter? You know how earthquakes
have an epicenter? Well, camera shakes need an epicenter defined
for them as well. For this, we're going to
say, Hey, let's basis upon the capsule components. That is, this capsule components surrounding
our character. Let's base it around the
center of that, right? So we've got a
capsule components. Let's drag and drop this into the graph, will get
a reference to them. Let's drag out of this in
typing yet world location. This will return x, y, and z coordinate value. So we'll say that
is our epicenter essentially right in the middle
of our capital component. Now, we do need to specify
an outer radius here, essentially from the epicenter, how far reaching is his
camera shake into play? Let's sit. 500 is our outer radius. Just so long as our camera is going to be inside
of that radius, which if you left
your camera settings, by default, that should be it. But you can play
with this, you can expand that out if you want
to a little bit further. Then what we're gonna
do is drag off of this. And I'm going to bring in a node called spawn sound attach. Now we could just
spawn a sound here, but just to show off some
different functionality, we're going to spawn a
sound and then attach it. Attach it where? Well, we're going
to attach it to our capsule component here. Once again, I know we
don't have to do this. We could just play a sound, but let's just go ahead and
spawn and attach that sound. What sound we want here? Let's go with an explosion, type in explosion a
to the explosion Q. Although any of these
will really do just fine. And zooming out just
a little bit here. Let's drag off of this and do a spawn emitter at location. This is the old particle system. If you want to use a
Niagara particle system, you could do a spawn
system at location. The reason I'm
doing spawn emitter is because I know I've got the explosion particle
effect right in here. But once again, you can use in Niagara particle system as well. And actually I didn't
want to do spawn emitter at location my bad, let's do a spawn
emitter attached. Once again, just to
show spawning mid or attach that we can use
different function nodes here. Slot in that explosion. There it is. Where do we want
to attach this explosion? Well, I can extend this out from my capsule component like so. Double-click on that wire
to bring in a reroute node. And that should
just about do it. Now, these three function
nodes are something I would turn into
its own function. I would collapse these
into a function. Yes, you can have functions
make up another function. And the reason I
would say these three are valid to crunch down
into its own function. Because there are a bunch
of effects right there. Essentially kind of like
a player damage effects. You're going to play
a camera shake. You're going to have
an explosion sound and you're going to play an
explosion particle effects. So they all go together. It makes sense to crunch these
down into a single node. Now when we collapses
down into a function, I'm going to be leaving out these two and you'll see why
in just a little bit here. So I'm going to left-click drag highlight just
these three nodes. Then I'm going to right-click
on any one of them and I'm going to collapse
to function. So that's going to bring in a function node like
this as new function. And let's give this a new name. So over in the functions area where it created that for us, Let's hit F2 on this, and I will call this
simply player damage. Player damaged f x. That seems pretty good. Now you can see over on
the right-hand side it is already created our inputs
for this function node, but we've got a couple
here that are redundant. So I can actually simplify
this a little bit. So let me just expand out my details panel
here a little bit. I've got attached to component and attached a component too. But they're attaching
to the same components. So I can actually
eliminate one of these. That'll do just fine. Now, you're gonna get this red wire and that's going
to look hideous. So simply right-click on this, refresh the node,
it'll get rid of that. We can get rid of
this guy right here. If you wanted to, you
could rename your inputs but epicenter and attached
to component or just fine, I could delete this
out, you know, simplify this a little bit more, make this look a
little bit cleaner. Something like this. If I dive into this
a function node, notice what we've got going on. I've got my capsule components. The world location of the
Catholic component and plugging that into the
input side of my function. Inside of my function. These are getting passed
along as the epicenter and the attached two component for that sound and the emitter. Now it did actually get rid of because I deleted
out that bottom input, the attached two component actually do need to
wire this backup. But again, the same attached to component works
for both of these. So you can bring in some
reroute nodes here to kinda clean this up, like so. And actually, I'm
going to go like this, hold down Alt, left-click. This is a valid setup like that. Alright, compile and save this. Coming back to my event graph, that looks nice and clean, Let's jump in and play
and see how this looks. So I can be running
around right here. Actually let me set
my debug option to my character there so you
can see this firing off. Alright, so pressing F2, boom, you saw the camera shake
just a little bit, kind of a little bit of
a zooming effect there. So I can move around
and press F2. And now what you could
do is if you wanted to, you can jump back
into your function that you just created here. You could change out your sound, you could change
out your explosion. Let's just go with flame
for the time being, Right? Flame, flame thrower. Actually not flame thrower. I want to go fire fires. The one I want to go
with something like a fire instead of explosion
clicking play here. When you press F2. The reason I chose fires, because remember what
we were doing with that particular
function node is we responding that emitter
and we were attaching it. So that is the
difference between just spawning a sound and spawning
a sound and attaching it. I wanted to show
that off just to show a little something extra. Alright, back in our
event graph here, what you could do if
you didn't want and did not want to keep these all
collapsed to a function. You can right-click on this and you could expand
the node like this. And then it'll get you back
to where you had things. You wanted to see what
it's all inside of there. I'm just going to hit
Control Z to undo it because I like it all
collapsed to a function. Now, just a couple of
things I wanted to mention before we
wrap this video up, let me just dive back into my player damaged function here. I'm going to select these nodes, control C and control V. You cannot, you cannot have a latent node into a
collapsing of the function. What will happen is
unreal, will yell at you. So if i so bringing
a delay node, holding down the left clicking. So let's just say I
wanted to collapse all four of these
into a function. I'm going to highlight
them right-click, Collapse to function. It's going to yell at me
and say, We cannot do it. Show the message log. Let's show the message
long and it says, Hey, delay cannot be placed
in the function graph. Likewise, if I get
rid of the delay, let's bring in an event node. Let's do F eight. Sure. Try bringing in input
event or any event into your function like this right-click,
Collapse to function. You're also going to get
another message saying, Hey, you can't have an
event node in there either. So just FYI, when you are
trying to collapse to function. So guys, there you have it. Collapsing to function, highly recommended if it
is a collection of nodes that goes together and it's just some
script that you repeat again and again in various parts of your graph because that'll
do to offer this one, we will see you in the next one.
62. Pure and Impure Functions: Hello and welcome back. In this video, our goal
is to spot and understand differences between pure
and impure functions. We'll also show how you
can designate that is to make a function either
pure or impure. Now to facilitate
this discussion, I'm gonna be working inside
of my third-person character. So if you want to
play along at home, this is where I suggest you had. And once again, you
can get inside of your ThirdPersonCharacter
by coming underneath this directory and double-clicking on your
third-person character. Alright, let's talk
some differences between our pure and
impure functions. Well, for starters, Let's talk
about the pure functions. These are the green
colored functions and here are some
examples right over here. These are generally used as getter functions that
just output some data. So that's one of the keys
with pure functions. They do not have any
execution in or out pins. So if you notice our
debt times seconds, we'll just output
our time in seconds are get actual location
will just output sum x, y, and z coordinates. There's no execution in or out pins needed to get the value of, in this case, our actual
location or time in seconds. Now, when do these run? Since we don't have execution
pins that flow through these on the input side
or the output side. When do they run? Well, they run when the
return value is used. So just to demonstrate this, I've gotten event
tick that's going to take off every frame. We got this hooked into a print string impure
function node. Let's plug this into here. A float value into a string. It's going to convert
that float into a string. And what will happen
here is every frame, it's going to fire off until this print string to print
something out to the screen. When it does, it's
going to reach back through here to get
our time in seconds. This executes, it runs when its return value is called upon. So let me just go
ahead and play here. You can see how this is
returning our game time in seconds and it's counting
up from when we began play. Now something else to note about pure functions is that
they promise not to modify the state or the members of a target class in any way. In our example here is going to be our get actor location. The target here is an actor. And because we're inside of our third-person
character blueprint, the targeted here being self, would be our
ThirdPersonCharacter. What you would notice with this pure function node is it's not going to change the
state of this actor at all. It's simply going to return the location of our
ThirdPersonCharacter. Contrast this with our set actor location
impure function. No, this blue one. This one can change the
state of our target, our actor, or third-person
character here. And it can change the state by changing the location of it. So that's one of the key
differences as well. So with a pure function, you ask a question, what's an actor's location, e.g. and you get an answer and
XYZ location in this case. Now, just to show off some of these pure functions outputting some data that is requested. You've already seen the
users get time in seconds. Let me simply plug in
this, get actual location. Again, this is going to be
firing off every frame. And because I'm going
to be moving around, you're going to
see this updating. Getting my actors location,
the ThirdPersonCharacter. These are the coordinates where the ThirdPersonCharacter currently stands
within the world. Then I could simply output the display name
of our player controller. Like so. Once again, our player
controller is kind of like the puppet strings controlling
our mannequin right here. The player controller,
just as a refresher here, is set up in your
project settings. This is a little bit of a
tangent under maps and modes. So the player controller that we have set up in our maps and modes and the
project settings is that bp player controller. So it was just
outputting that name. Once again with a pure function, you ask a question. What's an actor
is location, e.g. and you get an answer. And now we turn our attention
to the impure functions, that is the blue
colored functions. One thing you'll note
about them is they do have execution in pins and pins. And that means because they
have an execution in pin, you must explicitly execute it by connecting some wire into it. Whether or not you have
something coming out the other side, that's
completely optional. But in order for this
to ever do anything, you have to have some
wire flowing into it. Another difference between
an impure function versus the pure function. And I just hit upon
this a moment ago, is that an impure
function can but does not have to modify
the state of a class. So in the case of our
set actor location here, this could modify the state. Of our target, our self here
are ThirdPersonCharacter, and it would modify our state by giving it a new location. Again, this function
is impure because it changes the state that is
the location of the class. In this case, our
third-person character within the world. So now the question becomes
with are created functions, how do you make them
pure or impure? How do you designate that? Well, with the function, select it over here and
I'm going to select our player damage fx function. If you select it over
in the Details panel, you do have a checkbox
specifying whether this is going to be an impure function or
a pure function by default, if I drag and drop this in, you can see it as blue in color. It is an impure function. However, if I was
to check this box, I could turn it into
a pure function. So this is the impure version. Let me duplicate this quickly so I'm going to right-click
on this player. Damage affects function. I'm going to duplicate it. Control D is the
hotkey for that. And I'm going to call
this player damaged FX. And I'm going to
put a space here and just call this pure. Okay, and you can see it opened
up a brand new tab here. What I'm gonna do is with
this function selected, I'm going to select the pure
option right over here. Okay? So now appears nothing has happened here in our
function graph itself. Could close this out, but I'm going to come back
to our event graph here and drag and drop this guy
down into the graph. Once again, pure functions are green versus our impure
functions are blue. Note that this one does not have execution pins on either side, whereas the impure
function does. Now, this function up
here is of no use to us the way we've
designed it because we have no way of calling this. And it does not output
any kind of data. So this is not a great function to turn into a pure function. One serves no purpose
in this forum. So I'm gonna delete this out. In fact, I'm going to delete out this function, don't need it. And I'm going to
try to bring about an example where this
could make sense. In order for this to
demonstrate, be demonstrated, I'm going to duplicate our modify health
function right here. The reason we're going to
modify our health function here is because you
remember inside of here, let me just
double-click on this. We were returning a value. So this could be a
candidate where perhaps we would want to turn this
into a pure function. But I'm not going to
destroy this one. I'm simply going to
right-click on this. And we're going to duplicate
this and I'll call this my Modify health fewer. And what I'm then gonna do here is over in
the Details panel, check that box to make it pure. I'm also going to modify a few
things about this as well. Now, I have this setup to pass this by reference
in the previous video. I'm going to uncheck that
and I'm just going to simplify this graph
here a little bit. So I'm gonna get rid of this
increment node like that. I'm going to plug
this into our branch. We're going to take our
heel or damaged mountain, plug that into here. That's all looking good. Right here. We're going to plug this
into here and we're kinda setting us back the
way we had it originally. So that's gonna be
our pure function. Looking good compiled at that. Let's go back to
our event graph. And let's, let's bring in, I've got my F2 key right here. I'm just going to steal
this event node right here. What I'm gonna do is
I'm going to bring in our modify health pure, pure function like that. And notice there's
no input pins, execution in or
execution out pins. And I'm going to print a string. So I'm going to steal
this print string node. It's already here. When I press F2, I'm going to print something to the screen. I'm going to plug this in, is going to convert my
current health into a string. And it's going to
modify some health. I need to feed this some
health or damage amount we want to modify it by. So let's go help to add. This is currently set to one. What's our health currently at? It's at ten. So that's fine. Let me
take my health to add. I'm going to plug it
into their compile. Whoops, si didn't
mean to do that. Let's go ahead and play here. And I'm not carrying
about the meter at all right now I don't really
care about that at all. So I'm carrying
about is the print out that we're going
to see on the screen. So pressing F2, look right about where my mouse
cursor is, 11121314. Again, this is set up to simply output our
current health. We don't have to wire in
execution in or out of it. So it simplifies
our graph somewhat. And in fact, that's
one of the reasons that you'd want to
use a pure function. It simply makes a graph
easier and cleaner to read. You got less execution
wires to hookup. Also, they always return the same predictable results
so long as any inputs, in this case, our health to add, are the same, you're gonna get the same predictable result. But the biggest reason to use a pure function over an impure. The biggest reason
you would want to convert one into a
pure function is Compiler benefits ensuring more optimized code
behind the scenes. I won't bore you
with the details, but you can look that
up online if you want the juicy, boring details. Alright guys, that's gonna
do to offer this one, the difference is between
pure and impure functions. See you in the next video.
63. Function Library: Hello and welcome back everyone. Well, up to this point in
our discussion of functions, we've learned how to create some functions inside
of a blueprint. And that's all well and good
if you have a reference to that blueprint in which
the function was created. However, what do you do
if you want to create a function and have it accessible in all
of your blueprints. What can you do then? You don't want to have a specific reference
to a blueprint. You just want to
make it general use function that's
available anywhere. Well, in that case,
you want to create something known as
a function library. Our goal in this one is
to learn how to do that in what a function
library even is. Function library is a
place to store functions that can be accessible
from any other blueprint. Alright, back here in
our content browser, Let's go ahead and create
our function library. And I think a
Blueprints folder under the scripting category
would make sense for us. So let's right-click
it some empty space. In the blueprints category, we've got this fly-out
in, in the flyout menu. It says blueprint
function library. That's the one we want to
go ahead and click on that. Let's give this a name. I'm gonna call this my
underscore functions and I'm going to
all caps it just to make it very obnoxious. And then I'm going to double-click
on this to open it up. Now, once we do that, it's going to prompt us to
create a function right away. And it has a tab of that
matching name right away. For us, I'm going to call
this function we're about to create change mesh material. And this function is going to do exactly like the name suggests. Now, I'm going to add a couple of inputs to our entry node here so we can select that or selecting the function itself
will allow you to do them. So the first input I'm
going to add is going to be called actor. And we're going to change
the input type here to be simply an actor. So under object types, I just simply did a
search for actor. Under object types, actor, we want an actor
object reference. And then our second
input that we want here, creating another one is
going to be called material. And we're going to
change this type to be simply type in material. And under the object types
material in the flyout menu, we're going to change it
to an object reference. Alright, so those are
gonna be our two inputs. We're going to have
one output here. So I'm going to click
this plus button. In doing so, we add a
return node right away. Let's call this output
successful change question mark. And then we're going to give
this a type of Boolean. So we're going to output on the other end of this
function node whether or not we successfully change
the material of our mesh. So create a little
bit of space here we're going to be adding
some nodes in-between. The first thing
we're gonna do is we can go ahead and
break this wire here. I'm going to hold down the
Alt key and left-click. We're going to drag out of our actor input
and we're going to find out if our actor is
a static mesh actors. So we're going to cast
to Static Mesh actor. So essentially
asking the question, hey actor that we're plugging
into this function node, are you a static mesh actor? And if so, we want to do
something and if not, we want to do something else. Now the thing we
want to do firstly, is we want to toggle a variable whether or not
it's going to be true or false based on if this cast fails or is true that it
is a static mesh actor. So we need to create
a variable here. We've got a section
called local variables. Now, we're going to
be talking about what a local variable is
more in the next video, a lot more in the next video. So just play along right
now and then we'll get to the differences between
local and class variables. In the next video, we're gonna be
creating a variable here, a local variable. This one's going to
be called success. Ful, change question mark. And I hit the wrong key there. So let me try that again. Success. I'll just call it success change question mark,
that's good enough. And I'm going to drag and
drop this on top of that, I'll put execution pin, drag and drop on
the cast failed. We want it twice. So if it in fact is a static mesh actor, it'll shoot out of this
exhibition execution wire. And we're going to
say, yes, the success, we did successfully changed it. And if it failed,
we're going to say no, we did not successfully
change it. So that's gonna be set to false. Next we're going to simply
drag out of here and type in play sound 2D. We're going to play a sound
confirmation sound effect or a fail sound effect. For up here, if it is
successful in changing, we're going to call the
sound compile success. That is one we're looking for. That one is in the
engine folders. So if you don't see that
you're playing along, you can click on that
little gear there, turn on your engine content. So we'll play that sound
going to hit Control C, Control V to paste
that down here. If this casting fails, we're going to do
failed, compile failed. Either of these
will do just fine. Then we need to do a little
bit of work down here. So what we wanna do out
here is grab out of our Static Mesh actor
and we're looking for the static mesh components. So Static Mesh actors consists of a static
mesh component. That's what makes
him a static mesh. And out of this, we're
going to drag out and type in set material. There is a node
we're looking for. And the material we want to
change it to is going to be whatever we input
into this function. So we're going to
drag right here, I'm going to plug it into here, but I'm going to double-click
on this wire to bring in a re, route node. Okay, we're almost finished
here, we're almost finished. So what we're gonna do here next is we're going
to take this output. We're going to plug this into our set material because if we have determined that it
is a static mesh actor, we want to play this out and
indeed change the material. We're going to plug this
backup here at the cast fails. It is not a static mesh actor. We're going to
come right through here and we're just gonna go right back to
the returned node. We do not want to change
the material in this case. Now for this successful
change Boolean variable, well, we can just plug
in the result of this. We're setting it
either here or here. The result of this,
we can get it and simply plug it into there. So that is going to
be our function, our loan function that
is going to exist and are my functions library. Let me go ahead and compile
this and save right away. Next, let's head on over to our ThirdPersonCharacter
Blueprint because we've got some work to do
inside of there in order to show off this function. So if you forgot where that is, contents third-person blueprints
double-click on that to open it up inside of our
ThirdPersonCharacter. Once you come on down
to the Event Graph, Right-click in some
empty space in simply type in my functions. And you can see as we
start typing it in, it shows our function library
under the class section. So under the class, my functions, function library, we now have access to that
function that we created. It's available inside
of this blueprint and any other blueprint. Fossa, click on this, we can see what our function
currently looks like. It takes in an execution wire on the input side,
it can output one. It can take an actor, it can take a material, and it can output whether or
not we successfully change the material on an input actor will come back to this
in just a little bit. But for now, delete that out. We're going to head on
over to our viewport tab, and we're going to add a
new component over here. So let's go ahead and select
our Capsule Component. And under this we're
going to add a component. And we're going to add
a sphere collider, sphere collision. Now this is going
to act as a sort of invisible hand, if you will. So I'm gonna give this a name
and call it simulated hand. And I'm going to place
it out in front of our character here a little bit. So I'm going to
change the x location to be, we'll say 60. And I'm going to change the
scale universally in X, Y, and Z 2.5, something a little bit smaller because it is attached to
our Catholic component. When we rotate our
character around, this is going to be
rotating around as well. What we're gonna be doing
is we are going to be checking to see if
this is overlapping something and then
we're going to change whatever it is overlapping
that's gonna be, if it's overlapping, a chair, we're going to change that
static mesh into a gold share. We're going to change the
material of that Static Mesh. One more property that
I do want to set up here is under the
rendering section, I want to uncheck hidden
in games so that we can see where this is
out into the world. Alright, so with
that all set up, we can save this, jump back to your level here. We're going to place some
static meshes in our level. Now I've got some
specific ones in mind there in the
stirrer content folder. Really any static
measures gonna do. But under the Props folder, I'm going to place a chair
is around a little bit. I'm going to place one of these guys wheel that around
a little bit and I'll place, how about a basic cylinder C. We can find one of
those under here, or the place actors tab, but I'm going to come
right under here shapes. Let's do a cylinder. And I'm just going to scale
it up a little bit like so. With all three of
these selected, I'm gonna hold down the Control
key and click left-click. So all three of
them are selected. I want to set
something in each of them and that is to ensure that they generate overlap events so that we can
detect that we are overlapping them with our
quote, unquote simulated hand. So with all those selected, I can simply type in
the search bar here. Burlap. What I'm looking for is
generate overlap events. So go ahead and
check that again, make sure you've got
all three selected. And then what we're
gonna do is jump inside of our third person
Character Blueprint. So head on back there. Thirdpersoncharacter, head
on over to the Event Graph. And we want to do something, but our simulated
hand is overlap, so find some empty space. And with your simulated hand selected here you can
right-click on this. We're going to add
an event for when we begin overlapping
that component. Going to head into our graph way down here because it
wants to, that's fine. So what we're gonna do is
out of our other actor, we're going to drag
out and we're going to change the mesh material. And I can simply just type in change or begin to
type in change. And it is smart enough
to know that, hey, are you trying to
find that change mesh material function that lives inside of your function library. Yes, it does. Now note that this can output, this simulated
hand was something overlaps that it can
output and other actor. And in this case
it's going to output an actor object reference. This actor input on the
change mesh material is looking to take in an
actor object reference. Isn't that convenient. So we're going to
detect if it is overlapping some other actor. And then we're going to
change the material. I'm going to change the
material to simply be gold. Gold lives in R star content. And what we'll do here is
we'll bring in a branch node. I'm going to type in branch. Alternatively, if you delete that out and drag out of here, this is a Boolean output. If I type in branch here, it'll hook up both wires at one. It's pretty handy. Then let's simply print string. I'll bring in a couple of
these Control C, Control V. And this is going
to be our scripts. So up here, if this
is successful, we're going to print
out cold in. Here. We're going to
type in no change. All right, go ahead and
compile and save that. Let's give this a
playwright away. So clicking R plus button, I will set our
debug object to be our ThirdPersonCharacter
that has spawned in and expanding this out
just ever so slightly. Alright, if I look in
front of my character, there's that red sphere, that's my simulated hand. You can see it pivots around, rotates along with my character. So when I overlap the chair, you see that it did change
the material pretty sweet. Changed the material there, and our cylinder changes
it there as well. That is a good global
function, if you will. We can use it inside of our
ThirdPersonCharacter here. But let's also show
how you could use this inside of your Level Blueprint. Because after all, what's
the point of creating a function library
if you can't access the functions inside
of it from anywhere. Heading back to our level
tests map tab right over here. Let's open up the
Level Blueprint and I'm just going to
bring in and input key. Any input key will do so. I'm right-clicking
in some empty space. Let's try the seven key. And it'll think I'm
using the seven key for anything else here am I know? By the way, if you click under your grass here and
expanded grass out, it'll show you what different
events you've got in there. So for the seven key, I'm going to drag out of here, do a search for
change mesh material. And once again, because
this function exists in our created a
function library and we can find it in the
Level Blueprint. Sure. And I need to supply
an actor here. So let's choose
one of our actors. I'm going to make
sure that I've got my cylinder here selected. Jumping back into
my Level Blueprint, holding down the left clicking. Let's plug that in there. And I'll change
the material here. Let's go cobblestone. Something cobblestone. Alright, compile, save. Let's play. Set our debug object
to our level. Bring on back our map. And of course, I can
touch these two. They're still going
to change the gold. Now if I touch the
cylinder here, that would turn to gold
because that's all that's set up in my
Character Blueprint. But if I press the
seven key here, we can see that we'll
turn it to cobblestones. So a great global function
that we've created there. Alright, let's finish out this video talking
about the pros and cons of functions in
a function library. Well, the pros would
include you can access that function from
inside of any blueprint. It's a great time-saver. If it's a function you can
use in many places, you know, you don't have to
write the same script in multiple places, multiple times,
that sort of thing. Now the cons, the cons
would include having a harder time referencing
blueprint specific data, e.g. my third person
Character Blueprint. If I add some function like say maybe a modify health
function that was very dependent on some variables and lived inside of here. Well, that type of
function will be better off inside of that
specific blueprint. Or if I had some
function that was very dependent on some
of the components inside of a given blueprint. That function would
be better off in a Blueprint class itself as opposed to a
function library. Alright guys, that is
going to do it all for this one in this discussion
of a function libraries. See you all in the next video.
64. Local Variables: Welcome. In this video, our
goal is to familiarize yourself with the concept
of local variables. Now, in this video, we'll break down what
local variables are, how they differ from
class variables, how we can create and use them, and what kinds of things
you need to know about regarding their accessibility
within blueprints. Now the last video we
use a local variable, one called Success change, a Boolean local variable. And I mentioned that
we would come back to it in a future video, that is this future video. Now, note something
about local variables. We can only create local variables here
inside of functions, inside of the function library, the blueprint function library. We cannot create
class variables. We only have a local
variable section. So what the heck are
we talking here? Class variables versus
local variables? Well, to help facilitate
this discussion, I've got my ThirdPersonCharacter
Blueprint open. Jump on over to here. And if we look over in our ThirdPersonCharacter
Blueprint panel, we have a variables section. These are variables that
belong to our character class, so we can call these
class variables. But you'll notice something here in the My Blueprint panel. We do not see local variables here in
the function library, we see a category
called local variables. Where is it in a
Class Blueprint, we only see a variable section. Well, in order to
see local variables, you have to have a function selected or your
construction script as well. So if I select my Modify
health function right here, Let's double-click on
that to open it up. You may have noticed that
as soon as I did this, I now have access to a local variable section
right down here. If I jump on out of here, go back to my Event Graph. Note that the local
variables will disappear. It's not there anymore. Alright, so let's dive back into our modify health function. Alright, now let's talk
some of the differences between class variables
and local variables. Well, for starters,
when you're creating a variable right here in
the My Blueprint panel, you are creating
a class variable, one that belongs to
this parent class. Now, any variable you might
want to get or set from another blueprint should
be a class variable. Now, just to give
an example of that, let's say in your
Level Blueprint, you had a reference to your ThirdPersonCharacter
and you wanted to modify your third-person
character's health variable. Maybe there's a zone
within the level that does damage or maybe heals the
ThirdPersonCharacter. Well in that case, in order to access our
ThirdPersonCharacter is health variable from inside
of the Level Blueprint. You'd want to make sure
that this health variable existed as a class variable. Now as for local variables, they can be created inside
of a function graph. Local variables are only visible to the function
that they were created within and not other
functions or the event graph. Now let's go ahead
and create one here inside of our modify
a health function. Now I could create one by
clicking this plus button right over here under the local
variables category. However, I'm going to create one by right-clicking on a pin. So long as you're
trying to promote to a variable inside
of a function, you have the option to
promote to a local variable. So I'm going to right-click
right here under my clamp float Tmax. And right-clicking, we
are going to promote to a local variable that's going to create this
variable right over here. So let's call this
my max health. And what you'll
notice now is that this local variable does not exist in any other
function graph here, if I go into my player
damaged fx function, double-clicking on this, that local variable
cannot be found. Likewise, if I was to right-click
inside of this player damaged function and I
search for max health. It's not available on here. If I go over to my event
graph and I searched for it, I don't see any local variables down here and
either right-click, max, health is not here as well. In fact, if I uncheck
context-sensitive, it doesn't show up. This max health
variable inside of Maya modify health function is
local only to this function. And if you don't see
it here anymore, you can click this
little drop-down arrow and it will show
you where it is. Once again. Now at this point you
may be wondering, what's the point of
local variables. Why do I even need them? Why can I create all
class variables and use those local variables do help reduce the clutter
for things that are only relevant within the
context of a function. You don't want to
populate a huge list of class variables here when some may in fact only be needed
within a given function. So for that reason,
organizational reasons, it's a good idea
to simply create a local variable helps keep
things neat and clean. Secondly, it also helps guard
against your own mistakes. I've got two variables here. I've got health and max
health that are very similar. Now maybe I want to
ensure that, hey, I can never modify
my max health. It's only going to be accessible from
within this function. Well, that's a good
candidate to turn that into a local variable
to ensure that I don't accidentally
modify this variable from within another blueprint. Alright, let's show this off a little bit further by creating a brand new function
for starters here inside of our
ThirdPersonCharacter. So under the functions category, we're going to add
a new function. I will call this turbo run, which is going to do exactly what you
think it's gonna do. Now inside of here, what
we're gonna do is bring any reference to our
Character Movement Component. Inside of our Character
Movement Component, we have access to a parameter
called max walk speed. We want to do something
with our max walk speed. So it's drying out
up here and bring in a reference to our
max walk speed. We're going to get that value, which by default
here starts at 500. Then what we're gonna do is we're going to drag out a here, hit the plus button, we're going to add
something to it. Then we're going to set
our max walk speed. So dragging out of our
character movement once again, set max walk speed. We're going to go like
this and like this. So now we want to add a
local variable in order to determine how much
of a speed boost we want to give our character
when we terrible run. So this is what I'm gonna do. I'm gonna add the value
right here, 2000s. And then I'm going to
right-click on this pin. We're going to turn this
into a local variable, so we're going to promote that. And we're going to see
that populated down here. Let's give it a name
called turbo speed boost. And now you can see because we promoted it with that value
already set in there, it's going to set that value
right in there as well. So that's a handy little
trick that I like a lot. Alright, let's compile that. Make sure that that's
looking all Skippy. Then let's jump into
our event graph. And I'm going to find
some empty space here. And we're going to bring
in an input events. Let's see what we've
got available here. Now we've gotten access to
a lot of different things. I'm going to right-click.
We'll do the two key. Sure. Let's do input
or actually type in keyboard to right there. Bringing a two key. Off of this, we're going to drag and drop our terminal run. And if we release the key, what we wanna do is
we want to bring in our Character Movement
Component like that. And then we're going
to drag off of here, do another set, max, walk speed. Remember the default
value was 500, so let's set it back to 500 as soon as we
release the two key. So this is gonna be
our Turbo run script. So notice are terrible
run function right here. It has that local
variable inside of it. We can double-click
on that, that'll jump into that function. We got this turbo speed,
boost, local variable. Alright, now let's go ahead
and give this a play. I'm going to compile here,
save and play, set our debug. Object to our
ThirdPersonCharacter. We can run around just
fine looking good. However, when I
press the two key, we zoom just fine. We're terrible running
and I release it and I slow back down. To summarize here, you can search for and find local
variables from within the graph that they were
created are terrible run here we could search for and
find this local variable. You cannot search for and
find a local variables within the event graph of the blueprint they
were created inside. So in the event
graph right here, we cannot find that
local variable. You also cannot
search for and find this local variable are turbo
run local variable here. You cannot find that if you search for it within
another loop, another blueprint, even if
you have a reference to our ThirdPersonCharacter
here you cannot find a reference to this. Now, one last note
about class variables. This is worth noting that
if you click this class defaults button inside
of any Blueprint. Any Blueprint class,
you have access, sorry, not Class
Settings, class default. You have access to all of
your various class variables. Here they are right over
in the My Blueprint panel. Health can jump, et cetera. Over in our Details panel, we can find them all
right here as well. Note that if you were
to change it here, say we were to change
our health from ten to say 100, Enter. And now I was to select
my health variable here. It is going to update
that default value. So it doesn't matter
where you change it. You can change your variable
values from here or the class defaults section thought I would point
that out as well, right? That'll do it all
for this video. See you in the next one.
65. Functions Things to Know: Welcome back. In this video, our goal is to cover
some really good things to know about working
with functions. Now, these are
things that didn't necessarily warrant
a full video, but should certainly
be touched upon when discussing the
topic of functions. For this video, I'm
going to be opening up a variety of blueprints, ThirdPersonCharacter level
blueprint the likes. So I'm gonna be starting off in my ThirdPersonCharacter
Blueprint content, third-person blueprints. The first thing we are
going to be touching upon here is how to debug a function. Now, this is gonna be something that later
on in the course I'm going to be dedicating
a whole module towards, but it is worth
mentioning here as well. So here I have a
very simple script. When I press the two key, I'm going to make my
character terrible run. And when I release
it, I'm going to return back to my
normal movement speed. Now you can see I've added
a comment on this node by right-clicking and
adding a node comment that if I press F9, F9 acts as a toggle here and you can see how it changes
that tool tip. I can add what is known as a
breakpoint that's going to allow the code to stop
right here at this point, as soon as we reached this
point in the execution chain. So you can imagine if you had a whole bunch of
nodes wired together, it would freeze the game up as soon as you hit this point. Now why would you
ever want to do that? Well, sometimes you may have some unexpected consequences
going on in your scripts. Something is happening
that you weren't intending on
happening, whatever. And you need to freeze the game, to step through the code, step through your script to
find out what's happening. That is the use of a breakpoint. And I'm just going
to briefly show off how this can
freeze your game. So I'm going to press
the play button here. Notice that I do have my
breakpoints that here. You can also right-click
and remove a breakpoint, disable breakpoint, or toggle that breakpoint,
turn it on or off. Here we go. Planet. I'm going to set my
debug object to be my ThirdPersonCharacter
and bring them on my play window again. So as soon as I
press the two key, It's gonna jump immediately to that script and freeze
the game right here. Now from here, with this node selected and you can see that
giant red arrow being like, yep, that's the guy that
we're trying to select. You have a series of
buttons up here that allow you to decide
what you'd like to do. From here, you can locate the currently active node,
which it currently is. We can step into this node
and what that's gonna do is gonna jump me inside
of the function itself. Let me just go back
to my event graph. I could step over, meaning if I had some
more nodes over here, it could stop me on
over to the next one. And then this one right
here is to step out of this node to be executed
in the parent graph. So again, I have a
whole section of videos upcoming that
we'll talk about this, but breakpoints, you can
add them to any node. I'm going to stop this
year by simply clicking on the node and toggling on
and off with the F9 key. Alright, next up for
any of your functions that you have created
in the Details panel, you have the ability
to add some keywords. And what this enables
you to do is when you right-click in
some empty space here, if you search for any
of your keywords here, it will find that function
that you're looking for. So we could do
something wacky here. I'm going to add keywords
here such as purple. And I'm going to
separate them with a comma monkey comma dishwasher. And if you get that joke
and where it came from, my hat is off to you. Compile save. And now if you do a search
for right-clicking purple, it finds function terrible run. Monkey, find that function
as well as dishwasher. And I just type in dish
and it already finds it. Now note that this
works not only within the blueprint that
that function was created, but if I go over to my level
test map level blueprint, as long as you have a reference to that blueprint in here, I can talk to my
ThirdPersonCharacter Blueprint. I can drag out of here. Type in purple, finds that
function monkey or dishwasher. So there you go. Keywords. That's
how you can find a function using any key word
or words of your choosing. And next, let's explore this
compact node title field that you have
available to you for any of the functions
that you have created. What this allows you to do is to simplify your Node a little bit. I don't use this a whole lot, but maybe some of you will
like to work this way. So I'm going to change
my node title here to be something other than
player damaged effects. I'll simplify it and just
simply put in player FX. And as soon as I hit enter, this title is going
to go bye-bye, as well as all of
these pin label. So here we go, pressing Enter. You can see now I've crunched this node down into a
simplified version. Player effects is now the compact node
title of this node. And all those pin
labels have gone away. Now you can still see
what kinda datatypes these pins are looking for by simply mousing over to them. That's gonna be
looking for an object, a vector, as well as a sink
components respectively. Maybe some of you will
prefer working this way. I however, do not, but I thought it would
throw it out there anyways. Next, I want to talk about what this access specifier field does for a function
that we have created. However, in order to do this, I need to create
a child class of our ThirdPersonCharacter here in order to really do this justice. Now, class inheritance
is a topic I will be talking about
later on in the course. However, again, in order to show off this access specifier, I need to do this now. So back here in my
content browser, I'm going to right-click on my ThirdPersonCharacter and I'm going to create a
Child Blueprint class. And I'll leave this name
going to just hit Enter. And what I'm then going
to do is go back into my ThirdPersonCharacter and talk about this access specifier. So we've got three
different settings here, public, protected, and private. So this determines
which blueprints can gain access to a function. In this case, our
modified health function, public is a default setting. Any other object can call this function so long as
we have a reference to it, meaning I can use this
modify health function here within this blueprint
that we've created with him. I could also access it from
our Level Blueprint again, so long as you have a reference to your ThirdPersonCharacter, I can find my God, if phi health there it is. Jumping back to my
ThirdPersonCharacter. Let's now change r, modify health from a
public, too protected. Now, this means the function can only be called by the
current blueprint, meaning our
ThirdPersonCharacter Blueprint, as well as any blueprints that derive from the
current blueprint. So can I find it here? Yes, I can drag and drop. I can access it there. Make use of it there. If I jump to my child
ThirdPersonCharacter, and I jump over to
the Event Graph, and I right-click and I do
a search for modify health. There's that function. I can find it here as well. This shows that our
parent class here is our bp ThirdPersonCharacter. So yes, you can use it within the original blueprint
that you've created. You created it in
or the child class. Lastly, let's jump back to
our bp ThirdPersonCharacter. Select our modify health. And let's change this from
protected to private. Now, this means the
function can only be called from within the
current blueprint. So yes, I could drag
and drop this in here. I could call this function. However, if I was to go to my level test map,
dragged out of here, do a search for
MOD if phi health, I can only find
that pure function. Because if I look back in
my ThirdPersonCharacter, remember I currently have two versions of the
Modify health function. The Modify health
pure is currently set to access specifier public, meaning I can find it
within the Level Blueprint. However, modify health is
currently labeled as private, meaning that I
cannot find it here. Modify health? Nope. Now if I go to my
child blueprint, you can see that this is still out here and that's
because it was still out here prior to me changing this access
specifier to private. However, if I was to
go back into my child, delete this out, Right-click, do a search for modify health. I can no longer find it. So just a little bit of
a table there as well. So the access specifier, you've got public,
protected and private. Now next up, I'm
going to show off what this call in
editor checkbox does. But in order to do this,
I'm going to create a brand new function over here. I'm going to click
this Plus button. And I'm going to call
this my Super jump. Inside of this function
that I am creating. I'm just going to drag off
type In launch character. And the only thing I'm
gonna do here is change our z velocity to be 2000. Now you'll notice that our
function here is identical to just this launch
character function itself. But in order to show off this
call in editor checkbox, I wanted to do
something super simple. So with this function created, go ahead and select
that and click on this call in editor checkbox, what this allows us to do, Compile and Save here as well. Let's jump back to
our level editor. I'm going to make sure with
my three dots selected here. I'm going to play in
selected a viewport. I'm going to click Play. Now with me playing in
my selected viewport. I'm going to select my
ThirdPersonCharacter. And I could do a
search for Super jump. And we can see under
the default category, I've got this super jump button. If I click on this, it will
simply call that function. Now you'll notice that in the BP ThirdPersonCharacter
itself, I only created that function. I have no input key to
actually call that function, but this is a great
way to simply test out the functionality
without any input keys or anything of that sort. You can simply test to see
what it does straight away. Now there is a
little gotcha here that you should know
about and that is. Note that my Super jump, let me stop playing here. Note that my function
here does not have any inputs or outputs. If I was to select something
like player damaged effects, you can see that I've
got some inputs here. I don't have any
outputs on this one, but I could return something. Let's click on this
and do return. And we could return the
spawn emitter attached. We're going to drag and
drop that there like that. Now if I was to take my player
damage affects function, I'm going to click
on this call in, editor checkbox compile, save. Let's jump back
in here and play. Going to select my
ThirdPersonCharacter, scroll on down. I'm going to find those buttons
once again, there we go. Under the default category, I can find my Super jump
call Editor button. However, I don't find
that same button for the player damage effects even though I have
that box checked. Now why is this? Well, I don't know the exact
answer to that, but I suppose
because it would be pretty difficult
to manually call a function that is reliant on
some data that needs to be input into the function itself
in order to work properly. Now next I want to point
out that for any of your created functions within
the My Blueprint panel, if you right-click on them, you have the option to
convert function to event. What the heck does
that even mean? Well, let's dive inside of our terrible run,
a function here. And I can do that by simply
double-clicking on it. It'll open up that
function graph. And notice that this
function is simply taking my characters
max walk speed, That's how fast they're moving. It's going to add a little bit
of a booster there and add that together to create
our new Walk Speed, our new movement speed. So notice this setup right here. I'm going to jump back
to my event graph. And what I'm gonna
do is I'm going to right-click on my
terminal, run a function. We're going to convert
this to an event. And when I do, it is basically
going to break out all of that code that was inside of that function that
modified my characters, max, walk, speed, and in all places it in the
event graph itself. Now notice that our terrible
run function no longer exists here in our
function area. Instead, we see a custom event called turbo run,
that same name. Now this needs to be called in order for this script to run. So something to point out here, you cannot do this if the
function has outputs. And by that I mean
let's double-click on our modify health
function right here. This function does
have an output. So if I try
right-clicking on this, in converting this
function to an event, you're gonna get a warning
saying you cannot do that. So I thought I would point that out while we are here as well. Now, why would you ever
do something like this? Why would you ever convert one of your functions
to an event? Well, perhaps it's
easier for you to read your script in this sort
of broken out manner. Or perhaps you decided this is better off as a one-off script instead of a function that
you could see yourself wanting to use multiple places. Now a couple more
things here. Before we wrap this video up. Remember, you must compile that is to press this
button right up here. You must compile to access new functions
from other blueprints. If you added a new
function here, you created a new one
and you wanted to access it from say,
your Level Blueprint. You need to compile first
before you can do that. Another thing that's
worth mentioning here is you can have functions inside of other
functions that you create. So I showed that off here by having a function
that I created called Super jump and having that function inside
of that function. And last but not
least, for functions, you can't have latent
nodes inside of here. And by that, I mean, I'm talking about delay nodes
right-clicking. And I'm just going to do
a search for delay here. Can't seem to even added here. However, in the Event Graph,
you right-click delay. You can find delay or
retrievable delay. You also cannot add a node
known as a timeline node. So important things to
remember there for functions, right guys, that's gonna
do it all for this video. Good things to know. We will
see you in the next one.
66. Macros Overview: Alright, over the next few
videos here we are going to be shifting our attention
to the topic of macros. And specifically in this video, our goals are to learn
what macros are, discuss how they are similar
or different to functions. We're also going to
explore a couple of common pre-existing macros
and how they're constructed. And lastly, we're going to
talk about where we can find macros within blueprints. So first of all,
what is a macro? Well, a macro is
essentially a collection of nodes that does something it's similar to a function
in this regard. And I have a couple of macros
right here in front of me, inside of my Level Blueprint. Now, unreal does come
with a whole host of ready-made macros
that you can use. It's from the standard macros
in the engine content, which I will show you in
just a little bit here, you can create your own macros inside of a Blueprint Class, a level blueprint or a
blueprint macro library. And again, over the
next few videos, we'll show how to do all that. So first of all, let's
explore some common macros. And as you see before, you
have a couple of macro nodes. One is the compare float macro, the other one is
in, is valid macro. Just a moment ago I made, I mentioned that a macro is
essentially a collection of nodes that does something
similar to a function. And we can see this
by double-clicking on either of our macros here. And I'll just double-click
on compare float here. In doing so, I'm
gonna be opening up a new tab called
standard Macros. This is a macro library
that consists of a bunch of macros that already
exists here in Unreal. And note that we also opened up a compare Float tab within
this macro library. And this shows off all the
nodes wired together to create this compare float macro. Over on the right-hand side, we can see that if we
select our input here, we can see that this particular
macro compare float belongs to the math
float category. So if I was to drill down here in our collection of macros, math float, we can see there
is our compare float macro. Now you can expand all of
these out to see all of the different macros that exist within this macro library. Now the reason I'm pointing this out is because
if I was to jump back to my level blueprint
or any other blueprint here. And simply right-click and some empty space
and I'm gonna do a search now for compare float. We can see that is the category where this
particular macro is found, the math float category
as specified right here. Math float. Now let's quickly hit upon some macro and
function similarities and differences here. So starting with
the similarities, both macros in functions are time-saver as they can store
a commonly used sequences of nodes complete with
inputs and outputs for both execution
and data transfer. So instead of say, placing this sequence of nodes in multiple places
throughout your graph, you can just create
a single macro or a function can do similarly. And that'll save
you time because you're condensing these nodes down into one another
similarities. You can edit the
functionality of a macro or function in a
central place, a graph. Right here we have our
own compare float graph. You can edit the functionality
here and it'll propagate that change to any
other macro that you've placed in any
other blueprint. Another similarity is
that they are reusable. You can reuse this macro in
plenty of other blueprints. You can have it in
multiple blueprints. You can use the same macro
within the same blueprint. Also, macros and
functions both allow local variables and we have a whole video talking
about local variables. But essentially a local
variable is a variable that is just referenced and used by
that individual function, or in this case a macro. Now the difference
is macros can have multiple input and
output execution pins. And we can see that here in
our compare float macro. If I select this entry node
right here, Check this out. We have one execution input, but we've got three
execution output pins. And if that's not clear enough here from our input and outputs, Let's look back at
the final node, back in our Level
Blueprint, check it out. We've got one execution
input and three outputs. Now you get to name
these by the way. So if I go back to our
standard macros here, you get to input what that name is does not have to be exact. You can put it as a symbol, symbols and letters, whatever
you want to put there. One other difference,
and this is key, this is very much
qi Macros can have latent nodes in them
while functions cannot. So when I'm talking
about here, once again, jumping back to my
Level Blueprint, let me just scroll on
over to the right here. I'm just in my Event Graph, so I'm not within any macro
or function graph itself. These types of nodes right here, latent nodes, ones with
this little clock icon. If I mouse over this node, this delay function,
it even says in the tool tip at the very
top that is a latent node. That's what this
clock icon means. That is a time sensitive node. Any late node like that, or a timeline node. Anything with dealing with time, you cannot place
those in functions. However, macros, it's okay. Lastly, macros cannot be
called from other blueprints. Like a function can. Just to quickly
demonstrate this. If I was to go into my
third-person character here, I'm just going to create
a quick temporary macro. I'm going to call this my temp. I'll call it macro temp. How about that macro temp? I'm going to compile this. And then in my Level Blueprint, if I find, I've got my four key, if I was to drag out
of this and I do a search now for macro, I cannot find it. I cannot find that, whereas
I could find something like my super jump function. Super jump. There it is. So you can't call
macros that live in another blueprints
from another blueprint. Alright, so where can you all
find macros within unreal? Well, there is an existing
macro library here. We've got our standard macros. Well, where does this exist
in our content browser? If I jump back to
our level tab here, you have to make
sure that you have your show engine
content checked here. And I just went under
Settings show engine content. And here is the pathway at the all engine Content
Editor blueprint resources folder right there. And here is your
standard macros. And you can see from
the tool tip there the blueprint type
is a macro library. By double-click on this, it's just going to jump
back into that tab. Here's a whole bunch of different macros that are
available from any blueprint. Where else can you
find some macros? Well, I have some available
here in my Level Blueprint. If I jump on over
to my node types graph in eyes zoom in on my
flow control nodes here. All these are flow
control nodes. We're going to have
a whole section of the course dedicated
to flow control loans, but these are all macros. So you're gonna notice that
macros have this gray header. That's an easy way
to identify a macro. It's got this gray header. And just to prove that
these are macros, if I double-click
on any of these, let me just double-click
on my gate here. What do you know? It jumps me back to
my standard macros. That is a macro indeed. What else can we find macros? Well, you can create
your own macros, and I can show that off by here in our
ThirdPersonCharacter. We did create a temp macro. Of course this is
empty right now, but it has a section for
macros are Level Blueprint. It's got a section for macros so you can create them here. Any other blueprint,
you can create macros within which we're gonna
do actually next video. So guys, that is going
to do it all for this one on our
overview of macros, we'll see you in the next video.
67. Creating Macros: Welcome. Our goal in this video
is to learn where and how to create a macro and to help better drive home those differences between
functions and macros. We're going to
create our macro in such a way that it
would be impossible for a function to
duplicate because we're going to include some late
nodes inside of our macro, as well as having a multiple
execution output pins, which again, a
function cannot do. We're gonna be doing
some work here inside of our bp ThirdPersonCharacter. So there's the
pathway to find that, as well as our Level Blueprint. So have those two handy. We're going to start inside
of our ThirdPersonCharacter. Now, inside of here,
simply come down to the My Blueprint panel and in the macro section,
click the Plus button. And we're going to create
a macro called on fire. What a great name
that's gonna get you excited for what's to come. Alright, now select
your input node here. Create a little space
between the two here. And with either be selected, I'm going to add some
inputs to this coming under the Details panel
clicking the plus button. Now I'm going to add
a series of pins. The first one, I'm
going to simply call in and press Enter. Now we can set the type of pin
that we want for an input. If we click right here, we've got a bunch of variables
that we can choose from, as well as an execution pen. You did not have this option
inside of a function. We're going to add
a few more here. So click this plus button again. We're going to call this
one effect, one delay. And this is going to be a float. And clicking this
plus button again, this is gonna be
effect to delay. And then plus button again, and we're going to call
this effect three delay. Those are gonna be floats. Then we're going to
add some outputs here. We're going to add
three of them. The first one is going to
be called spawn effect one, and this is going to
be an execution out pin execution output in that. Finally took that we're
going to add two more. They're both going to be
execution now pins as well. And they're gonna be
called Control C, Control V, spawn effect too. And spawn effect three. Right? Now with
that taken care of, Let's put in the nodes that
are gonna go in between here, we really don't need
that much space. So out of our pin right here, we're going to drag out and
bring in a sequence node. This node is going to fire out of these pins sequentially. We can add multiple
pins right here. I just need to add a third. So as soon as we come into this, we're going to fire
first, second, and third in such
rapid succession that is going to
seem instantaneous. We're also going to
add three delay node. So if you hold down the
D key and left-click, you can bring in delay at nodes holding down d
and left clicking. And we're going to hook
them in like This, 12.3. And the amount of
delay as good to come from outside of our macro here. Whatever is gonna be plugged
into our delay or we can hard set it within the node itself. So we're
gonna go like that. And then out of
these completions, we're going to plug these
into our outputs like this. So a very simple macro, we're just take it
in a few delays. We're going to then
sequentially go 12.3 out of these delays and
then we're going to output. So just to show what this particular macro is going to look like back
in the Event Graph. Let's place one of
these out here, drag and drop our macro. That's the final look. So this right here translates
into a macro node, a, a gray headed node
that looks like this. We've got our three output pins. Are for input pins three floats
in one execution in pen. Now, it's worth pointing
out here that because our macro has some latency
nodes inside of it, that is our delay nodes. We see that little clock icon, that latent icon right
here on the macro itself. Thought I'd point that out. Alright, let's build
out our script here, making use of our macro. So I'm going to start
off with a custom event. So right-click. We're
going to bring in a custom events to
search for custom, add a custom event I'm
going to name this player, catches fire exclamation points. And I'm going to
plug this directly into our on fire macro. And now I could plug in some
float variables to this. I liked the flexibility of
this macro in that way. However, in the
interests of time, I'm just going to
input some numbers. I'm going to hard-code
that if you will. So 0.2 is gonna be
our effect delay one. Our next effect is
going to be 4 s. In our next one is going
to be 6 s. So I was just clicking tab will just jump
you to the next field there. Next what we're gonna
do is off of each of these we are going to
spawn and effects. So drag off of this and type
in spawn actor from class. Now we're actually going to
use three of these nodes. So let me just bring these
all down here a little bit. So spawn actor from
class node Control C, Control V, and Control V. To frame this up
for you all here. And the first actor we're
going to spawn in is going to be some smoke. That's blueprint effect smoke. We can find that in the
starter content pack. Again, you can use
whatever you want here, but I'm just going smoke first. The second one, I'm
going to add sparks, which is also in that
Starter Content Pack. And the last one is
going to be fire. So yes, smoke, sparks
and then fire. Now we do need to input
a spawn transform. So I'm going to grab
our capsule component and just jumping to
our viewport here, our capsule component is a thing surrounding
our character, so it's going to spawn it
right in the middle here. So let's jump back
to our event graph. I'm going to bring
in a reference to art Capsule Component
drag out of this. We want to get the
world transform. And we can plug this into all three spawn actor
from class notes. Alright, we're gonna
have a little bit of some crisscross the wire, but hope not to make
it too bad for you. Now, this is not enough
because we're spawning these, but we want to attach
these to something. So I'm going to drag off of
our spawn actor from class. Note here the return
value and I'm going to say attach To actor, sorry, attached two components. The one I'm looking for here,
attached to components. Alright. Now the parent here is going
to be our capsule component. So I'm going to try to go
with a set-up like this. I'm going to drag
this way over here, but I'm going to double-click on this wire to go like this. Now are the rules here. I do want to set these to
snap to targets like that, like that, and like that. Alright, and I'm going to
Control C and Control V, these three nodes like this. So why are this guy and this
guy in like this, whoops. This into the target, the parents into there. This goes to there, this goes to there. And we can take this, the capsule component and
sneak it down right there. So essentially what this
whole script is meant to do is upon these given upon this
custom event firing off. We're going to come in
here and we're gonna delay by these amounts in once again, double-clicking on this macro. We're going to do each of
these when they're delay calls for us to then spawn
the given effect. So we're going to spawn in the smoke than the
sparks, than the fire, and we're going to attach it
ultimately to our character. Let's compile this and save. Alright, that's the
bulk of the work, but we've got a little
bit more work to do. So let's jump back
to our level here. And we're going to place
a couple of things down to make it look
like a dangerous zone. So I'm going to place
a sphere triggers. So I've got my
place actors panel. You can find this by
coming right under here, place actors panel that so
you can place this panel. And our idea here under
the basic category. I'm going to place a trigger
sphere into my level. Like so. I'm going to set the
sphere radius over in my details panel to
be 200 like that, something a little bit big. And then in the starter content folder here I'm going to
come under particles. And I'm just going
to drag and drop my P fire right on top of the triggers fear here in my outliner so that
it is attached to, well, it's actually not
going to attach it there, but I can drag and drop it here. And then I can drag
and drop it on top of my triggers fear
there to attach it. And the reason this is good to attach it. This is just an FYI. If I move the sphere, the fire comes along with it, but I can move the fire independently so that it
is right over the top. I'm just looking
for something that looks a little dangerous here. Let's set the scale of our
fire here to be I don't know, three times as big something. Five times this bay. Yeah. Something kinda
dangerous looking. All right. Go back and select
your trigger sphere because we're going to make use of this inside of
our Level Blueprint. I've got my Level
Blueprint tab right here. I'm going to right-click with that sphere at trigger selected. We're going to do something when we begin overlapping that. You've seen me do
this several times. So what we're gonna do is we're going to drag out
of the other actor. We're going to find
out who that is. So we're going to drag
out of this scene, do Cast to ThirdPersonCharacter. We're basically asking
the question here. When something overlaps
this triggers sphere, we're going to say, Hey, let's find out what the
other actor is. If it is a ThirdPersonCharacter, then let's do something. Well, what we wanna
do here is call. We want to call this custom
event player catches fire. Now, the reason we
have this setup, the way that we do
is because we cannot call this macro from
our Level Blueprint, even though this is
compiled and we have our macro living here inside
of our ThirdPersonCharacter. I cannot just call on fire. It does a search for
player catches fire. This is our custom events, but we cannot call that macro directly
from another Blueprint. So that's one of the
differences between macros and functions. So here's our call over
to that custom events. I'm going to compile this. It looks good. So this is going to tell in
our ThirdPersonCharacter, this to fire off. Alright, let's give this
a play, moment of truth. Clicking play. I'm just going to
try to minimize this a little bit so you can see these scripts firing off here. We'll make our ThirdPersonCharacter
just spawn in, and that's gonna be our
debug object there. Once we overlap this cuts smoke, it's attached to us. We are now sparking the crotch area and
now we are on fire. So indeed, that did
work is designed. So it's worth pointing out
here that we created a macro. We could not call this macro or directly from our
level blueprint. Inside of this macro, however, we were able to make
use of delay node, some latent nodes, those are available for you to
use within a macro. Also, what made this macro different and special
from a function is we could have multiple
execution output out pins. You could have multiple
execution in pens as well. In this case, we just had
multiple execution out pins, but you can have them on
either end of the macro. Alright guys, that's
it for creating a macro will see you
all in the next video.
68. Collapse to Macro: Welcome back. In this video, our goal is to learn how to make
our lives better by collapsing a collection
of nodes down into a single macro node. Now this is one of those quality of life
type actions you can take to make a
certain bit of script happened by using one node. Not many. Now let's show this off. We have before you created some script meant to
simulate a coin flip, meaning we'll have two possible
outcomes, heads or tails. And then we're going to
collapse that functionality down into a macro that can be used anywhere inside
of our ThirdPersonCharacter? Yes, once again, I am inside of my
ThirdPersonCharacter Blueprint. I have prepared some
script ahead of time, and this is my quote, unquote coin flips script. Essentially what I'm
doing is I'm launching my character to
simulate a coin flip. We're going to launch
our character into the air just as if we would
flip a coin up into the air. We're just launching them
850 into the z direction. Then we're going to
play a sound just to coincide with that
launching of our character. This sound effect can be
found in your engine content. By the way, if you
don't know how to turn on your engine content, make those folders
available to you. Back here in the Content Browser under the Settings section, you can just make sure that show engine content is turned on. You should be able to
find that sound effect. Then we're gonna delay by 2 s. That's gonna be the duration
of our coin flip here. Then we brought
in a branch node. And what we are doing here
is setting a condition, or condition is we're going
to have a random integer, either one or two,
that's our range. And if it's equal to one, then it's going to equal true. And we're going to
play the success sound if it ends up being a two. And again, this can
only be one or two, then these are not equal because two would not be equal to one, then it would be false. And we would play the
compile failed sound, that would be our failed S of x. And both of these sound
effects can be found in that same content folders. Alright, so we want to
convert this into a macro, collapse it into a macro. Now one thing you should know
is when you try doing this, we only want to get these nodes right here so
you can left-click and drag if you accidentally try to bring in your input events like
I've got right here, let me just show
you what happens. Left-click and drag. And now if I right-click on any of my selected nodes here, we have the option to
Collapse to Macro. So in trying to do this width, that event key in here, we're going to get a
warning saying Collapse to Macro fail than if we
show the message log, it's going to say you cannot place that five input in here, so we'll get rid
of it This time. We're going to left-click
and drag around these nodes, leaving the five
input out of it. Right-click. We're going to
collapse to a macro. And we can see over
in the macro section, we now have the ability to
give this macro a name. So I'm going to flip my
page and we're going to call this coin flip. Yep, following along with
my notes, coin flip. You can see that
this is hooked up, but we need to do
little bit of work inside of our macro so we can double-click
on it right here. And what our macro
currently looks like. But we want to do a little
bit more work here. So we simplified our life a little bit by
condensing these nodes down into one node back
in our event graph here. But I still want to
modify some things. So firstly, I'm going to
select my input node here. And I want to set my
input name here instead of executes to
simply be n. Then I, my output node, I'm going
to add a couple of outputs. Plus I'm going to
call this one heads. And we're going to set this
to be an execution out pin. Then we're going to click the
Plus button one more time. We're going to call
this one tails. And that's also going
to be in execution PIM. And again, if this
results in a true, That's essentially
going to be our heads. So we're going to connect
this into our heads. And if this ends up being false, we get a two here,
it's not equal to one. This is going to be our tails. So if we go back to
our event graph now, we can see that our coin
flip macro has been updated. Note that we have one execution
in pin and two out. Also. We have this latent icon on here to indicate that
inside of this macro. And once again, you
can double-click on this to open up your macro. We have a latent node
inside of here, yes, LinkedIn nodes such as delays, can exist inside of a macro. They cannot exist
inside of a function. All right, Let's head back
to our Event Graph tab here. And I want to extend our script out of each
of these pins here. We're going to say
if our coin flip here ends up being heads, what we're gonna do
is we're going to set our character's
health to be full. Before this video shots, I took our health variable
here and remember this is hooked up to our
hood or health meter. And I set it to 0.1,
meaning that we're going to start off with 10% health. I'm going to hold
down the Alt key, left-click and drag
to bring in a setter. And I'm going to
set this to 1.0. We're going to go full health
if we get a heads results. And what we're gonna
do off of the tails, We're going to kill her character because
that sounds like fun. So we're going to
bring in our mesh, a reference to our mesh. So grab your mesh
component here. Off of this we're
going to drag out in, we have an option called
set simulate physics. The target for this is going to be our primitive component, meaning our mesh right here. And all we need to do
here is set this to true. And I'll leave you in suspense as to what this is going to do. Alright, go ahead and
compile here and Save. And we are going to
give this a play. So playing, let me set my debug object to
be our character, bringing our character back on. So you can see I'm starting
with 10% healthier. If I press the five
key, once again, it's going to run into our
macro and determine if we get a heads or
a tails results. So here we go, five
key. I got full health. It made me jump right away, then sent me to full health. Because the jump, if you will, the launching of our character, that is our coin flip
the beginning of it. Let me try it again. Five key, jump right away to seconds later we got
full health once again, let's keep going until we
get the tails result here. So jump 2 s later, we're going to find out the
result and simulate physics. He went through the floor, Leaving is sword behind. And so there you have it. If you have a collection
of nodes that you want to condense down
into a single node. And perhaps it has a
late didn't note in it. Or you need to have some multiple execution
input or output pins. Consider converting
it into a macro, collapsing it down into a macro. You might need to
do a little bit of fix-up work like
we had to do here with our input name and adding
a couple of outputs here. But that's a really handy way
of simplifying your graphs, guys, that's gonna do
it all for this video. See you in the next one.
69. Macro Library: Hello. In this video, our
goal is to show how we can create an add macros inside of our own
created macro library. So what is a macro library? Well, it's similar to a function library that we created in the last
section of videos, in that it is a
centralized place to store created macros
that we make. Now, what are the big
differences though, between a function library and a macro libraries
that macros can only be accessed from
blueprints that share the same parent class,
a macro library. Now, that seems a little
bit confusing here. Just stay with me as we go about creating our macro library. Alright, so here I am inside of my scripting Blueprints folder down on my content browser. I'm going to create my
macro library right here. So let's go ahead
and right-click. And we're going to come
up to blueprints in, in the little flyer menu. We've got the blueprint
macro library. So we're gonna go
ahead and pick this. And now we're going to see
is it's going to ask us to pick a parent class. So we're going to choose a character parent
class that is going to be similar to our
third-person character. Our ThirdPersonCharacter
is of the character class. Alright, so we're going
to click on this. And it's going to ask us
to name this and I'll call this my underscore character. I'll do all caps. Why not character
underscore macros? And then let's go ahead and double-click on
this to open it up. And now something you'll
note here is that inside of our macro
library here again, our parent class is character. We have the ability to access and use any variables that are native to this class and they're listed all
write down under here. So under character,
we've gotten meshed, character movement, et cetera, a lot of different categories. Now let's compare this with
our third-person character, which is the parent class of character over in the
My Blueprint panel. If we come under variables, make sure that if you
click on this gear icon you have show
inherited variables. Check this out. Under the character
category you have mesh, character movement, et cetera. These are all the same
variables that are native to this class,
the character class. So you can find them here inside of our ThirdPersonCharacter and here in our macro library, our character macro library, we have access to them as well. Okay, let's go ahead and
create our macro here inside of our character
macro library. Now, once we opened
this macro library, it had a macro
created for us here. You can see the tab
right over here. Let's go ahead and
give this a new name. So I'm just going to
click on this, press F2, and I'm going to call
this change max speed. And that's exactly what
this macro is going to do, is we're going to alter our characters maximum
movement speeds. So I'm going to create a
little space here between our input and our
output node here. So let's go ahead and create some inputs and outputs
for this macro, I'm going to create
one input here, clicking on this plus
button right down here. And the first one is simply
going to be called in. This is going to be
an execution in pen. And then I'm going
to create one more. And this one is going
to be called new speed. We're going to feed
this a new speed value, and this one is
going to be a float. And for our outputs, I got a few in mind here. We're going to click this once, and we're going to
call this one walking. This is going to be
in execution out pen. And then we're going to get
create two more plus, plus. The next one is
going to be running, and the next one is going
to be named sprinting. And those are all
execution out pins. Alright, so what we're
going to do here is we're going to drag in our Character
Movement Component again, one of the benefits
of us creating, in this case, a character
macro library is we have access to all of the native
character variables, including our Character
Movement Component. We're going to drag
this in our graph. We're going to get
that. Now you'll notice something here when I
drag this out here. And I just released, we can only get variables here inside of our
macro library. And this goes for any of them. If I was to do this, was jumping
and try to drag this in. We cannot set any variables here inside of our
macro library. An important thing to note
with a macro library, you can only get
these variables, you cannot set them. But that's okay. Well, we're gonna be
doing here is reaching inside of our Character
Movement Component. And we're going to type
in set max, walk, speed. Now, this variable lives inside of our Character
Movement Component. And just to drive this
home a little bit, I've got my ThirdPersonCharacter
right here. If I select my character
movement component, I have a max walk speed
variable that lives inside of that Character
Movement Component. Okay, so we're going to
feed this a new speed. Like so. Then out of this I'm
going to drag out and bring in a branch node. And then I'm going
to drag out of here. And I have several comparison nodes that
I want to bring in. So I'm gonna do a less
than or equals to one. I'm going to drag
out a here again, and I'm going to do a greater
than, just greater than. Then I'm going to drag
out one more time and I'm going to do
a less than or equal to little loops less than or equal to or just less
equal as it's called. For the values for
these, I'm going to plug in 200 for this not plugin, I'm just going to hard code it. 200 for that. We're gonna do greater
than 200 for this and 1,200 for this. And we are going to read, I'm going to read this all
to you in just a moment. How we're going to be
interpreting all this. In just a moment. I'm
going to bring in another branch node holding
down the B key left clicking. And I'm going to plug this
true into our walking, the false I'm going to drag
and so you hear the term, I'm going to drag
them here and the false I'm going to
drag into here. And again, I will interpret
this all for you here in just a moment out of here. And I'm going to drag out here
and bring it in and node, it's going to be an AND Boolean. And boolean right there. Plugging this into here. We're plugging this into
here and this into here. Alright, Mr. Laundry, you went through that rather quickly. What does this all
translate into? Alright, so this is
how it's gonna work. We're gonna feed a new
speed into this macro. So we can alter, set our characters
max movement speed. If it is less than
or equal to 200, if that is true, we're going to output walking. So we're going to continue
to extend out of our macro and do something when we detect that
we are walking. Now, if we detect that we
are going at a speed greater than 200 and less than or equal to this
value right here, 1,200. If that is true,
then we're going to be considered to be running. However, if this turns
out to be false, then we're going to be
considered sprinting, meaning we're going some
speed greater than 1,200. Now let's go ahead and
make use of this macro inside of our
ThirdPersonCharacter Blueprint. A quick note here, there's
no need to compile here. You don't need to compile
inside of a macro library. In fact, it's grayed out, but we can go ahead and save this. And over in our bp
ThirdPersonCharacter, we can go ahead and
right-click on this. And we can do a search
for change max speed. And there it is. There's our macro
that we just created inside of our macro library. And let's create our scripts
to make use of this. So we're going to add an input key at the
very front of this. I've been using the five key and I've been deleting
it between videos. It looks like I don't have it anywhere in my graph right now, let's do the five
Kishore five input. So what we're gonna do here is upon pressing the five key, we're going to change
our characters max, movement, speed. What do we want to change it to? Well, let's right-click in some empty space
and I'm going to do random float in range. So we can plug this guy
into our new speed. So every time we
press the five key, we can choose a value, and I'm going to choose
a value, 1-2 thousand. So every time you press the
five key is gonna give us some value within that range. When we release this key, we're going to want to set our
character's movement speed back to what it normally is. So if we drag and drop our Character
Movement Component into our graph and we see our characters max walk
speed right now it's 500. So if we drag out here, we can do set max walk speed. So when we release this, we're going to set our max
walk speed back to 500. So pressing is
going to set it to that new value releasing
it's going to set it back. And all we're gonna do
out of each of these, we could do something further. I mean, I could play a
particle effect or whatever. I'm just going to print a
string out to the screen. So we're going to
do several prints. Strings is first of all,
it's just going to say walking and hitting
Control C, Control V. Control V. You can guess what
I'm going to plug into each of these fields. This is going to say running. And this one is going
to say sprinting. Sprint, sprint ing. Not that it matters
all that much. Let's compile this. Let's save, and let's go ahead and play this
setting, our debug object, huge or third-person character, so that we can see this script firing off over on the
left-hand side here. Alright, So I'm just
walking, walking, walking. As I press the five key, look in the upper left
below the word Superhero. So five, running. Sending it back to five. Running doesn't seem
all that much faster. Five, sprinting. Five sprinting. Now running does have the
greatest range, 200-1200. I wanted to get it walking, so they're sprinting, pressing
F5 again and running. Again. Running could be
pretty close to sprinting. Sprinting, get some running now it's gotta be
barely above 200. Running, running. Let's get a walking in here. I'm going to keep going
until I get to walking. There we go walking. So we can see that that
macro is indeed working. Alright, now it is
important to note here that we were able to find and use this macro here inside of our third-person character
because both are ThirdPersonCharacter and
our macro library share the same parent class. If obviously go to
our Level Blueprint. Let's open up our
Level Blueprint here. And even if I do have some reference to
our character here, let's just do an event
begin play for sure. Even begin play. And we were to get
player character. And then, you know, Cast to ThirdPersonCharacter,
something like this. And we were to try
to find that change max speed dragged out
of here, changed Max. You cannot find that macro here inside of your
Level Blueprint. You cannot just right-click in some empty space and find change max speed because this doesn't
have any parent class, because this is a
Level Blueprint, but even inside
of another class, but a blueprint like
our example pickup, this has the parent
class of actors. So if I was to
right-click in here and do change max speed, I cannot find it
inside of here either. So that's an important
thing to note because this macro was created inside of a macro library with the
parent class of character. We can only find and use this in any other blueprints that
share that same parent class. So given that nuance
behind a macro library, needing to define
a parent class, what would be the benefits
of using a macro library? Well, consider maybe you have a fighting game and you have a whole host of
characters that you can play as maybe you
would want to have some macros that all characters
could share and use. Something like picking
between a random tante or maybe an outfit change,
that kind of thing. I mean, right here,
all I'm doing is I'm picking a
random float in range, and then I'm deciding if I'm walking, running, or sprinting. Maybe we could feed this
a random integer in based on the integer
that is picked. We could play a random taught
something of that nature. Now, if you want to get around that limitation of
the macro library, there is a little bit of
a hack here that you can do to make sure that your
macros are available anywhere. And that is to ensure that
your parent class for your macro library is
of the object class. Now to drive home that point, let me just right-click
it some empty space here and I'm going to bring in, say, a gate node. And the reason I'm
doing this is so that I can double-click on this and quickly take me to our
standard macros library. Just browsing to this, we can find where this is
in our content browser. It is in the engine Content Editor blueprint
resources folder. Once again, to see this, you can make sure that you
have show engine content on. And if we go to our
standard macros library, we can see that our parent
class here is object. Now, going back to our
content browser here, if I was to right-click
it some empty spaces, if we were going to create
a new macro library, blueprints, blueprint
macro library. Check this out right down here in the all classes section. You can see that every other
class inherits from object. So if you were to make a
standard macro library that has the parent
class of object, any other class is going
to be able to use it. Hence, why you can
find nodes like gate node in any
other blueprint. Alright guys, is going to
do it all for this one. We will see you in
the next video.
70. Array: Welcome back everyone. In this section of the course, we're going to be
returning to the topic of variables because up until
this point in the course, we've only talked about a
single variable container. And in particular, what
we're talking about here is with a variable type selected, you have over on the
right-hand side here the ability to choose
the container type. We've only created
single variables. We have not talked about
arrays, Sets, or maps. So that's what this section
of the course is all about, talking about these different
variable container types. In particular, for this course, we're gonna be learning
what an array is. We're going to show how to
create a few and then give an example of how
they can be used. So firstly, what is an array? An array is a variable
container that can store a collection of values
of some data type. Now more practical terms in array is a list of
similar things. It could be an array
of float values, it could be an array of texts, of sounds, of objects, etc. Now, each entry
into the list has an associated integer index or what is known as a
key associated with it. Meaning we can look up a given entry in the list
if we want or need to. Alright, here I am inside of my ThirdPersonCharacter
Blueprint. So let's create our
very first array. And we're going to start off by coming down to the
My Blueprint panel. We're going to create
a new variable, clicking this plus button, I'm going to call this
one catch phrases. And the type here is going
to be a text variable. And then over in the Details panel we can
set the container type, which I'm going to
click this drop-down and choose an array. Now I need to compile
my blueprint. And when I do, it's
going to allow me to add X number of
items to my list. Remember, at array is
essentially a list and you get to determine how many
items exists in that list. I'm going to click
this Plus button right down here, three times 12.3. And my first catch phrase
is gonna be, hey, hey. My second one is going
to be high diddley bow. And my next one is going
to be released the hounds. Now note that array variables or container types rather
are designated by this three-by-three colored
grids show that they are not standard single variables. And you can see that represented
not only over here but down in your My Blueprint panel under the variable section, you see that
three-by-three waffle icon that indicates that that
variable is an array, an array of texts variables. Now, something worth
mentioning here is you can reorder your values within this array by
clicking right about here and dragging one above, or dragging down below, like so. Also over on the right-hand
side here you have the option if you click on
this little drop-down arrow, insert, delete, or
duplicate an entry. So I'm going to
insert just to show that off and then let's
quickly delete that. Alright, now let's go ahead
and make use of this array. So I'm going to bring
in an event key here. Right-click. I'm going to do the five key. And then what I'm gonna
do is I'm going to bring in my catchphrases. So I want to get to, so
I'm going to hold down the Control key,
left-click and drag. That'll give me a getter. And then out of this,
I want to drag out here and type in gets, I want to get a reference here. Sorry, rather, I
want to get a copy. And what do I want
to get out of this? Well, I get to choose which entry in this
array, 01 or two. And again, this is
a zero-based list. It's going to start off
counting at zero which one of these entries I
would like to return. So whatever number I
type in here that will correspond with the entry
that I want to return. And I'm going to choose
something at random here. So I'm going to drag backwards
off of this and type in random integer in a range. And I'll say 0-2, because that is my range, 0-2. If we were to go above
to say we put it in a range 0-3 and we
return the number three, we would just get a null result and no arrow would be thrown. We just get a null result. I'm going to drag out
here, type in print text. And we're going to
plug this in here. So let's quickly
give this a play. Let me compile this, make
sure it's looking all good. And I click on my
play options here. I don't want to simulate, I'm on a plane and
new editor window. I'm going to set this as my debug objects so that we can see this script firing off. And not to OBS. Here we go. When I press the five key. Hi diddly. Hello. Hi diddly Hill, really sounds. You can see as I'm
spam the five key, I'm getting one of those
different options at random. Now check this out. We currently have three
catchphrases in our array. However, again,
this is a variable. We don't have to keep these
three elements right here. We could swap them out. Let's try something like this. I'm going to bring
in a four key. For inputs. We do for keyboard, There's my four key. What I'm gonna do
this is I'm going to set my catchphrase. I'm going to hold down the
Alt key, left-click and drag. We're going to put this on
this pin to bring in a setter. And what I'm going to do
off of this is dragged backwards and type
in make array. So this node, I'm going
to add three pins. What I'm going to do is
I'm going to hard set what are the three elements
going to be in this race? I'm going to put in dough. And in my second entry here I'm going to put it in Smithers. And the third one is gonna
be the Nelson months. Haha. So check out what we've
got going on here. Let me just kinda shrink this a little bit,
tuck it up here. Clicking play setting, this might do already have
that as my debug object. That's all well and
good. So if I start off pressing the five key
and I'll just spam it, you'll see the original
entries in my array. Now I'm going to press
the F4 key and it's going to overwrite
those entries. So I'm just going to
press it one time. Watch this fire off, booms. That did fire off. So now when I press
the five key, the entries, the elements in this array have
been changed out. So it will read as thus the new entries that
I've just put in over here, I swapped out, I change the
contents of that array. Alright, let's try creating
a couple other arrays. So let's create one more here in the My Blueprint panel
under variables, clicking this plus button, I'll call this my sound array. Now I'm going to change out
the variable type here to be sound wave files, sound wave. So under object
types sound wave, we want to choose
object reference. It is already of the array
variable container types. So that's all well and good. And I'm going to create
one more variable here, clicking the plus button. And this one is going
to be my actor array. And I'm going to change
the type right here to be of the actor variety
under object types, actor the object reference. Okay, now I'm going to
compile both of these. And for my sound array, I'm going to hard input
three of these, so 12.3. And here I can slot
in some sounds. I'll go with any three. I've got double window close any three we will
do this is all just e.g. sake. Var underscore close
enough for my third one, I'm simply going to
go floating UI close. So you can imagine, say I had an array of car horn noises. You want to awesome key on your keyboard is gonna
make your car horn go off. These can be three different
variations to that sound. Maybe you just want to
pick one at random. Okay, So that's all well and good enough for
my actual array. I'm going to do 12.3. However, I am going to leave
these as empty right now. I'm going to compile this
and save one more thing. I forgot to check this
box instance editable, so make sure you
check this as well. Go ahead and compile
and save one more time. What I'm gonna do is
once I play this game, I'm going to set which objects are going to be a
part of this actor array. So note that this array
currently this list is empty. So what I'm gonna do is
go back to my level here. I'm going to add three objects.
Doesn't really matter. I'll just do a cube, a sphere, and a cylinder. Like so. Okay, got those
three set in here. Let's go back to our
third-person character. I'm just going to swap
out our arrays here, just kinda modify our
scripts here a little bit. So here under catchphrases, we're gonna get rid of
these four or five key. I'm going to bring in my
sound array holding down Control, left-click and drag. We're going to drag out
a here type in, gets, we want to get a
copy, plug these in. So actually I don't want
to print text here. I want to play a sound. Play sound. Sorry, rather, let's drag
out of here and type in play sound 2D, like so. And when I press my four key, delete these out right here, I'm going to grab my actor, raise a holding
down Control key. Left-click in bringing a
reference to that end, I'm going to drag out
of this type in gets, we're going to get a reference. Copy, rather not a reference. I always screw those up. I will do a random integer
in range for this. So Control C, control V. Now what I'm gonna do here is we're going to drag
off this and we're just going to destroy an actor. So when I press the four key, I'm going to destroy
one of these now again, this is currently
an empty array. So let's compile this. That script is going to
be looking good here. I'm going to go ahead
and jump into my level. We're not gonna get to see
these scripts firing off. But if you need to come back
here and reference these, that's all well and good. Okay, here we go. Alright, now with my
character in my level, I can see him populated
here in the outliner. I'm going to go ahead and
select my ThirdPersonCharacter. And now I need to set the three elements
of my actor array. So I'm gonna do a
search for it here with my ThirdPersonCharacter
selected. Do a search for actor array. And note that I've gotten
nothing set in here yet. So I'm going to click
these drop-down arrows, and I'm going to set
them to be the cube, cylinder and sphere
respectively. So cube cylinder
for the next one. Sphere is somewhere in here. There is a sphere. Okay? And let me bring up my
play window once again. Alright, so pressing
that five key firstly, we're going to hear some sounds. All well and good. Alright, and now my
four key watches, these disappear when
they are selected. Squares are cylinders gone? I press the F4 key again, nothing disappear too, must have selected that element again. Sphere gone, and
finally, square is gone. So you can see those
various arrays working. Now the reason I'm
getting this error is because it was trying to
destroy a few actors. There is I was pressing
my four key here. It was trying to pick a
random integer and range, just trying to pick
one of these three. Now the first one is
destroyed was the cylinder, which I believe was elements too. I could be wrong on that. Once that's destroyed and it picks that same number again, it's going to throw
that error when I stopped playing
saying like, Hey, I'm trying to destroy you actor, but you've already
been destroyed. But again, this is all
for academic purposes. Alright, just a little
bit more here to go. Before we wrap this up, I wanted to point out
that for any array, and let's bring in our
catchphrases here. Any of these will have the same options available
to you if you drank out of this and come under
the utilities section, utilities array, you have a bevy of different options that you can use to modify
to edit your array. You can add to it. You can drag out of
this and type in clear. You can clear your array. So we could add another
element to our array here. This one would clear
the array entirely. You can append the array that is to take one
array of catchphrases. Maybe you have a second ray of catchphrases and you
could combine them. You could, I began at random. You could pick out
a random entry from your array and
also return the index. So that would pick
out a random entry that would return the index. So with any array you have a bevy of options
that you can play around with to modify that array in some way, shape, or form. And again, you can find those under here, utilities array. You've got a lot more of them
available to you as well. Alright, thanks to know
before we wrap this up, values within an
array, once again, they are zero-based
index values, meaning that the first
index is zero, not one. Arrays are a great way to store a list of these
same type of data. Where would you use this? Well, I had an array of
fruits that I spawn into a Pac-Man style game that I
created in Unreal while back. Another thing to note about
arrays is you can grab a specific entry from a
list by getting a copy, like we're doing here. Or you can get air or random
entry like we're doing here. So if you want to
get a specific copy, you can just break
this wire and say, Hey, I want element zero. The random approach would
do something like that. Now later when we talk
about flow control, nodes will show how
to look through every entry in the array
using a for or a while loop in order to do something
to every entry in the list or to drive some logic
based upon while given, while a given entry
in the list is found. Right guys, that is going
to do it all for this one. We will see you in
the next video.
71. Set: Welcome. In this video, our goal is to learn what a
set variable container is. Show how to create one, and then give an example
of how they can be used. So first of all, let's define what a set even is. Well, a set is like an array in that it is
a variable container that can store a collection of values of the same datatype. Over here in my variable types. Over to the right, I've got
different container types, single array set or map. So we're talking set
in this video, e.g. we could have a set of
hidden treasures you're asked to find in a level
collection of hidden treasures. Now, one of the unique
things about a set is all entries within a set container must be
unique, no duplicates. We'll get to some more of
the differences between arrays and sets in just
a little bit here, I'm going to be
creating a couple of variables here within
my Level Blueprint. But for this example, you could do this in your
ThirdPersonCharacter as well. You forgot how to open up your Level Blueprint
right there. Open Level Blueprint.
And let's come under our My Blueprint panel and
create a couple of variables. Clicking this plus button. Once, I'm going to create
one called hidden treasures, all, I'm going to change
the type here to be a name. We're going to punch in some names for some
hidden treasures. And then over in
the Details panel, I'm going to change the
container type here from single to set. Next, I'm going
to right-click on this and I'm going
to duplicate it. You can see the hotkey
for that control plus D. And this is gonna be
called hidden treasures. Found. And then once I compile, I can add some entries here, some different set elements. So let's start with
hidden treasures all. I'm going to click
this plus button once. And if you tried to click
on it a second time, it's going to say you
can't add another one until you add some,
an entry here. So I'm going to call
this gold statue. Going to click the
plus button again, I will call this one necklace. The reason you can't add another
one when it says none is because it would try to create a duplicate entry that
would also say none. So remember, sets
cannot have duplicates. Clicking this plus button again. We'll call this ancient pottery. Pottery. Pottery. Sure. Ancient pottery. Clicking the plus button again, we're going to call this
one scroll of wisdom. And clicking the
plus button again, we're going to call
this one warrior crest. Alright, so now I'm going to set some hidden treasures
found here. And actually you know what? I want to actually have some
duplicate entries here. So I'm gonna delete
this one out. And I'll tell you why we're
going to delete this out to ensure that we have our names
spelled exactly the same. So I'm going to
right-click on this. We're going to duplicate
this. Once again. I call this found, and I'm going to
compile this in. Once I compile it, I can
see all those same entries. Let's just delete a
few of mine here, so I'll delete the necklace
by clicking right here. Delete will keep gold statue. Let's keep scroll
of wisdom as well. It doesn't, doesn't really
matter which ones we keep, but just keep a couple
of them right there. Now, note, certain variable
types cannot use sets. If I was to select my, say, Boolean variable here and come over to the
container types. I can't set a set for this. I can also do it for
a text variable tech, or a rotator or a transform. All the other ones you can
set as a set container type. Just thought I would throw
that in here as well. Now, if I drag out a
reference to one of my sets here and then get it
dragged out of it, releases some empty
space underneath the utilities set section. You see that I have a whole
bunch of different functions available to me to manipulate
the data in some way, shape, or form a lot of
functions specific to sets. What I'm gonna do
here is fast-forward the video quickly
after I add these, and just quickly
talk about some of the different options
available to you. Alright, and here's a bunch
of those functions that I was just talking about
that are specific to set. You can add an element to it. You can remove an element to it. You have some comparisons between two different
sets, that sort of thing. Now one thing that's
worth noting here, if you were just
to right-click and some empty space like I did with this node right here doing a search
for a union node. It has these great
input and output pins. These are wildcard
inputs and outputs, meaning that whatever
datatype gets hooked up to an input
or output first, that's the datatype, the rest of the input or output take on. And just to demonstrate this, these are gray right
now if I was to plug in this to say this top one, you can see they
all turn purple to represent the name
variable type. There. To delete that out and put
one on the output side, it's going to change the input
side to that same color, that same type as well. Alright, here to my
Level Blueprint, I have started creating
a script showing off a practical example of how
sets can be used in a game. So when I press the three key, what I'm gonna be doing is
finding out the difference between two different sets. My top set is going to contain all the treasures say that I need to find in a given level. My bottom set is going to give me the treasures that
I've found so far. What this difference
note is going to do is it's going to output
all of the ones. I have not found the difference between one set and another. So I can't just drag out of here and type in print string. So I can't, this is not going to print out the names of all of the set items that are
currently not found. So what I need to do here
is dragged out of here. This will give me the resulting
treasure is not found. And I'm going to
type into two array. What this will allow
me to do is output an array of all these
different set items. The difference
between these two. And with this, I can drag
out of here and bring in a for each loop. Now we have not talked yet about flow control nodes that's going to become
in the next section. But what this flow control
node is going to allow me to do is look through each
item in this array, each item in this list, and then output those
to the screen here. And it's going to be
outputting those to the screen of via
a print string. So for each item in that array, we're going to take
that and convert that name to a string
so that we can output. Let's compile here, make
sure our script looks good. Save it. We're going to play. You can set your debug object to your test map there if you
haven't already done so. And now if I press
that three key, you can see those are the three
items I have yet to find. I'm just spamming
with three key. That's the difference between my all set and my found sets. Alright, so now let's
try something else here. I'm going to bring
in keyboard VY, the V key, I don't know. And with this, I'm
going to bring in a reference to my
hidden treasures found. I'm going to drag off of here and I'm going to type in AD. Make sure you choose
the add function under these set category here. And we're going to add necklace. We're going to say we've
found the necklace now. So we're going to add that to our list of bound treasurer. So essentially this
would be gold, statue, scroll of wisdom
and then necklace. So Compile, Save. Now when I play, when I press the three
key, it's going to say, hey, you're missing those three, but now I'm going
to press the V key. We're going to
say, yep, we found the necklace now, V key. Okay, So that's been added
to my list of thousand. Now when I press the three key, it's going to say those
are your two missing. We have found the necklace. Alright, let's finish off this video talking about some of the similarities and differences
between arrays and sets, starting with some similarities. Well, both arrays and sets store a collection of values
of the same type. Both allow you to add
and remove elements, and you've seen me do that over the course of the
last two videos. As for differences, the
order of elements is difference in arrays you
have a ordered list. Sets are considered
to be unordered. Now, as for uniqueness
of elements, arrays can have duplicate items. Sets cannot have duplicates, and that is one of
the key differences between arrays and sets. Sets cannot have duplicates. Arrays can, as for
functional differences, arrays can look up and get an individual element via an index lookup because
they are ordered. And just to show
that off quickly, I've got an array of
pickup actors here. If I drag and drop
that and get that, I can drag out of here and gets, I can get an individual
item within that array, any number here, again, starting with the zero list, I currently have
nothing in this array. But yeah, you can get a given elements
specified by an index. Now as for sets,
they cannot look up or get an individual element. However, sets are great at running comparisons
between lists, like you just saw me do with
these hidden treasures, all lists and my
hidden treasures, boundless set or an array,
what should you go with? Well, I would go with a set if the order is not
at all important. Uniqueness of elements
is a requirement. On the other hand,
go with an array if the order is important, but duplicate elements, not a big deal there
possible within that. Now sets also have the benefit of their little bit more
performance than arrays. So that may be something
to keep in mind as well. But again, arrays are
great for if you need to look up in individual
item within that list. Sets are great if
you need to compare one set versus another
set, that kind of thing. Alright guys, that's gonna
do, offer this video. See you in the next one.
72. Map: Welcome. In this video, our
goal is to explore what map variable
containers are, how to create them,
and how we can use one in a gaming project. Now, seeing is going to
be believing this one is going to be easier demonstrated
than talked about. So we're going to jump
right into creating one. Now, we're gonna be creating
this map variable container inside our bp player controller. This is an asset that we
created during our event. Begin cursor over video. If you want to go back and
review that when you can. If you don't know how to
create a player controller, I'm gonna give you
a quick primer, a quick refresher here. You do so by right-clicking, going under Blueprint class, you want to create a
player controller. And then you would
name it thusly something like bp
player controller. But then after you do that, you have to associate
that as you're active player controller for the project that you
are working within. And you can do that
in your settings. Project Settings
under maps and modes. Right here is where you can slot in that player controller class. Now, we're going to
have some videos later on the course
where we talked specifically about
these blueprints known as Framework blueprints. But there's a specific reason
why I want to show off this map variable container
using a bp player controller, my player controller
blueprint right here. And that is because a player controller blueprint
is associated with, in our case, are
ThirdPersonCharacter. Now, in a real game, your character could die
and when they get respond, all the variables inside of that player character
blueprint would be reset back to their
default values. Now, something like in
inventory variable, where it holds the
name of an item and how many you have of
that item would be better off stored in a player controller blueprint because if your character dies, your character dies in
those variables get reset in a player controller
that stays alive, so to speak, it stays persistent throughout your
gameplay session. Thus, if your character did die, those values would not get wiped out inside of
your player controller. Alright, so with their player
controller created and set inside of your project
settings under maps and modes. Player controller class. Let's dive inside of here. And if you get this
little window that says, Hey, this is only a
data, only blueprint. We can click right here to open the full blueprint editor
and see what we want to see. Alright, first thing to do
here is to create a variable. Now, actually before I do that, I want to clear out all
these inherited variables just to simplify this section
of the My Blueprint panel, these are all inherited from our parent class of the
player controller variety. So I can Hi these out by
clicking on this gear icon. Unchecking show
inherited variables and that'll just simplify
that a little bit. So let's go ahead and add
our desired variable here. I'm going to name this
inventory because that is a good thing to store within a player
controller blueprint. Once again, a player
character can die and respond and die and response variables within
a player controller will persist throughout
your entire play session, the player controller
does not die. Think of it as like
the puppet strings controlling the
puppet that can get knocked off the string
again and again. Alright, with this selected
over in the Details panel, we're going to change
our variable type here, boolean to string, and then our variable container from
a single to a map. Now that enables me to add
a secondary datatype here. So I want to have a string for the names of my inventory items. And then I'm going to
have an integer to tell how many of that
given item I have. So I could have things like health potion, three of those, man a potion three of
those leather helmet, one wouldn't shield one, et cetera, et cetera. Now to add elements to
this variable type, I'm going to click Compile here. And we can see over
in our Details panel, we can add elements. I'm going to click
this plus button once. If I try clicking it again, it's going to tell me, nope, you can't do that. Now with a map variable. It is a container that
stores a collection of key value pairs whereby the keys and values can be
of different datatypes. Once again, in this case, my key is going
to be the string. The name of my inventory
item keys must be unique. So for my first one here, I'm going to call
this health potion. And I'll say. I've got three of
these by default. So health potion is
going to be my key, and over here is going to be my value represented
by an integer. These do not have to be unique. These can be the same, and I'll represent that here by adding another element here. So the keys, in my case, the strings, needs to be unique. I'm going to have this
be man, a potion. And I'll set three is a
default value for that. And let's just add a couple more here just for the fun of it. I'll add sure. Leather helmets. We've got one of those. And clicking plus here, I've got a wooden shield
and I've got one of those. Alright, now I've
got my collection of key value pairs all within
this map container. Now, maps are great because they support efficient lookups and retrieval of these values with the use of these
associated keys. Alright, now I want to create
one more variable here, and this will come into play
a little bit down the road. So I'm going to click this
Plus button and I'm going to name this item to use. And I want to have this be
of the string variable type. Before I actually set this
as a string variable type, I'm going to temporarily
set this to a Boolean. Now something to note
here is that you cannot have certain variables as maps. So if I was to try to say, Hey, variable type Boolean, I want
to have you within a map. You can't do it. So certain variable
types cannot use maps. They include Boolean, texts, rotator, and
transform variables. So I thought I would throw
that out there right now. Those cannot be, cannot use
the map variable container. Alright, now I actually
do want to change this datatype here from
boolean to a string. And we're going to compile this so we can set
a default value. And this is going
to be manna ocean. So as the name suggests, this is going to
be our item to use a man of potion
that will come into play down the road here. Right next, we want to create a new actor class blueprints. So come on back to
your content browser. I'm going to put this under the scripting Blueprints folder. We're gonna put it
inside of there. So I'm going to right-click
in some empty space, we're going to create
a new blueprint class. It's going to be of the actor variety and we're going to name this BP underscore
manner potion. And then we're going
to double-click on this guy to open it up. And firstly, we're going to add a couple of components and
then set some details. So the first component
I want to add is a sphere components. Not this type of a sphere, but rather a sphere
collider, sphere collision. That's what I'm looking for. And I'm going to set the sphere radius
over here to be 70. And then with your
spear components selected inside of this are
attached to this rather, I'm going to add a cylinder. And so I'm just going to type in cylinder and we'll find
a basic shapes cylinder. And I do have some settings
I want to set for this. I'm going to change the
scale to be unlocked, so unlock that and we're
going to set that to be 0.25, 0.2, 5.0, 0.5. Then I'm going to tilt this. We're going to rotate
it a little bit. So right here in the wires rotating is that
that to negative 30. And I'm also going to make
this material be something like what do I have
vertex, something red. Let's go with that. Now it looks kind of man alike. Sure. Next we're going to add a variable inside of
our bp Blueprint. So click under this plus button for the variables section. We're going to call this
item to use as well. We're going to change the
type here to a string. We're going to
compile so that we can set a default value. And this time I'm going
to type in Amana potion. I'm gonna do this in lowercase, but I'm only doing this to have this be
different than how we named this the default value inside of our bp
player controller. There we use upper casing
for the beginnings of our manna and potion words
just to show that we can, because casings not going
to matter for our map here. So let's go ahead and compile
and save this right away. Now, before we go
any further here, I wanted to show off over in our bp player
controller that for our map variable here
I'm going to hold down Control left-click and
drag into our event graph. If we drag off of this release, if I come under Utilities map, we have access to
a whole host of functions that can manipulate
our map data in some way. In a lot of ways
that's similar to our arrays and set
container types. And I'm just going to
add a few of them here. So I'm going to bring in
an ad one this allows us to add to our map. Dragging off of this, there's also another one
to find it given item. Drag off of this, I can remove an element from our map dragon
off of this again, I can find one that contains, once again, I can drag out. I can do search for
just the keys that exist within this map,
meaning these guys, I can drag off of
this and I could bring in a function that finds just the values of this map. So there's a lot of
different functions can manipulate or give you
information about your map here. Alright, Next we're
going to head back to our bp menopause so that we
can add some script to add to our inventory here
we're going to add to our Amanda potion inventory when we pick up a man a potion. So coming back in
our BPMN of motion, we want to do something when we are overlapping this sphere. So head to your event graph, we're going to right-click
on our sphere collider. We're going to add
an event for when we begin overlapping that. And we only want something to happen when our
other actors that overlaps this sphere is
the ThirdPersonCharacter. So releasing we're
gonna do a search for Cast to
ThirdPersonCharacter. And if it is a
ThirdPersonCharacter, we can extend our script here. Next, what we wanna do
is we want to talk to our inventory variable here inside of our bp
player controller. So how can we do that? Well, back here inside
of our bp man of motion, I'm going to right-click and
some empty space and type in get player controller. And so a mistake that many
make is they think that, well now I've got this get
player controller function. I can just drag out of
here and do a search for inventory to find that variable. And no, you can't, because we need to find out which player controller
we want to talk to you. Project could have many
player controllers. So this is the starter to identify which player
controller we want to talk to. So dragging off of here, we can cast to our
player controller, our bp player
controller in order to access the information
inside of it. Now I'm going to simplify
this node here a little bit. I've got some execution pins
right here and right here. If I right-click on this node, I can simplify this node down to what is known as a pure cast. I know that this is
not going to fail because I have a
single-player project. I know that I've set my
bp player controller as the player controller that my project is using here
in my project settings. So in this particular instance, it is okay for me to not check if I have succeeded
in this caste or not. I know that it is
going to succeed. I'm going to right-click
convert to pure cast. It's going to eliminate
those execution pins, but I can still reach
inside of it like so. And access my inventory, which is pretty sweet. So there is my map. Next one I wanna do is
I want to grab out of here and do a search for find. And what this node allows me
to do is find a given key, given value, given an input key. So the key that I want to search for here is man a potion. So I'm going to drag and
drop this onto my input. That's the key that
I'm going to be looking up within this map. And it's going to output
the value of this. But I want to increment this. I want to increment this every
time we overlapped this. So we're going to
be starting off with three Amanda potions. When I overlap
this, I want you to simply increment this amount. So I'm going to
drag off of here. This will spit out
my value of three. Dragging off of this, I'm going to type in increments. So this node right here is automatically going to
increment this 3-4. In this case. I'm going to wire this
through here like so. But it's not enough
to increment this. I still need to add this
all back to my map here. So what I'm gonna do is drag out of my
inventory once again, type in ad, come under
Utilities map, add. So I'm going to go like this. We want to add to
our manna potions. And what do we want to add
that amount are updated. Amount is going to be
plugged in right down here. So that's going to set a new amount for
our manna potions. And then what I'm gonna
do is drag out of here. We want to print this
out to the screen so that we can actually
see this working. And I'm going to drag
backwards off of this type in, append in. We are going to print some
texts out to the screen. So the first thing
we're going to print out is the name of the item, in this case a man, a potion. Then I'm going to put in
a space equals space. And then the third thing
I want to include here is the amounts are
updated amounts. If I drag this on down from
the output of our increments, we can output that amount. So this will read as man a potion equals the
updated amount. And then last but not least, we want to destroy this actor. So dragging out of here, we're going to type in Destroy Actor. It. Let's compile the scripts and let's go ahead and save. Now. This is all well and good, but we have not added any man apportions
to our level yet. So let's go ahead
and do that quick by jumping back
to our level tab. Drag-and-drop just a few of
these out here like this, and drag, and drag. And here we go. Once again, remember that we're starting at three man a potion. So look up in the
upper left here, and we now have 45.6. I would say that that
is working just fine. Now, in the interest of time, we're going to head back to
our bp player controller where I have set up some script to decrement
from our inventory. This is much the same
setup that I have in my man, a potion blueprint. However, the only difference
here is I am decrementing from our inventory as
opposed to incrementing it. Once again, I am
using my key here, my Amana potion key, although I'm using a
capital M, a capital P, It's still talking to this man, a potion key right here. So that's the one I'm finding. And then I'm simply decrementing from it and then adding that decremented a mountain back to my updated inventory amounts. So we're using the key
to adjust the value. So just show this off. I've got this BP controller
set as my debug object here. So I'm starting off
with three 456. And I should have some red
font to decrement this, I'm going to press 7543, et cetera, et cetera. So there you have it. A map variable container
for a key, value pairs. Look it up by the key, and then you can increment
or decrement the value. It's great for something like
inventory, such as this. Alright guys, that is going
to do to offer this one. We will see you in the next one.
73. Enum: Welcome. In this video, our goal
is to learn about enums, which is short for
an enumeration. This is another type of
lists we can create and use to help drive logic
in our blueprint scripts. It's actually one of my favorite variables
to create and use. So what is an enumeration? Enumeration is a datatype consisting of a set
of named values. It is a listing of
labels, so to speak. Now this is something
that we're going to create here in our
content browser. And then we're gonna
make use of it inside of our ThirdPersonCharacter
Blueprint. So come under your scripting
Blueprints folder, this is going to be
a sensible place to create an enumeration. And if we right-click
and some empty space, we've got this
blueprints category. And in our little fly-out menu, we have the ability to
create an enumeration, it says in the tool
tip, and enumeration is a list of named values. Go ahead and click on this, and we're going to give
this a name right away. I'm going to call this E
underscore health status. Now I always like to name my creative enumerations
with E underscore. But again, you can use a naming convention
of your choice. And then I'm going to double-click
on this to open it up. Now inside of here we're
going to click on this plus add enumerator button once, twice, three times
to enable us to add some labels inside of here
that we can make use of. So I'm going to
overwrite each of these. First one's gonna
be called Super. Second one is going
to be called, okay, you can make these labels,
what's your wants? And my third one here is
gonna be called hurt badly. So these are
essentially going to be my three distinct health
status is that I'm going to use to drive some logic within my third-person
character blueprint. I'm gonna go ahead
and save this and then I can close this out,
don't need it anymore. And I'm gonna be jumping into my ThirdPersonCharacter
Blueprint. If you forgot where
that is under the third-person
Blueprints folder, Double-click on that
guy to open it up. Once inside of here, we're
going to create a variable. So I'll create a variable by simply clicking on
this plus Add button. I like to do it in a
variety of ways to show off different ways of
creating variables. And I'm going to call this
E underscore health status. I'll name this the exact same
as I named my enumeration. I'm going to hit Enter here. Now over in the Details panel, I'm going to change
the variable type. Now, while I named
this the exact same as my enumeration
I just created, I could have named this
anything I wanted to. However, I want to map this to coming under variable type. My E underscore health, whoops, E underscore health
status enumeration. There it is, right there. So I am telling this
variable that I'm creating, that I want to be of this type. Now once I click Compile here, I can see that I can change my health status
default value to be super, okay or badly. And because this is a
variable, I can change it. I can change it from
super two, okay, or badly, and then use that
status to drive some logic. Alright, so let's
go about creating our initial bit of script here. I'm going to start off by
creating a custom events. I'm going to right-click
in some empty space, type in custom, we're going to add
a custom event that is an event that we get to name and call it
when and where we want to. And I'm going to zoom up here
because I'm very far away. I'm going to call this
updates health status. And then I'm going to bring in my enumeration variable here, holding down Control, left
clicking and dragging. And what we can do with
this guy is we can drag out of this and
bring in a switch node. If I just begin to
type in switch, this brings in a
switch node that's going to allow me to switch based on the value
of this enumeration. So here we go, switch
on eHealth status. You can see the output
pins right here, say super, okay, or hurt badly. Those are the exact
labels that I have here inside of this
enumeration, super okay. Or her badly, if I plugged in a different enumeration here, it would say switch
on whatever that was. And it would have output
pins corresponding to whatever labels were inside
of that enumeration. Now this is great
because depending on the value of this variable, it's going to fire out
of different pins here. And what this will allow us
to do is adjusted something, in this case about
our character. What I'm gonna do is
I'm going to adjust our character's movement speed based upon our health status, whether it is super
okay or hurt badly. So I'm going to bring in my
character movement component. Drag and drop it in here. Inside of my character
movement component, I have this parameter
called max walk speed. That's what's controlling how fast my character can move about the level I'm going to
drag out of here and type in max walk speed. I want to be able to
set my max walk speed. And I'm going to
duplicate this Control C, Control V, control V. And I can plug this same
Character Movement Component into all three. It doesn't matter if
you have one of these. Or I could drag and drop my character moving
components separately. I could have three of these and plug these separately
into each of the targets, doesn't matter how you
go about doing it. I'm gonna go like this, like this, and like this, let me just double-click on that to bring in a reroute node. And now I'm going to hard set my maximum walk speed based on if my health is super
okay or hurt badly. If it's super, I'm going to say my health is going to allow me to walk at that maximum
speed of 2000s? It is. Okay. I'll say it's back in
my default of 500. If I'm hurt badly, I'm going to set it to 100. Right now. This is all well and good. But we're not calling this
custom event anywhere. We need a way of calling this custom event of firing
and off so that we can set our maximum
wants to be based upon the value of this enum. We need a way now of switching this status
of setting that. So that's what this next
bit of script is gonna be. Alright, so I'm just going to
start with an input event. I'll right-click and
some empty space and I'll do a search for key board h because
we're going to be using this input event
to modify our health. And just a few adjustments
we need to make here from things that we had
changed in previous videos. Select your health
float variable here we're going to
change this back to 1.0, which is going to equal 100%. And then with our
modified health function, this was created back in
our functions section of the course when we were setting
out to create a function, you can find out how
we did that there. I'm going to make a
few modifications to this as well because that
section of the course, we modified our modified
health function. I'm going to left-click
and drag this on top of our press
key right here. We had this given input
as a passed by reference. We set that as a
pass by reference. At some point, we're
going to undo that. So with that node is selected
in the input section, you can check that
because we want to input something they're
hard-coded, so to speak. And I also need to modify some
stuff about this function. So I'm going to double-click
on this to open it up. We've got this increment
currently in there. I'm going to delete that out. So what we wanna
do here is we've got health value that we're going to hard set right
here back on our function. We're going to say every
time we press this, we're going to decrement by zero points one,
essentially 10% health. So that's gonna be our input going to double-click
back on here. When that happens,
we're going to subtract that or rather, we're going to add that to
our current Health value. Even though that's
a negative number, we're going to be adding that negative number
to our current health. So we're going to be
taking that negative 0.1. We're gonna be adding
it to this value, which is going to
equal 0.9 or 90%. And we're going to
be outputting that. We're going to plug
this in like this. We can still maintain that
if this is greater than, if that's greater than zero, we're going to play a
positive sound effect. If it is less than zero, we're going to play a
negative sound effect. So that's all well and good. So make sure you're modifying health function is updated
to look like that. I'm going to compile
that right away. And back in our event graph, we're going to
continue forward here. So we're going to say if our current health
dragging out of here is greater than or equal to 0.75. Essentially, if we're, we've got three-quarters
health or more, we're going to bring
in any branch. That is true. We're going to set our
health status here. So we're going to drag
and drop this onto the true to bring any center. We're going to say
if your health is three-quarters or greater, your health is now
labeled as super. If that is false, we're going to bring in
a another branch node. And we're going to do
another evaluation here. So dragging out of here,
we're gonna do a search for another greater
than or equal to. So if it is gonna be greater
than or equal to 0.26. So essentially 26%. If it's between these
two ranges, 26 to 75%. If that's true, we're going to Control C and Control V on
this guy a couple of times. So that's true. It's between
this range 26.75% health. We're going to say
your health is okay. And if it's false, you've got 25% or less health. We're going to say you are hurt. Badly. So that's
all well and good. Obviously you see that
this is not connected. And the reason that's not connected yet is
because I want to sneak a print string in here. We're going to print
strings so that we can actually see our current
health spit out to the screen. So I'm going to
convert this float into a string by
plugging in like so. This is all well and good. However, whenever I'm switching the value of my health
status variable here, we're making use of that appear to drive our
maximum walk speed, but we're not calling
customer advantages yet. So we actually have to finish
off this bit as gripped by calling where this
custom event to fire off. And we can do that by
right-clicking in some empty space and typing in up dates. There it is, call function
update health status. That is the exact name of this. We're going to call that. This is going to call for this
custom event to fire off. We're then going to see okay. What is this health status
been updated to? Super okay. Or her badly, Depending on
what this is now set to, we're going to drive our
character's movement speed. So let's compile
this, makes sure that this is all hunky-dory. Forget to save it. I'm going to kinda tuck
this away up here. We're going to play this that our debug object as our
ThirdPersonCharacter and going to actually select my character
moving components. So our default walk speed is
going to start off at 500. Even though our health status
by default is set to Super, we're not evaluating that yet to determine our
maximum walk speed. So know that when I start
moving around here, we're going to be moving
around in our speed of 500's. So bringing that back on. Okay, you can see
that I'm moving at about yay speed that is 500. I'm going to press
my H key here. Now at 90% health, which is still super so my maximum walk speed is
now going to be 2000. You can see me
moving much faster. I'm going to press that
H key again down to 80% health, 70% health. Now I'm in this okay range, so it's going to be
set back down to 500. I'm still not okay range. So let me keep hitting
the H key here to deplete my health now to 20% health. So now I'm hurt badly. So this is as fast as I
can run, so to speak. That is a great use of
an enumeration variable, determining your health
status and then you can modify something
about your character. So with that, what are some
other uses you can think of? Well, let me just throw
a few of them out there. What about you have an enumeration
for different weapons. And depending on what
weapon you have equipped, say a sword, a dagger, a bot, your movement speed, or even your available
attacks could very well. What about any NUM for a
different character classes? Warrior made, the, etc. and depending on what your
character class is set to, certain weapons may or may
not be available to you. Or what about an enumeration for different game states or events? Think of a game
like Rocket League. You could have an enumeration
for things like gameplay, goals scored, halftime, etc. And depending on what
that enum is set to, you can make it so that
different things are happening, such as showing a cutscene of a goal after a goal to score. Alright guys, that's gonna
do to offer this video, we will see you in the next one.
74. Struct: Welcome. In this video, our goal is to learn and
demonstrate the use of the very useful
struct variable type. Now, this is a type
of variable I create all the time in my
own gaming projects. With a stroke, you
can hold lots of data types that are related to the same thing within
a single container. So let's go ahead and
create a struct variable. Here in my scripting
Blueprints folder, I'm going to right-click in
some empty space in under the blueprints category in
the little fly-out menu right underneath enumeration we have the structure also known as a struct variable type
that we can create. So let's go ahead
and create this. I'm going to name this
STR, underscore spells. And then let's double-click
on this guy to open it up. Alright, let's define what
a struct variable even is. So a structure or a struct
variable is essentially a variable that can hold lots of other variables inside of it. So essentially structs
bundled data together. You can think of a struct as
a giant storage locker with all the other boxes inside of that storage locker as
individual variables. Each box inside the storage
locker has its own contents. We can then go inside
of the storage locker. In this case, our struct and take out the content of a box, in this case a
variable as needed. Now, these strokes are
great for holding variables that belong together in
some way, shape, or form. So we've got a structure
that we're going to be creating here called spells. Think about all the different spell properties that we could contain within 11
container of sorts. Here, we can add the
name of the spell, the type of effect, the element that it's
associated with. Maybe a man of cost,
maybe a cool down. All those things are associated
with a given spell and it would be great if we
could contain them with all in one asset. Well, a stroke is a great
place to do just that. Alright, leave this guy
open for the time being. We're going to actually create two more enums assets first, before then coming
back to our struct. So jump back to your
main editor here in, in your scripting
Blueprints folder. And let's create
these two enums. Can right-click under the
blueprints fly out menu. We're going to create
an enumeration. This one I'm going to call E
underscored spell elements. And then I can right-click on this right away
and duplicate it. Control D will
duplicate it as well, because it's also going to be an enum and I'm going to call this one E underscore
spell types. And then we can double-click on each of these to open them up. So spell elements is open. Let's open up spell
types as well. Alright, so under spell types, I'm going to add
three entries here. We'll start off with spell
types, 1234 spell types. I'm going to do direct
damage in display named number two here is
gonna be area of effects. The third one is going to be, we'll say healing. Sure. Let's go ahead and save this and then you can
close that guy out. For spell elements,
we're going to add three entries here, 123, and these will be none. Fire. And my next one
here will be wind. And actually let's add one more. Let's do a water as well. Water. What tray? Potter. Let's go ahead and save that and then we can close that out. Now, those created,
we need to jump back into our structure
and we're going to add some new variables
through this. Again, think of a struct as a container that can
hold many variables. I'm just going to slide
this over to the left here. So I'm going to add, let's see, 1234567 if I'm counting right, so let's add, I believe
that's seven right there, 0 through six,
**** equals seven. So my first one here, I'm going to call spell, name. And this will be of the
texts variable type. Come on, texts, There we go. Second one here will be
called spelled type. And this is where we can slot in the room that we just created. We can come under EU
and find it down here. Although you can also search
for it up there and there, you can see it's spelled
types right here. Next one, we're going
to call spell elements. And coming under
our new category, we're going to set it
to spell elements. Next one, we're going
to call it manage cost. And whoops, that one did
not take right up here. Let's go right back to there, to our spell elements here. Under enums spell elements. There we go, man of costs. We're going to set
that to be an integer. We're gonna go cool down next. We'll set that to be a float. Next up we've got spell effect value that
can be damaged or healing. That is what I'm referring to
you by spell affect value. And it will set this
to be an integer. And then last but not least, I've got casting S f x. So this would be
the sound effect associated with casting a spell. So I'm going to set this
to be a sound wave. Will do sound wave
object reference and then something else. Just to show off here, we
could set this to be an array, so we can actually have an array of different sound effects
that we want to play. So that's kinda cool there. Alright, let's go ahead
and save this out up. And I am seeing this
warning up here. And if we mouse over it, it does say you cannot
parse that value. You got to have something
other than none in there. So let's expand this
down and let's go ahead and add a couple of
default values for this. We can add that default
values by not under here. Here we've got this
default values tab casting s effects plus, plus, and let me just
set these to be. Let's go darker ball. What do we got Dr.
Bowles windows open and we'll add data labels. Window close. Yeah, it doesn't really matter
what you put there just have two different
sound effects. So there is our structure. We're seeing that
that is good to go. We can go ahead and
click Save there. Alright, with this all done, jump on over to your
ThirdPersonCharacter. And if you forgot
where that guy is once again in your third
person Blueprints folder, Double-click on that
guy to open them up. So inside of here, we're going to make
use of that struct. We need to create a variable. So come under your my
blueprint variable section, click the Plus button, and we're going to call
this one my spells. We're going to change
the variable type down here from a Boolean to our struct, STR,
underscore spells. And there we can
find our structure. It's under the
structure category. And if I come over into
the details panel, I can make this in
array of struct. So I'm gonna change
the container type here from single to array. I need to compile right here. And when I do, I can add multiple entries
to my spell array here. So let's click once and twice, and now check this out. As I expand these down, I've got access to change all of these different properties that I set up here in my struct. So here in my struct, I set up fields for entering
in a text name. I entered in. I
entered in fields for defining a spell
type, spell element, man accost, all these
things and here they are available to me now in my
BP ThirdPersonCharacter. So let's set some of these. I'm going to say my
first spell name here is going to be called fireball, spell type, direct damage,
sure, spell element. I'm going to click this
drop-down and look at all those options that
I defined in my emu. Again, for our spell type
here and spell element. We associated these with enums, those named list that
we created earlier. So spell element, we'll
set that to fire. Man Acosta will set
them to be five, cooled down to 0.5 shore
spell effect value 25. In this case, I'm meaning
that as 25 as direct damage. For my next entry
here, spell name. I'm going to set
this to be cure. This bell type is
going to be changed to healing spell elements. Well, it's not gonna be any of these elements are going
to leave that as none. Managed costs will say ten, cool down 3.8, spell
effect value 50. And then we can also set the sound effects
for each of these. I forgot to do that
for the fireball. So expand each of these out. Yes, you can go
ahead and change out the sound effects so you can leave the defaults there
for your fireball, but maybe for your
curing sound effect, you want something different. So I'll try one called
ship VR shape scale up. And I'll do the same for
this other one ship, ship scale up as well. Those are in the engine
content folders. By the way, if you forgot how to access your
engine content folders, you can click on the
little gear icon, show engine content. Alright, so all that is
set up pretty sweet. Go ahead and compile
that right away. Alright, so with all this setup, how do we make use of
this struck variable? How do we reach into
this strike variable and extract the information that we're looking to extract. Well, for starters here we
have to add this to our graph. So I'm going to
left-click and drag. I'm gonna get it. And this is returning an array because we have two
elements in here, a fireball with all of
these properties about it. And our index one here
is our Q or spell. So we've got index 0, our firewall, and index one in our array,
the curing spell. So we can drag onto
this and type in gets, we can get a copy here. And depending on what
value we input here, it's looking for an integer. We can input either 0 to
return our fireball index 0, or we could input one to return our curious
belt That's index one. So that's how that works. Then what we wanna do here
is right-click on this pin. If I right-click on it, I can split the Struct Pin. Now watch how this node
transforms when I do this. Bam. Now I've still got
this integer inputs, so I can still define, do I want to be looking
up index is 0 here, my fireball or index
one here for cure. But now I can output all of the different properties
related to that given index. So I can find for index is 0, the fireball spell name, the direct damage,
yada, yada, yada. Now note here that
you can go back and collapses all down by right-clicking on
any of these pins. And I can recombine
the Struct Pin. But in this case we
want to right-click on this and split that struck pin. Now, something that is worth noting here is
there are actually lots of strokes to be found when working with
blueprints scripting. And this is a little
bit of an aside, but it's worth
pointing out here. I'm going to right-click and some empty space and just type in get actor transform. This would get the transform for our ThirdPersonCharacter. Now if I was to right-click
on this pin right up here, I can split the Struct Pin a transformed
consists of location, rotation, and scale data. But even something like
the location, right? That is three values
in one in X, Y, and Z vector that determine
our final location. Those are three float values. So if I was to
right-click on this, I could split this
struck pin as well. So you can see how there
are actually numerous, numerous nodes throughout
unreal that you can do this whole splitting
and recombining of struct pins,
something like this. A vector is a struct. It consists of three
float variables. So I can right-click on this. I can split it and
you can recombine. And even our rotator
right here that consists of three
float values as well, so we can split that. Yeah, worth noting, right-click
recombine, right-click. Whoops, not promote. Right-click, recombine,
right-click recombine. Alright, back on topic here, Let's make use of our struct. So I'm going to delete this out. I'm going to bring
in an event key. So let's right-click
and some empty space. Let's try something
on the nine key. Sure Why not? I don't think I'm using
the nine key anywhere. We're going to drag off of
our spell type down here, lead these two guys
down here spelled type. And I'm going to
search for a switch. On ease spell side. We're gonna do
something depending on what spell type we
are specifying here. Then what I'm gonna do is
I'm going to drag out of my spell elements and I'm gonna do a switch on spelled
elements like so. And we're going to say if
we're doing direct damage, we're then going to find out
what is our elements here. And what we're then going
to do is print a string. We're going to pull off
of our fire here and I'll kind of recap this. When I'm all finished here. Pull off of this, then we're gonna pull off
of our spell effect value. That's like how much damage
we're gonna be doing here. Spoiler alert, I'm
going to leave this as the 0 elements here. So we are going to be
casting a fireball, so to speak, without any
effects of any sort. But cashing in air quotes, drag off of here. And we are going to actually not plug
that into there yet. I'm going to drag back off
of here and do an append. We're gonna be printing
something out to the screen. Our a is going to
be you dealt space. R, B is going to be the spell effect value is going to convert that
integer to a string. We're going to add
another pin here. We're going to plug in
the spell name for C. So you dealt 25 fireball. And the last word here, we're going to add another
pin is going to be damage. And I'm going to add
a space before that. And that is going to
be all well and good. Nn last but not least, we're going to drag off of here. We're going to play, a sound, will do is play sound 2D. What sound do you
want to play it? Well, let's get one of our different cascading effects
here. Drag off of this. We're going to get a copy. We're going to
drag that in here. As we get to specify, remember our
fireball spell here, we've got two possible
casting sound effects, element 0 or element one. So let's pick one at random. So I'm going to drag backwards
off of here and type in random integer in range. We're going to go between 01. So that is going to
be our final set up, making use of our strokes here. Alright, so framing that up pretty good. I
think I got that. All right, let's go
ahead and compile to make sure that
script is good to go. Save, Let's jump in and play and then press that
there are nine key. Hey, setting our debug
object, jumping back. Here we go. And here we go. Precedent Nike, you should see
some texts appear up here. U del 25, fireball damage. I know there's no space
between fireball and damage. And as I expand
this again, again, you should hear one of these two sound effects
play at random. Alright, so I know that that
was a very basic setup, but I'm going to
challenge you to try to expand upon this
sort of a setup. Now, I want you to try
these on your own, ensure that you can cast a spell only if you
have enough manner. We're not making use of
our monocots right here. So ensure that try
something else. Ensure that you
cannot cast again unless you're cool down,
duration has expired. Try this, try adding
an emitter or particle system to a
spell that you cast here. Also try this, try specifying
a vector location that this given spell should spawn
that given particle system. So those are all
things given some of the prior knowledge
in this course, I'd like you to go ahead and
try now to finish this off, let's talk about some other
possible struck use as well. Imagine you had a
quest system struck. You can specify a
name, a location, enemies to spawn or be defeated, and maybe reward
types and quantities that could all be
contained within a struct. Or perhaps character base attributes could all be
contained within a struct. And you can specify
things like name, speed, health, all
those kinds of things. Alright guys, that's
going to do to offer this video on the
very useful struct. See you in the next one.
75. Flow Control Overview: All right, We have
finally arrived at that point in the
course where it is time high time to talk
about flow control nodes. Now, I know you've seen
me up to this point in the course use a lot of
these flow control nodes. But we have not yet had an official discussion about it because there's a lot
of topics to cover. So that ends right now. Here begins our flow
control node conversation. So our goal in this
video is to simply get an overview and
understanding of what flow control nodes are and their purpose within
scripts, a deeper purpose. We'll also take a quick look at common flow control
nodes used in scripts. Let's start by defining
what flow control nodes, even our flow control nodes are nodes that allow
for controlling the flow of execution
based on conditions. They assess some data inputs. And depending on the inputs, they determined
which execution out pin fires or when
an execution out pin fires are both essentially control
the flow of execution. For example, we've got
this branch node up here. We can flow into it. And then based on
a condition input, we can flow out of
the true branch if the condition is true, or we can flow out of the false branch if the
condition is false. Now flow control nodes have
a gray coloring at the top. And as we mentioned earlier
in our macro section, flow control nodes
are macros and you can see this by simply double-clicking on one of them. I'm going to double-click
on my gate node here. And that's going to open up
my standard macros library. These are macros, flow
control nodes are macros. Now, where can we find a bunch of these
flow control nodes? And here are a bunch of
the common ones that you will find throughout scripts. I have this all in my
Level Blueprint as a quick overview of many
of the common ones. Well, if you're looking
for some of these, you can obviously
search them by name, by right-clicking and searching for them by the title here. There are also located
under the right-click menu, right here under Utilities. And then in the utility section, you can come under flow control. And that's where a
bunch of these reside. Now, it is worth noting here
I'm going to be throwing this select node that does
not have a gray banner. It is not officially
a flow control load. I'm going to include it
in this section as well because it does sort of control the flow
of data that gets output based on in index inputs. So in a sense, it is sort of a
flow control node. So that's why I'm going
to include it as well. Super handy node to know about, by the way, a few more things to know about flow
control nodes. Many of them have hotkeys and I included these on the
node comments here. And so you can see
with a branch node, if you hold down the B key, left-click, you'll
bring in a branch. Those are super handy tricks. I would recommend
that you get to know because you are going to find yourself using these
nodes all the time. Also, flow control nodes, they are useful for
gating or restricting when an area of script happens. They're also useful
for determining which bit of script
happens next. So that's something
to know about flow control nodes bare
that in the back your mind. They are useful for determining when an
area of script happens, which bit of script happens. Next. Example of which script happens
next would be a branch. Do I flow out of
the true or false? An example of when
an area of script happens would be
with our gate node. And you can learn more about that in the gate
node video itself. Alright guys, that is
going to do to all four are flow control overview. We will see you in
the next video.
76. Branch: Welcome. In this video, our
goal is to learn how to use the branch node using an extremely common
locked door scenario as a demonstration. So firstly, let's define
what a branch node is. You've seen me use several
of these up to this point. Branches are essentially an
if then statement encode. They serve as a
simple way to create decision base flow from a
single true or false condition. Now once executed, the
branch node looks at the incoming value of
the attached Boolean. You can attach a
Boolean variable to this or you can
simply hard-coded by having that checked or
unchecked the outputs. And then this will output an execution pulse down
the appropriate output. So if this is true, and that's what the
check mark means, will flow out of here. If this is false or unchecked,
will flow out of here. Now, once again, the
hotkey for placing this in your graph is to simply hold down the B key and left-click. Now, it's worth
noting here that we have previously
used a branch node. We did this during
the introduction of the Boolean variable. And we did this inside of
our ThirdPersonCharacter. So why don't you find your
ThirdPersonCharacter. You can find that in the
third-person Blueprints folder. Double-click on
that to open it up. And what we did during the
Boolean video is we made it. So when we input action
jumped via the spacebar, we evaluated the condition of our can jump
Boolean variable. And if it was true, which we currently have it true by default, then we can jump. If it's false, we cannot jump. And we can see this
by simply trying to play when I send my
debug object there. And once again, this
is set to true. And you can see that by mousing over this while you're playing. And if I press the space-bar, you can see that indeed
I am jumping in. As soon as I release.
There we go. It however, if I was to change, Ken jumped to false, we'll press the space bar. This will evaluate to false
and nothing will happen. So let's go ahead and try this. Pressing the space bar, you can see the flow
of execution dies right here because this
evaluates to false, which we can see in
the little tool tip. There were never getting
beyond this branch. It is stopping the flow of
execution dead right there. Alright, let's try to show
off another scenario here. So I'm going to create a
brand new variable over in the My Blueprint section of the ThirdPersonCharacter
Blueprint, clicking the plus button
at the very bottom here, I'm going to call this
hes key question mark. And I won't compile this. And just to let you know here, I'm going to leave
this has key as false. I do not have the
key right away. Actually, you know what, I'm going to check it
to true will say yes, our character does have the key. So we'll compile that save. And then what we're
gonna do is jump back to our content browser here, I want to go into our
blueprint section. We have our rotating
door we created this blueprint is rotating door blueprint when we talked about the rotator variables. So you can review that video if you've not created this door, I'm going to left-click
and drag this into my level right away. Then I'm going to double-click
on this to open it up. We're going to modify our
script here just a little bit. So what I'm gonna
do is I'm gonna kill out our get
player character right here and right
here, and right here. That was one way that we just had set up
there of checking if it was our ThirdPersonCharacter
overlapping that door. What I'm gonna do
now is we're gonna check grabbing onto
this other actor pin. We're going to cast to
our ThirdPersonCharacter. This is another way
of checking to see, hey, who is the thing
that overlapped us? And again, we're
checking the box as the component that
we're checking to overlap the box
component right there. We're going to
wire this through. We're going to do
something only if it was a ThirdPersonCharacter
overlapping us. However, we're not going to open this door just yet unless we find out that our
ThirdPersonCharacter has the key, if you cast your
ThirdPersonCharacter in this manner, we have yet to officially
talk about casting nodes. We can reach inside of our ThirdPersonCharacter
and access any functions or variables or anything like that that
lives inside of there. We could call a function
access variables, etc. Specifically, we want
to dry out of here and find r has key. We're going to get, does
our player have the key? If you don't see this, trying to do what
I just did there, make sure your
third-person character is compiled after you created
that has key Boolean. Now once again, this is true by default,
that's how we set it. So we're going to use
this as our condition. If it's true that our
player has a key, then we're going
to open our door. With this all in place.
I'm not going to worry about this end
overlap right now. I'm only concerned about
the opening of it. Let's go ahead and compile this. Let's save, and then
let's give this a play. Alright, so we can check for
R script working wrap their, here's where you can
set your debug object. If you have multiple
doors right there, you can say which door you are checking out to see if it's
working. Alright, here we go. We should have that
key because we said that true by default,
that Boolean. And there we go, it will open. Now, let me just jump back into my third-person character. I'm going to change has key
to false, compile save. Let's go back to a rotating
door click play right here. And now our character
does not have the key. So let's go ahead and you see we're
approaching that door. You can see that
overlap happening, but it's stopping the flow of execution dead right
here in our branch. Alright, Jumping back to our ThirdPersonCharacter
Blueprint here in this jump section of script. I wanted to point out that your conditioning a
four-year branch does not have to be just a single
variable such as this. And it also does not have to be just a single hard
input conditioned by checking this box or
unchecking this box, you can actually do a more intricate
evaluation if you will. And if I move over
to the left here, I'll show some other
nodes that are oftentimes found to be
plugged into a branch. And these are these
guys right here. We've got an anti-node, NAND node in or a NOR
and an x or if you will. So the comments here
describe how these work, but we can give a
few of these a try. I'll try out this one
because this is very common. You can try plugging one of these into your
branch right here. And we can even use our Ken jump is one of the conditions. Now this will return a true
if all inputs are true. So let me just click
this plus button. Let's go four times. We could keep adding
more input pins. Now I'm going to plug
my can jump into this. Now currently my can jump. That is false, but I'll
check all the rest of these. Now, this should only return
true if all inputs are true, these three are true. Can jump here, however is not. So this should disable my character from jumping
because not all are true. Compile this and play. Pressing that spacebar. You can see I can
jump, let me change, can jump here to true,
jump in and play. And now I can jump, all four of them are true. Next I'm showing off
this NAND node I can jump is set to true
as are all the others. This will evaluate to false
because all inputs are true. That's how this one works. So it only returns false
if all inputs are true. So I'm pressing the
space bar, can't jump. However, if I was to change
one of these two false, and it could be any
of these that I pick, then it will evaluate to true. So now I can jump. The OR node will return
true of any input is true. So I've got three of
them that are false, but my can jump here is true. So clicking play here, pressing the space bar, it will evaluate to true because only one that's all
I need is true. Next, we've got the NeuroNode. This evaluates to true only if both inputs here are false. So currently my Boolean
variable is false, as is this empty
slot right here. So if I click Play, you can see that I can jump. However, if I was to set
even one of these to true, jump back in and play. You can see that is going
to evaluate to false. Last but not least, we've got this XOR node and
this is going to evaluate to true if
inputs are not the same. So currently my ken
jump is set to false. This checkbox is set to true
so they are not the same. So this should evaluate the
true jumping in and playing. Yes, indeed, I can jump if I was to set these to
be both the same. So right now both of them
are false. Jump in and play. It does not evaluate to true. So there you have it. Those are some useful node, some complementaries
that are oftentimes plugged into the condition
input of a branch node. So let's talk about some
possible uses for branch nodes. Well, you could
ask the question, does the player enough
manner to cast a spell? Does the player have enough
manna to buy an item? You could do some evaluation
of money that the player has an integer value
of the amount of money versus the amount of
money required to buy an item. If that is true or false. You can evaluate that to determine if the
purchase goes through. What about, is a player in the right location
to use an item? Or maybe, is the player low on health, you
could evaluate? Is the player at twenty-five
percent health or less? If that is true, you could do one thing versus if it's false, you could do another. Alright guys, that's
gonna do to offer this discussion on branch nodes, we will see you in
the next video.
77. Sequence: Welcome. In this video, our goal
is to learn about how the sequence flow
control node can be utilized in scripts. Now this node, you can fire
off multiple sections of scripts simultaneously and
in an organized fashion. Now in this video
I'm gonna be doing work inside of my
Level Blueprint. So if you'd like
to play along at home and forgot how
to get in there. In your maps. Simply come right here, open Level Blueprint and
that'll get you right there. Alright, what is
a sequence node? It is one that allows for a single execution wire input to fire off of multiple
execution outputs. Now, this is great for events. It only allow you to have one copy of an event
within a script, like Begin Play,
begin, overlap, etc. Now you can add
multiple output pins here if there's multiple things
that you wanna do off of, say, Begin Play by simply
clicking on this plus button. Now if you want to remove any of these output execution pins, you can simply right-click on them and remove them like so. This is great for
keeping scripts organize and to
add one of these, because this is such
a commonly used node, you can simply hold
down the S key, then do a left
mouse button click, and that'll bring
one in for you. So let's put one of
these to use inside of our level blueprint
here, not expedite things. I have a little bit of
script I set up ahead of time over here in
my Level Blueprint. But that's all fine and dandy, I'll explain what I've done so you can play along at home. So I want to do three things
upon beginning play here. So let me bring in and
begin play event node. I can hold down the P key and left-click to bring
in Event Begin Play. And just to show that
you can only have one of these event begin
plays within a graph. If I try to right-click
and some empty space, and I'll do begin play like so. It'll just jump me right to it. Or if I hold down the
PT and left-click again, I've gotten nothing. So only one of those
can go within a graph. Now, going to hookup
event begin play. This will fire off as soon as
we begin playing our game. And I'm flowing this
through a sequence node. And the reason I'm doing
this is because I wanted to do three things off of Event. Begin Play. I want
to play a sound. This is gonna be
some started music. I'm gonna be getting
my player character than casting to my
ThirdPersonCharacter. And I have promoted this to a
variable here so that I can save a reference to my
ThirdPersonCharacter in case I wanted to do something to my ThirdPersonCharacter
later, I would just simply need to drag and drop one of
these into my graph. Then the other thing I
wanted to do here is something a little
bit more fancy. I placed a target
point within my level. You can find one of these
in the place actors panel. So I went here, added
a place actors panel, did a search for a target point, is just adds an icon to your editor and it
defines a point in space for you that you can use within a graph
like I'm using. So with that target
points selected, I hold down the R key is in
reference and left-click, and that's how I get
a reference to that. Then I simply
dragged out of that, got the actor location
dragged out of this search for random point
in bounding box, I specify a size
for a bounding box, this is essentially an area
within my level around, centered around my target point. Then I drug out of this
to make a transform. All I cared about really
was the location. The rotation scale
did not matter to me. Then I drag out of
this and I searched for a spawn actor
from class node. Here, I'm specifying my BPMN, a potion that I created
earlier in the course. You can specify any class here,
it doesn't really matter. So these are the three things I wanna do off of begin play. So Event Begin Play right
here using a sequence node. I can go bam, bam, bam. And if you want to organize your script
a little bit better, you can double-click on a wire to bring in a reroute node. Again, sequence
nodes are great way to organize your scripts. So I'm going to compile this to make sure my script
is looking good. So upon beginning play, we
should hear some music. We will have a reference
to our character, and we are going to
spawn a man, a potion. Now, I can play the
game and see this, or I can simulate the game and
we should hear that music. And we should spawn this potion. Now, this is all going to
happen behind the scenes. So this, you're just going to
trust this going to happen. But we're going to hear something and see something
so I can play the game. And he saw that emancipation
is born in here. A little bit of music. Or if
you want to test this out, you can also simulate your game. Now to do this, you can come under
your three dots right here and
choose to simulate. And you can see the
hotkey for this. Now when you simulate your game, you're making your
game run all the code, all the script is
running as well. Whoever you're not jumping
in and playing your game. So if you click right here, you can see that it did
spawn in a manner potion. And some music is
playing as well. I can stop this. Alternatively. That's a civil right now
I'm in simulate mode. Just note that alternatively, if you do Alt plus S, that does simulation
mode as well. This is great for just
making your game run. And you just want to fly around like this and check things out. Now, before we wrap
this video up, I just wanted to prove
out that you do not need to use sequence nodes. They are essentially
a quality of life type node to better
organize your scripts. Here is the exact same setup
without the sequence node. It'll do the exact same things. However, my wiring is a
little bit crisscrossing. And you can imagine if I had 45610 things as could get
really, really messy. So if I click play here, you can see I do have
that madam potion, lands and music, etc. So oftentimes these
sequence nodes do come directly after an
event to do one thing, a second thing, a third
thing, et cetera. But that's not
where it has to go. You can place them where they make sense
within your script. Something else I wanted to
point out here as well. Once again, you can only have one copy of an event begin play, event begin overlaps
those sorts of things. However, there are
certain event nodes, such as input events
like our eight key, that you can have
multiple copies of. A case like this. You would not need a sequence
node because you can have one events,
do three things. So to prove this out, just clicking in the
press that button. Hello, are you there? Hello, are you there? So don't need a sequence node
for something like this. Although that wouldn't
be a bad idea either. Sequence nodes,
quality of life type, note, I use them all the time. That'll do to offer this video. See you in the next one.
78. Do Once: Welcome. In this video, our goal
is to learn how we can utilize the do once node
within our scripts. Now, this is a fairly
self-explanatory node that seems like
you'd only need to use every once in a great while. It turns out that this
node comes in handy in all kinds of scenarios. So what does the do
wants no do, well, it fires off an execution
pulse just once out of it. Now from that point forward, it will cease all
outgoing execution. It will not fire
again out of here into any other script that
you have beyond here, until you have a pulse sent
into the reset input here. Once you do that, it can
do once, once again. Now, to bring this
node into your graph, you can right-click
and do a search for do once or holding down the O key, you can left-click and
that'll get your one as well. Now let's put this to the test by running
through an example here. For this, I'm gonna be
working inside of my Level Blueprint so you can
access that right here. Open Level Blueprint. Also, I wanted to point out
here that we're going to be accessing a variable inside of our third-person character. So if you have just come
to visit video directly, open up your
ThirdPersonCharacter. Within this pathway, we're
going to be accessing this total XP earned integer variable within
our ThirdPersonCharacter. So if you don't have this, go ahead and create
an integer variable, I have the default
value set to 0. Make sure you compile
it as well because we're going to be
accessing it here shortly. Alright, let's jump back
to our Level Blueprint. The first thing we're
going to need is an event. And let's do this actually
with an overlap events. Let's overlap an area within
our level and then add some experience points to
our character for being so awesome and
traversing to that spot. So let's jump back
to our test map here and add a trigger sphere. If you don't have this
place actress panel, you can find it here. Place actors panel that
we'll get to that. Let's place a trigger
sphere within our level. With that selected over
in the Details panel, I am going to increase the
size of our sphere radius, make it a bit bigger. I'm also going to come under
the rendering section, unchecked actor hidden game, so that we can see this sphere. Now with this
selected, I'm going to jump back into my
Level Blueprint. We're going to right-click
add an event for this. Coming under, Add
Event collision. We're gonna do something
on begin overlap. So the first thing we wanna
do is check that it is our ThirdPersonCharacter that is the other actor that's
overlapping us. So we can do a check here by grabbing out of
this other actor pin, doing a Cast to
ThirdPersonCharacter. And we'll talk about
casting officially later on in the course here
that's coming up soon. And with this all done, we can reach inside of our
ThirdPersonCharacter and we're going to get that
total XP earned. And let's just drag out a here, hit the plus button. We're going to add, we'll
say we're going to add a 100 experience points
for reaching that sphere. Good job guy. Then we're going to drag out
of our ThirdPersonCharacter, do a search for total XP. We'll set it. So we're
getting it, adding a 100. We're going to set that
as the new updated value. However, we only want
to do this one time. We don't want to make it
so that we can overlap this sphere again and again and again and get
100 experience points. We only want to say, Hey,
you did it the first time. That's great. Never again will flow through the Arduino
wants node here. Then Award the 100
experience points. Last but not least, we got
to wait to check this. So I'm going to
drag off of here, do a print string. And we're just going
to print this out to the screen by dragging off of our total XP earned
into the string, it'll convert that
integer into a string. Compile that, save. Let's go ahead and
play to test this out. I'll set my debug object
there to my test map. And let's overlap that and see how awesome we are gained
a 100 experience points. So check up right in this
corner of the screen. 100 experience points. Now that should only
happen one time. So I'm going to end that overlap and then I'm
going to overlap again. You see that it flowed
into the do wants? No, but it did not flow
beyond it because this node says do once and never again. Alright, now let's try resetting this by
using another input. So let me just right-click
some empty space. I'll look for keyboard
for sure the F key. So when I press the F key, I'm going to reset this. And so here we go. I'm going to compile this. I'm going to play, I'm
going to overlap this. You can see I get my
100 experience points. I'm overlapping again currently, I cannot pass beyond here. However, when I press the F key, watch here we go
pressing the left key. It's going to reset it. So it should do once. Once again, I get another
100 experience points. It stops because it's doing it only once I'm going
to press the F key. It'll allow me to
do it once more. There we go. So that is how the
F key works to reset that doing
once, once again. Now note on this do
once node there is a Boolean input where you
can start closed or not. Currently are we are
not starting close. You can plug in a
Boolean variable if you want to start at close or not. So let me just show you that. If I do start a close, so I checked that
box and now play. I'm going to overlap
this sphere. But it doesn't go beyond here. Yes, it's called
the dual wants no, but we are starting closed off, meaning that we have to reset it here first in order
for it to do one. So now if I press F, it resets. And now I can go
beyond just once. Not again, press F. So just wanted to point
that out as well. This start clothes can
make sure that the first time in this case we overlap it. You don't actually
do once that you have to reset it first. Let's talk what are
some possible uses for the du once note here, well, think of a level up
fanfare or notification upon reaching a given
experience points threshold, you know, you've reached 5
thousand experience points. You've leveled up. You only want that to
play the first time you exceed 5 thousand total
experience points, not 5,005, not 5,010, et cetera. Or how about you're interacting
with a treasure chest? You want to open it,
but open it just once. That would be another great
use of a do one snowed. Or how about
harvesting a mineral? You've got some iron
ore in your level and you walk up to it and you
can harvest it just once. And then maybe a timer
or could be set to allow for that to
be harvestable. Once again, say after an
hour, two hours, etc. So those are all possible
uses of the Dew wants node. Very common to use it. I love it. One of my favorite
flow control nodes, guys that is gonna do
to offer this one, we will see you in the next one.
79. Do N: Welcome. In this video, our goal is to
gain that knowledge of and demonstrate the practical
use of the do n node, otherwise known
as the dawn node. Now this is a great
note to use to restrict the amount of times
something can be done. So what does the do and no do? Well, it fires off in
execution pulse n number of times as defined by this
integer input right here, you can plug in an
integer value or you can hard set it like I've
got the number 37 here. So after this limit
has been reached, it will cease all
outgoing execution until a pulse is sent back
into the reset input. So in this case, if we were to hook up an input key to this, say the F key for fire. We would fire out of this exit, this execution output 30 times. And after 30 times, I would have to reset
it in order for another execution
pulse to be executed. Now, this counter will output how many times
it has been done, and we'll show that off
here in just a little bit. But that is essentially
how the do n node works. It's a lot like the do
once node only you get to set how many times
it does the thing. It doesn't have to be onetime. You could set this to be one, but you can have this
be 1102100, etc. So to add this node, you could right-click and
just do a search for Don. There is the do n
node or holding down the left mouse button clicking. You can add that as well. Let's put this to practical use. I am in my ThirdPersonCharacter
Blueprint. That's where you can find it. So let's try out
an example here. I've set one up ahead of time. And here is my example. I'm going to on a left
mouse button press, we're going to do three times. I'm going to output the
counter here to the screen. This could be a print text, note, it could be print string. It's all going to
work the same here. And upon doing
that, I'm going to spawn an actor from class. So this is a spawn
actor from class node I just slotted in the
blueprint effect fire here. You can really slot
in anything you want. You do have to give
this a spawn transform. I could have just done a GET world transform.
I wanted to do. I could've done a get
rolled transform, gets world transform for the actor or any of my different
components I chose to do on here for my
simulated hand. Now this is one that I added
earlier in the course. So if you're wondering what
my simulated hand is here, it is a sphere
collision component. And just to show you
where I place this within my viewport, there it is. That's my simulated hand represented by some
sphere collision. So we're gonna be spawning a blueprint effect fire at that spot relative
to our character. So that's our setup right there. Let's go ahead and
give us a try here. Let me compile that, make
sure my script is good to go. So we're saying
we're gonna do this three times and then pressing the RT will reset that and allow me to do
it three more times. Once again, clicking play. Let me just get this all set
up to set my debug object to the ThirdPersonCharacter so you can see this
script executing. Alright, so turning there
is my simulated hand. Once you can see in the upper left is outputting
how many times we've done here our counter a
second time, 21 more time. Three. Now if I try doing it again, it's not going beyond
the due end node. However, if I press the archae recipient now,
we're going to reset it. And that will allow me to
do it three more times. So here we go. 123,
but not a fourth. So something like that,
that's set up right there. It could be used
to light torches, like in a Legend of
Zelda style game. Some other possible uses, we could use a set-up
such as this to determine how many times you can harvest
an item before you can. That's another good
use of the n node. Perhaps you're using it to determine how many
times you can fire off a given weapon
before you must reload. Or maybe you use it to
determine the number of interactions you can have with an NPC before you
can't have anymore. You know how so many games have is where you can
interact with an MPC, say three times, he's got
three unique things to say. And then that's it. Alright,
so there you have it. The end node, it's
kind of a cousin, is sibling, if you will, of the do one snowed a little bit more
flexibility with the do n node they'll
do to offer this one. See you in the next one.
80. Flip Flop: Welcome. In this video, our goal is to gain
knowledge of and demonstrate the use of
the flip-flop node. Now this is the node
to use whenever you want to toggle between
two bits of script, whenever an event of
your choosing occurs. So what is a flip-flop
note it takes in an execution inputs like so. And toggles between two
execution outputs, a and B. So the first time
you flow into this, I'll put a is called
the second time. Output b is called
the third time. The fourth time b, etcetera. It flip-flops between
shooting out of a then B. Now it does have a Boolean
output allowing you to track when output
a has been called. That is oftentimes
used to just ensure that you know which one
of these is being called. Maybe you want to print
strings so you can see when a is called vs, B, etc. To show off an example, use of the flip-flop note
I'm gonna be doing this inside of my
ThirdPersonCharacter Blueprint. So if you want to
play along at home, you can find that under
third-person blueprints, double-click on that
guy to open them up. And we need an event to
get us started here. So I'm going to
right-click and do a left mouse button click event. You can use any
inputs that you want. I'm gonna go with the
left mouse button. And so when we press this, we're going to flip-flop between a than B than a than B
every time we press that. So what I wanna do is drag off this and I'm
going to bring in a spawn actor from class node. And the class I'm going to spawn in the first time I press the left mouse button
is going to be my blueprint effect fire. Now you can find
this if you have these starter content folders
and you can navigate to where this is by clicking right here. That'll
jump you to wear. This exists within
your content browser. Honestly, you can spawn
anything you want in here. I'm essentially going to be spawning in some
fire and then some sparks down here to simulate
me casting a spell. So I'm going to Control C, control V. So the second time we press
our left mouse button, instead of fire, I'm going
to spawn in sums, barks. Blueprint effect sparks. Now I do need to give this a spawn transform so I can drag backwards off
of either of these. And I will say make transform. Now the only reason
I want to use this make transform is just a scaled down the effects
of each of these. I'm just going to make
this be half the size of 0.5 in the x, the y, and the z. We're actually going to attach these spawned effects to our
mesh here in a little bit. But this will scale down the size of each of these
half size for each of those. Then what I wanna do is I
actually want to store what we spawn here inside
of a variable. And the reason we're
going to want to store these different effects is
because when we spawn one, we're going to kill
off the other. So that is our idea here
behind the flip-flops. So I'm going to
right-click on this pin. I'm going to promote
the variable. And I'm gonna give this a
name of equipped spell 01. So I've promoted that to
a variable down here. And then on this guy I'm
going to right-click on this, promote that to a
variable and I'll call this equipped spell 02. And I entered in
that name right down there in case you missed that. Now off of each of these, I'm going to drag off
and type in attach. I'm looking for attach
actor, two components. Attach actor to component. That's the one
we're looking for. Now, the target here is going
to be our equipped spell. The parent that
we want to attach this to is going to be our mesh. So if we go to our viewport, our mesh is this
mannequin right here. So that's gonna be
our mesh, the actor. We want to attach our
spell effect here to our mesh and we can
feed this a socket name. Now back in our name
variable video, we created a socket
on our skeleton, on our mesh here. And we created a name to socket. Now we did store
this to a variable. Our socket name that
we created in our name variable video was
called hand socket. So I'm just going to
drag and drop this, plug this right into here. Now if you did not go through
this name variable video, this will not work
for you because you need to set up a socket first. I would suggest you go back to that name variable video
in order to do that, in order for this
to work properly. Now I do need to change
my location role here to be snapped to target. The rotation rule
to be snapped to target as well in order
for this to work, alright, then I'm going
to simply copy this. Copy all three of
these nodes control C, control V. We're going to paste
these down here, like so. And we gotta make sure
we hook this in like so. So that's our current setup. So if you need to
pause the video here to see what
we currently have, but we're not quite
finished yet. We then want to do is pull
off of this guy in Troy. Actor. Now which actor do
we want to destroy? Well, when we're
spawning effect fire, we're going to want to destroy
our sparks effect and vice versa so that we only have one of these bonding at a time. Now, to do this, I'm going to drag in equipped spell O2,
plug it into there. This is the one that
we just promoted to a variable down here,
and vice versa. I'm going to Control
C, Control V with this Destroy
Actor right here. Like so. And we want to plug in equipped
Spell Number one to this. Now I know that when
we run this in a game, we're going to get an
error right up here, but I'm going to let
this error happened just so you can see how we
fix that in just a bit. Now, this is R script
that we've got going on. We're gonna be making use
of our flip-flop node. Let's compile this to make sure that this is
all looking good. We're going to save this. So just to run through this, we're going to left mouse click the first time we're going to execute out of the a output. So this bit of script
is going to run. We're going to spawn
in the effect fire. We're going to save that affect fire inside
of a variable. We're going to attach
it to our mesh at the socket name
that we provided. Then we're going to
destroy actor to. Now the first time we do this, this is going to throw an
error when we exotic here because we have not
spawned in effect to yet. So that's why it'll
throw an error. The second time we press
the left mouse button, we're gonna shoot out of the B output of the flip-flop node. It's going to spawn in
the effect of our sparks. We're going to save
that to variable. We're going to attach it to our mesh at this
given socket name. And in doing so, it is also going to
simultaneously kill out this effect right
here, our fire effect. Now the next time we press
our left mouse button, the third time we'll spawn
in this viral effect. And we will be killing out sparks the second
time we come to this, it won't throw an
error because we will have created this
variable right here. Alright, let's go ahead
and give us a play. We'll try to tuck this
into the upper corner. Clicking play. Let me set my debug. Object to our
ThirdPersonCharacter. Oh, here we go. I'm going to run
around over here. So I'm going to
left mouse button. Watch this flow of
execution as I do this. Here we go, left mouse button. You see that affect
fire is bond in here. It's attaching it to
my character, like so. I'm going to press the
left mouse button again. It killed out the fire. The sparks is in there. And press the left
mouse button again. We've killed off the sparks. We now have fire. Now I'm going to
exit out of here. Here's that error that I
was just talking about. It is complaining
once again that we can't destroy this
actor right up here. At the least the first time we couldn't destroy it out when we spawned in our fire effect because there was
nothing to destroy. This did not exist yet because we shot through the
a output first. Without having shot
through the b, we had not created
this variable yet. So how do you solve
this kind of issue? Well, it's actually
quite simple. If we right-click on our
equipped Spell, No, right here. And we convert it
to a validated yet. It'll convert the node
to look like this. And if we wire it
through like this, we can say only
if this is valid, meaning only if this variable
has something inside of it, will we destroy the actor. If it's not valid meaning
there's nothing inside of it, then there's nothing to destroy, so nothing will happen. So that's how you
can get around that. So compiling, saving,
playing, left-click, fire, left-click sparks
were flip-flopping a, b, a, b now and we escaped. We no longer get that error. So that is an example
of the flip-flop node. What are some possible
uses of this? Well, you could use a flip-flop node to swap
between two weapons. Maybe you use a
flip-flop node to toggle the light
switch on and off. Those are some example use
cases. What are the ones? Can you come up with? Guys that'll do to
offer this one? See you in the next one.
81. Gate: Welcome. In this video, our
goal is to gain knowledge and demonstrate
use of the gate node. Now this is an extremely
self-descriptive node in that you can enter
into the gate node. But whether or not
you flow out of the execution output pin
and do whatever comes after this depends on whether or not
the gate is open or close. It starts off close here
with your gate node. Now, to bring one of these
nodes into your graph, you can right-click
and search for gate. Also, you can hold down the
G key and left mouse click, and that'll bring in a
gain node for you as well. I've got an example that
I'd like to demonstrate for you all here inside
of your Level Blueprint. So if you'd like to play along, that is where to head. What we're gonna do
here is start off with an event ticks. I'm just going to
right-click and do a search for event tick. And we're going to flow
into our gate every tick. So every frame we're going
to be flowing into our game. Now we're not going to be going beyond this until
our gate is open. Remember our gate is
starting close here. So even though we're
flowing into this node, every tick, every frame, we're not going
to be flowing out beyond here and doing
whatever it is to come next until
we open our gate. So how are we going to
open and close our gate? Well, we're gonna do this via a trigger volume inner level. So head back to your level. And we're going to
come right under here. I'm going to come under basic. We'll add a trigger box, just left-click and drag
one of those out here. I'm just going to size
it up here quickly. Let's go 150 by one fifty, four fifty, one fifty, one fifty, one fifty. I don't know. It's the first number
that came from our minds. Something big, line thickness, we're going to change
that to tend to make this a little bit easier to see. However, we're not going
to see it unless we come under the
rendering section. Rendering section and we
uncheck actor hidden game. I'm going to lift
this up, hit the End key to smack it on
down to the floor. We're going to check to see
if we have overlap this. So with this selected, we're going to go back
to our Level Blueprint. If you don't already have that open, open Level Blueprint. And we are going to right-click
in some empty space. And we're going to add an
event for that trigger of volume under the collision
when we begin overlapping it, as well as right-click collision when we end overlapping it. So we want to do something
only when it is us, the ThirdPersonCharacter
overlapping the trigger volume. Another way we can check
to see if it is us. I could drag out
of here and cast. However, I'm just going to
show off a different method. I'm just going to type
in get player character. Now, if I drag out of
our other actor and simply type in the
equals operator, we can check to see if it is the player character
that is overlapping us. Now we don't need
to grab inside of our ThirdPersonCharacter
and execute any functions are calling the variables
anything like that. We just need to check if
it is our generic player. We don't really care
which player character, any player character. In this case, for
ThirdPersonCharacter is the one that we
are controlling. So this is good enough, can hold down the
Alt key left-click. That'll be our
condition right here. We're going to copy these
nodes right up here, control C, control V. Bring them right here. Like so. So if it is true that we are overlapping
that trigger box, if that's true, we're
going to open the gates. Now, if we have ended overlapping the Trigger box
with our player character, that is proven to
be the other actor that is ended that overlap. If that's true, then we are
going to close the gate. Now. That is all well and good, but what are we going to
do upon opening the gates? Well, we're going to add another
actor to our level here. So why don't you
hit on back there. And we're going to add a door of sorts right here a little
bit beyond our Trigger box. So to add a quote, unquote door, I'm going
to come right under here. We're going to
come under shapes. We're going to add a cube. And I'm just going to
stretch it out a little bit. So hitting the R key, I'm going to scale it like so. I'm not going to
be super precise. We're going to lift
it up into the air, something like that. Maybe thin it out a
little bit like that. I'm going to hit the End key to smack it on down to the ground. And with this selected, I am also going to
need to come over to the Details panel and change the mobility of
this two movable. Now the reason I'm going
to need to change this to movable is because I am going to be slowly moving this out of the way in the next
portion of our script. Okay, so with that done, we've got our cube
here selected. Make sure you've
got that selected. Head on back to your
Level Blueprint. You can access it there as well. If you don't already
have that tab open, hold down the R key, left-click to bring
in a reference. And then we're going to
pull out of this and type in static mesh components. So our static mesh actor consists of a static
mesh component. And to help drive
home that point, if I go back to my level
and select my cube, we can see that R cubed consists of a static mesh component, which is essentially
this cube right here. But we need to do that in order to drag out of this and bring in the ad relative
location node. Now at this node does, you can see our static
mesh component of the cube is hooked
up to the target. It's looking for a
component object reference. This is what we are going to be flowing into once
our gate is open. Now this Delta location
allows us to change the location of this
scene component, of this Static Mesh component. But only once the gate is open. Now I'm going to change
this by changing our z location to add one. So we're gonna be adding one to our z location every frame, because we're gonna
be flowing into this every frame once
our gate is open. So just to review, every tick, every frame we're going to
be flowing into this gate. However, right here, this checkbox says We
are starting close. We're not going to be passing
beyond here in changing the relative location
of our cube. However, once we
begin overlapping a Trigger box with
our player character, our player character
is deemed to be equal to the other actor. It is the other actor
that's overlapping us. That is true. Then we're going to
open the gate and then we're gonna be moving
that up into the air. However, when we end overlapping that trigger volume with our player character, when that is true, we're
going to close the gates. Let's talk this
up, right up here. I'm gonna click Play. If you've not set
your debug object, you can click right
up here and set it so that you can see that
flow of execution going. Let me just, There we go. Stop shown there just briefly. Alright, now I'm going to try to frame that up
a little bit better. Bring on my character
once again. Alright, so you see
event tick were flowing into this gate every
frame, however, we are not getting beyond
here now watch what happens when I overlap
this with my character. You're going to see this
open, the gate. Here we go. I can see it's lifting
up into the air. And if I end my overlap, it's going to stop lifting it up into the air, begin overlap. It's going to open the gate
and continue lifting it up and overlap, et cetera. Now another quick example, use case of the gate
node using much of the same setup that we
already have in place. I just swapped out a
couple of notes here. Here we are casting to our ThirdPersonCharacter
both Ana begin overlap and end overlap. And the reason I
wanted to go with this approach is so
that we can drag out of our ThirdPersonCharacter
and call this modify health
function that we created when we talked
about functions. Now what we're
gonna be doing with this setup is making it so that when our character is
overlapping this Trigger box, we're going to be decrementing our character's health while
they are inside of it. Once they step outside
of that trigger box, we're going to stop that
bleeding, so to speak. So you can imagine
this being like a poisonous gas
chamber or maybe, you know, maybe you're crossing a fire pits,
something like that. So here we go. You can see this at work. I recommend if
you're going to do this, every tick though, you would set your decrementing of health to a very low value. You're actually going
to see this represented in our health bar
up here because we do have our health bound to this meter on or HUD as well. So here we go, overlapping this. I know the sound is very spammy right now, but
you get the point. Stepping out of this
poisonous gas area, the bleeding stops. And so there you have it. The gate node, it takes
in execution paths. But whether or not you go
beyond this and do whatever comes beyond this execution out pin depends on
whether or not, if the gate is open or close that we'll do to
offer this one guys. See you in the next one.
82. MultiGate: Welcome. We're gonna be talking about the multi gate node
here in this video. And I think the best way to demonstrate what this
does is to just go ahead and put
together an example as opposed to talking about it. So I'm going to be
putting together this example here in
my Level Blueprint. If you'd like to play along, if you forgot how to get
in your Level Blueprint, you can come right here,
open Level Blueprint. And to add a multi-grade node, you can simply right-click
and search for it or hold down the M key, left mouse button, that'll
add one there as well. Now this first example is a
little academic in nature. So I went ahead and set up the script ahead of time
to save us some time, but I'll explain
what is happening. So I brought in 34 input keys
to help facilitate this. I've got a pressing
of the three key flowing into my
multi-grade node. On the output side of things, I added one extra pin. And each of these
is hooked up to a corresponding print
texts function node. And it's simply
going to print out 012 respectively to
correspond with output 012. Now, when I press the three key and we flow into
this multi-grade node, the first time I
press that three key, it's going to output
this output 0. It's going to output the
number 0 to the screen. This is determined
by our start index. A start index defaulting
to negative one essentially means start at
the top of our list here. However, unlike a
sequence node that would print all of these out
in rapid succession, It's only going to print
out this number 0. It is not going to
print out one or two. Now if I press the three
key a second time, it will flow into
the multi gate node and then print the number one. It'll pick this 1 first. We did this with the
first a key press. The second time you press it, it will flow here. The third time you press it, it will flow here, et cetera. The fourth time I press it, nothing is going to
happen until I reset. So here we go. That's a quick breakdown
as to how this node works. I'm going to click Play up here, going to set my debug object
to be our level test maps. So you can see this all
flowing in the graph as well. So here we go. I'm going
to press the three key. We see the number 0
just flows there. I'm going to press the
three key a second time. We see number one. I'm going to press
it a third time. We see number two. Now if I press it a fourth time, we're flowing into this. However, we are not
flowing out and we won't flow out
until we reset. So essentially when you flow
into the multi-grade node, it will make sure that all of
these outputs are executed. Once all of them have
been executed out, then you must Reset it in
order for this to work again. So if I press the F4 key, which I'll do right
now, just reset it. Now I can press
the three key, 0. Press the three key again. One, press three key again to. And if I try pressing
the three key again, I'm flowing into it,
but I cannot flow out of it until I reset it. And which points I
can do it again, 012. Now, let's try that
again only this time. Let's check. This is random checkbox. Before this was not checked with a start index
of negative one. We were going to
fire out of our top. I'll put pin, then our second, then our third in
sequential order, guaranteed with is
random selected. However, we are going
to fire through all three before
we need to reset. However, it's going to pick a random index with which to
fire out of the first time, the second time,
than the third time. Here we go. So pressing the three key decided to go with that 1 first, that 1 second, that 1 third. If I press it a
fourth time, nothing. Got to press F4 key to reset it. And then there we
started down here first, that 1 second, that 1 third. So that's what the is random
Boolean checkbox does. Now, if loop is
checked and I play, and I'm going to press the
three key here once, twice, a third time, then
a fourth time, five times, six times. Essentially when you
have a loop check here, you can keep pressing,
in our case, the three key again
and again and again. There's no need to reset. Lastly, just to show off to our start index by default
that's set to negative one. I'm just going to
uncheck each of these. Let's set that to say two, not negative 22,
and I click Play. Now when I press the three key, we fire out of the
two pin first, then 0, then one, or press the three
key again, nothing. However, if I reset, then press the three key, it's going to fire out of
2 first than 0, than one. So once again, admittedly, a fairly academic example. So let's try something a little
bit more true to a game. And I'm going to
demonstrate this here in the Level Blueprint as well. Let's come over to
the right here, or any open space
here in your graph. Once again, I've set up
some stuff ahead of time. I have a multi-day node. Hold down and left-click, he can bring one of those in. And out of each of my
three output pins, I did add one here. I brought in spawn
actor from class nodes, and I simply slotted in three different classes
my blueprint effect, explosion, fire, and smoke. And now I need something to
fire off this multi-day. Let me go back to my level
here and I'm going to add right up here basic. Let's do a Trigger box. Raise this up a little bit, set our boxes extent
to be something like two hundred two
hundred two hundred line thickness of ten. I should really leave a Trigger
box out here for all of the different examples
like this and showing off under the
rendering category, uncheck that actor
hidden in game, alright, with his
events selected. Here in our Level, Blueprints. Level Blueprint, hold down or rather a right-click,
not hold down, right-click Add Event collision for when we begin
overlapping that, we can check to see
that our other actor, we can say equals. This is another way
of showing to see if the thing that we're
hoping to overlap, this is a thing that
we're expecting will say, is that equal to r
gets player character. We're not looking to
extract any variables are calling functions within
our ThirdPersonCharacter. So this will be good enough. Holding down the Alt
key and left clicking. We'll say if that is true, will flow into the branch node, one flow control node. And if this is true,
we will flow into the multi-bit gates node. And if that is true, we will spawn one
of these compile. Oh yes, we need to specify
a spawn transform. Well, we have our Trigger box already selected back
here in our level. So let's just spawn. It's somewhere in that
trigger box right? Holding down the Alt key, left-click to bring
in a reference storage trigger box dragged out of here, gets transform. We can plug these in 123, so we're picking
one of these spawn at random, compile once more. Let's go ahead and play. I'll tuck this right
down over here. We have our test maps selected, wrote up there as
our debug object. And here we go. The first time we overlap
it were picking one of these random explosion
the second time fire, and the third time, we've got some smoke going
on in there as well. Now note, if I
overlap this again, we stopped right
here at the gate. We have not reset this at all. So that would be something
that maybe you wanna do to allow some spawning. Once again. Now setup such as this can be used for
like a loot drop. Perhaps you kill an enemy and you want to award
a random thing, that would be a good example. Use of the multi game. Perhaps you use a multi-grade
to spawn waves of enemies. So you could choose a wave
of enemy out of our zeros, out one or two. Or perhaps you could
use a multi-grade node when talking to an NPC. Once again, many games have
it so you can talk to an MPC, and in your MPC, wolves feed up three different
unique lines of dialogue. You can make it so that using
a multi-grade node when you overlap that trigger volume
related to that NPC, you can fire off trigger line of dialogue 12 or
three respectively. Guys, that is going to do it
all for the multiset node. We will see you in the next one.
83. For Loops: Welcome. In this video, our goal is to gain
knowledge and demonstrate the use of the for-loop nodes. Not to be confused with
the for each loop nodes, which we will be talking
about in the next video. Now these nodes will repeat a section of script
again and again. And while they can be used
inside of event grass, they really shine when scripting procedural content using
the construction script. Now to start with,
what is a for-loop? Well, a for-loop is a
node that when called, meaning it has an execution wire being plugged into the
left-hand side here. It fires a pulse
out of the loop, body X number of times, with the number of
times being determined by the first and last indices. So for example, if
we had some event plugged into our
for loop node here, and our first index was 0. In our last index was nine, we would flow out of our
loop body here ten times, starting from 0 to nine. Now every time we would
flow out of our loop body, we would be spitting
out which index between 09 we are at. Again, from 0 to nine,
you'd go 0123456789. So when we were at the
fifth iteration through, we would be spitting
out index for, again, starting from number 0. Now once it has gone
through all ten, this completed execution
output wire would fire off. Now the only difference between our for loop node here
in our for loop with bread node is simply this
break input execution pen. You have the ability with this
node to break the flow of execution before you get
to your last indices. If, for example,
your first index is 0 and your last index is 99, meaning 100 loops through here. You could for whatever reason, break it early so you don't
actually complete it. And we'll show a
demonstration of that later on in this video. Alright, now, as I mentioned
at the outset of this video, you can use these nodes
here in an event graph, but they really show off their power within a
Construction Script, building out procedural content. And in fact, at the very
beginning of this course, when I was talking about
the construction script, I did make use of
a for-loop node. So let me just
bring that back up, going back to my test map here, I actually have In example
Construction Script blueprint. This is the blueprint
that I built out way earlier in the course when talking about the
construction script. I've got one of
these in my level, but if you don't, you can find it in your scripting
Blueprints folder. There is your BP example
Construction Script. Also. You can navigate to it
here in your Outliner by selecting it and your world
and clicking right here. Now, I have nothing here in this blueprint
in my Event Graph, my viewport shows off what the Construction
Script has built. So here's my
Construction Script tab. If you don't have this open, you can double-click
on this down in the My Blueprint
panel to open it up. And here is where we are
making use of a for loop node. Now this whole script
right here has been built to generate
procedural content. I expose this numbers of section integer
variable to the editor. And so by adjusting the
number of sections, we can loop through this
for-loop node X number of times going from 0 to r
number of sections minus one. And this is just doing some math to determine where to place instance static mesh of
this wall piece right here. Now I've got a little bit
of additional scripts going on here to set the
material for this instance, static mesh, but that's what this entire construction
script is doing. So the power of this, again with the for-loop, is you get to specify how many times you are going to loop through the rest of
this code right here. And in this case, we're going from an
indices of 0 to however many numbers of
sections I specify. Here in my level, I expose this variable
to be instance editable, that checkbox right there. And in doing so, that variable becomes
available within the Details panel when I have
this blueprint selected. So you can see if I adjust
the numbers of sections here, I can expand out this wall. What this is doing. Once again, it is
looping through here. How many times? Well, I've currently
got this set to be twenty one. Twenty one. Twenty one minus one is 20. So from 0 to 20, that is looping
through here all those times to add these
sections of walls. So that's the loop
body is doing, doing repeating this
section of script, however many times going from the first index to
the last index. Now, it is worth
noting here that loop iterations will take
place between frames, so large loops may incur
a performance hit. So if we were to set our last index here
to be quite high, we will see a little bit of lag. So I'm going to try to set
this to a high number here. In my level. I've currently got it set
to 21, which isn't too bad. If I try setting this to 500 thousand and hit
Enter, watch what happens. And indeed, that did
take quite a long time. Now, I cut the video right there to make it seem like
it took a lot less time, but that probably
took my computer about a minute to actually show all those
sections of walls. So just know that you
probably don't want to have too many loops through
your for-loop node. Alright, let's show off
a practical use case for the for loop. Note here in our level, I'm going to add a trigger box and I am going to set the box extends to be
something a little bit bigger. We'll go 300 in the x, 300 in the y, and 40 is going to
be fine for the Z. I'm just going to pick it up off the ground a little bit,
something like that. Let me set the line
thickness to be ten. And just like you've seen me do a bunch of
times up until now, I'm going to uncheck actor hidden and games so
that we can see it. Then I'm going to
duplicate this, holding down the Alt key,
left-click and drag. And I'm going to set the box
extent down for this one, we'll make it 100 by 100 by 100, something a little bit
smaller like that, picking it up into the air, hitting the End key to smack
it on down to the ground. So what am I trying to
achieve with this setup? Well, essentially what I'm
going to make happen here. Our character is going to spawn right here at our player start. We're going to make
it so that when our character overlaps
this Trigger box, we're going to spawn some
manner potions within the bounds of this
volume right here? Yes, you can use a Trigger box it trigger volume to
spawn things within. That's what we're
going to use for that. And we're also going
to utilize a for loop node to spawn
three Amanda potions. So first things first, we're going to select this
Trigger box right here. Go back to your Level Blueprint. And we're going to right-click
and some empty space. We're going to add an events for when we begin overlapping that. And we will just drag out
of our other actor here, type in the equal sign. And this will be our method for checking to see if it is
our player character. We're going to right-click
get player character. Again, there's all
different kinds of methods that we could use for this section to check if it
is our ThirdPersonCharacter. This will work fine. Holding down the key left
clicking to bring in a branch. Like so. Next I'm going to
hold down the O key and left-click because we want
to do something one time. What do we want to have happen? Well, we want to drag out of here and bring in a for loop, not a for each loop, a for-loop. We'll set our first index to 0, our last index to two. So 012 will be our
three indices. And we'll drag out of
our loop body and we will spawn actor from class. And here's where I'm going
to slot in our man a potion. Again, you can slot
in anything here that is some kind of a blueprint
object, I would recommend. Now, where am I going
to spawn this thing? I need to speed this
a spawn transform. So let's go back to our level. We're going to select
this trigger volume here. Then we're going to jump
back to our Level Blueprint, hold down the archae
are as in reference and left-click to bring in a reference to
that trigger box. We're going to drag out of here. Get actor bounds is the node
that we're looking for. Then we're going to drag out of the origin here and type in random a point in
a bounding box. That's the box extent. We can plug that
into the half size. And last but not least, we're going to drag backwards
off the spawn transform, where we're going to
type in make transform. The only aspect of the
transform we're going to care about for this is the location. So take the location of
our bounding box right here and plug that into the location of
the make transform. So let's recap very quickly
here what we've got going on. We are going to overlap
this trigger volume. We're going to
check to see if it was the player character that did the overlapping if
it was, and that's true. One time, we're going to loop through this three
times, starting at 0012. So bam, bam, bam, spawning three manna
potions within the bounds of this trigger
volume. Let's compile. That's going to check to
see if our script is good. Save. Let's tuck this script right up here and let's go
ahead and play. And you see my two
volumes there. Let's overlap this
first one here. 123. There we go. Now if I try
overlapping and again, no dice, no dice, you can see it's just
stopping at the do once node. Now you may be asking why did this emancipation spawn
above right here? Well, we are getting
our actor bounds for this Trigger box right here, but we are picking a
random point within the bounding box by
specifying an origin, the center of this. And the random point
that we're truly picking is the half size
of our box extent. So truly you can
actually go outside of the bounds of this
so long story short, this is just a quick
example to show off the for loop node at work. So let me just quit out of here. To finish off, we're going
to demonstrate the for loop with bread node inside of
our ThirdPersonCharacter. So here's a directory
to find that. Double-click on
it to open it up. And we're going to bring
in a keyboard events. Let's right-click and some
empty space type in keyboard. Bring in any keyboard event
that you haven't used yet. I'll go with the E key, shore y-naught, and he will do. What we're gonna do is
drag off of this and bringing a for loop. A for-loop with break, not for each loop that's
going to come later. Next video. And we're going to have the first
index left alone at 0, the last index, however, I am going to put
in the number 30. Then I'm going to right-click on this pin and I'm going to promote that to a variable
just to show off, once again as a reminder, that if you put it in a number, then promotes a variable, you're going to not
only create a variable, but if you compile, you will see that
that number that you had hard set in there is now set as the default value for that promoted variable. Pretty handy. Now I'm going
to rename this variable. I'm going to hit F2 on
this and I'm going to call this inventory items max. So what are we doing here? We're going to go through a
hypothetical scenario whereby your ThirdPersonCharacter
can hold 30 inventory items. But let's just say on
the characters UI, they can only display 15
items on a single page. So in this case, we're going to stop our for-loop with break when we
find we have gone, we've gone through
this 15 times. So essentially we're
gonna be going from 01234567891011121314. That would be 15 times total. And we're going to
break our For Loop. So what do we got to do next? We got to drag out
of our index here. And we're going to bring
in an equal symbol. And we are going to see if
our index is equal to 14. Why 14? If we're wanting to truly break it
after we've gotten to 15 items because remember our first index is counting 0. So with that set in there, I'm going to promote
this to a variable. Right-click promotes variable. We can compile that. Now that is our new
value in there. However, let's name this
something better than that. So I'm going to
rename it over here. Let's call that
page one items max. And what we're gonna do next is dragged out of here and
bring in a branch node. In between this, I'm going to sneak in
a Print String nodes. So every time we're
looping through, we're going to print out. So print string, which
index we are on. So drag and drop that in there. It'll bring any conversion
integer to string. Plug this into our branch. And what we wanna do
here is if this is true, our page one items are
equal to our indices of 14. Let's compile that again, 14. If this is true, we're going to whip back around here and we're going to break. Double-click on this to
add some reroute nose to make that look a
little bit nicer. Once we have broken,
we've completed. I'm going to drag off of here, bringing in another
print string node. And we're simply going to
print out to the screen. Each one of your inventory is full or something like that. And let's print this out to the screen a
little bit longer. So I click that down arrow
right there to expose some more parameters here we'll set that to
a duration of ten. So that's what we've
got going on here. Again, we're not
actually printing anything out to the screen. We're not printing
any inventory items, isn't just all hypothetical. Compile this. Save. And let's go ahead
and place that are debug option to be our
ThirdPersonCharacter. So you can see this
script firing off. And this is all going to
happen very, very fast. So look up here in the upper
left as I tap the E key, page, one of your
inventory is false. So you saw all those indices, 012345678910 to 14 until it says page one of
your inventory is full. You can see from
this example here is we never got to our last index. We were supposed to
go all the way up to 30 inventory items. Well, truly 31 if
you're counting that 0. But we broke our loop here. We did not get through
the loop that many times we broke when we hit 14. So that's an example of a
for-loop with break node. Once again, these nodes are
great when using them with inner construction
script to create something like procedural
walls like this, but they can also be used
in event graphs as well. Now one final thing
to note here back in our construction
script that I created way earlier in the course when I created this script
using a for-loop node, oftentimes when using
for-loop knows the indices is used in some sort
of a math calculation. So that's something to
keep in mind as well. So for every time we're
looping through this, I was using that index number, multiplying it by another
number to figure out where exactly to place this instance, Static Mesh, this wall piece. Alright guys, that is gonna
do to offer this one, we will see you all
in the next video.
84. For Each Loops: Welcome. In this video, our goal
is to gain knowledge and demonstrate use of the
for each loop nodes, the close cousin of the for-loop nodes that we
covered in the last video. So what makes a for each loop node different than
the for-loop nodes? Well, they're flow control
nodes that take in an array as opposed to
any number of indices. Thusly, by taking in an array, they allow you to
do something to each array element that is
the contents of the array. Now, if you go back to our array video from
earlier in the course, you will remember that an
array is essentially a list. It is a container consisting of multiple elements that has entries of the same
variable type. Alright, to show off
in example here we will be doing some work inside
of our level blueprint. But first, we're gonna be doing some work in side of our level. Now, I am going to use this SM lamp wall within my
star content Props folder. Although really you
can use any sort of static mesh to create what
we're about to create. I've got a simple wall here. So if you want to
place a wall of sorts in your level
to play along, that might be good
to do as well. Because what I'm gonna
do is I'm going to place this wall Scott's along this wall that
I've got going on here. And I'm going to show
off something else that you can do here in Unreal, right up here within
your viewport, this three arrow icon, you can turn on surface snapping.
I currently have it on. That's what that
check mark means. But if you don't
know if you have it on or off, you can
click right here. I do have it on. The reason I have that on
is to show that off that if I drag and drop
this into my level, it'll snap it to whatever surface that I
am dragging it across. You can see it's sliding along the floor as well as placing
along the wall like that. Now, if I was to release it
and left-click and drag, It's not going to slide it
along the floor like this. However, if I grab it by the
three cornered point there, the translation widget
that ball right there. If I left-click and
grab it from there, then it will snap
it to the surface. Now, I'm going to drag
it along my wall here. Of course it's not exactly
positioned like I want. I am going to have to
rotate this particular one. So hitting the space bar, I'm going to rotate
it like this. Rotate it like this, and rotate it like that
to get it along the wall. Going to increase it in size
here a little bit as well. And I'm going to bring out
a couple of duplicates. So holding down the Alt key, I'm going to
left-click and drag, holding down the Alt key
again, left-click and drag. Alright, I've got three
of those in my level. Great. I'm going to select all three of them here in my outliner. I'm going to select the first
one, hold down Control, select the other two as well. So I've got all three
of those selected. And then back in
my Level Blueprint coming right here,
open Level Blueprint. I'm going to shimmy on down here and I'm
going to right-click. No, I'm not going
to right-click. I could right-click and create a reference to each of
those individually. If I had them individually
selected, however, I'm gonna hold down the
R key and left-click to bring in a reference to all
three of those right away. They're stacked on
top of each other. Unfortunately. Then what I'm gonna do is
I am going to drag out of one of them and
type in make array. So we're going to add
pins to our array here. And we're going to
plug each of these three into our make
array note here. Now this can output an array. What I'm gonna do is
I'm going to simply right-click on this and
promote this to a variable. Although note, however,
I don't have to do this. I'm gonna be using this
array of lamps here, 123 to plug this
into a for each new, for each loop node, this would work just fine
for the purposes of that. However, just to show off that I can promote this to
a variable, I will. So I'm going to right-click
promote two-variable, and I will call
this my lamp array. Now this immediately sets it
to the proper variable type. Ended immediately. It
makes it an eraser. That's kind of handy. And what I'm gonna do here is after I set these
into an array, I'm going to plug this into an execution pin of my
for each loop node, you can use the hotkey
of holding down the F key and left mouse button to bring in
a for each loop node. We're going to plug
this into our array. Now we need an events
to fire this all off. I have in my level a trigger
volume already placed down. If you don't have one of these, you can come right under here. Come under basic Trigger box, place one of those
in your level. I've got my box extents set
to one hundred, one hundred, one hundred by line thickness set to tend to make
it easy to see. And I've got actor hidden
in game unchecked. Now with that selected
in your level, back in your level
blueprint, right-click. We're going to add
an event for when we begin overlapping this. And we do want to make sure that we checked if it is our
third-person character. So let's drag out of here
Cast to ThirdPersonCharacter. And if it is, and we have set our
array variable again, this portion right here
isn't super necessary. We're going to do something for each element in this array. Now what do I want to do
with each item in our array? All three of these, well, what I wanna do is drag out
of our array element and I'm going to type in
yet actor location. We're going to use the
location of each of these walls to spawn an emitter. So I'm going to right-click in some empty space
and I'm gonna do spawn emitter at location. I will plug in the accurate location to the
location input of our spawn, a minaret location,
our loop body, we will plug into
this function node. The emitter here
I'm going to use is simply fire my P fire. This is an older
particle system. Again, you can put in an older particle
system or you could do spawn system at location that is using Niagara
sparkle effects, spawn the system at location
is the equivalent there. This will work as is however, just for completeness sake. Off of this completed
output pin, I'm going to print string. And I will simply
put in the string. Done. So we'll print that
out to the screen. And what I think
I'll also do as well is let's sneak in another
print string right up here, control C, control
V. We're going to sneak this end before
our loop body. We could put it after our
emitter if we wanted to. So we're gonna go like this. And for each item
in our array here, we're going to print out
the array index just so you can see that number being printed out to the
screen as well. So let's recap what we've got. Once our character overlaps
that trigger volume, we're going to see if it was in fact our
ThirdPersonCharacter. What we're then
going to do is use these three lamps
and make an array. So we're going to have an array, a list of static mesh
actors here that are going to populate that variable. We're then going to, for
each loop in our array, for each item in our array, we are going to get
the actors location and spawn some fire. Let's compile this makes your R script is
looking good to go. Let's jump in and play. Setting our debug object
to our test map here. Alright, so here we go. Once we overlapped this, we should see fire appearing
here, here, and here. It's as if we lit three torches. Now, this is spawning at
the location of our lab. It's not low. If we look at our lamp, the translation widget
is at the base of it. So that's why this flame is showing a little
bit down here. However, we could offset this a little bit and make
it appear up top, but you get the points. You can see, I'm not
doing this one time. So if I keep overlapping this, you're going to see this text being printed out to the screen. And I'm keeping a spawning more particle effects
here as well. But you can imagine a setup like this used to light the lamp. One more example to show off
here in our Level Blueprint. This time we're going
to be using the for each loop with break node. I've gone ahead and
created an array of texts. So if you want to play along, click that plus button. We turned this into the
variable type of texts, and we change the container
type to be an array. And then I clicked
here three times two, you add three array elements
made warrior and thief. Now something to note
with each of our four, each loop nodes is you have
some gray pins on here. Now, these indicate wildcards, meaning we can plug in a variety
of variable types to it. And it'll recognize what
type we plug into it and change the corresponding
type to be the same. Let me show you what I mean. I've got an array of
texts right here. If I plug this into our gray
array input right here, it's going to
recognize that Hey, you're plugging in an
array of texts variables. That means we're going
to be outputting texts because your array consists
of three texts made. Warrior and thief,
three array elements. Alright, what are we gonna
do with this setup here? Well, we're going to see if our array element is equal
to some literal texts. Let's right-click it
some empty space. Bring in an equal
node operator, equal. Going to plug in our
array elements into this. Actually that's the wrong one. My bad. We're going to
firstly bringing the make literal text node, make literal text node. That's the one I'm looking
for right down there. Out of this, I'm going to drag out and bring in
the equals sign. We're looking for text
equal exactly texts. That's the one we're looking
for, NOT operators equal. There we go. I'm gonna hold down
the Control key, left-click and just put
this into the bottom one. In our array element is going
to plug into the top one. Our literal texture
that we're going to be searching for is warrior. Note. We have Warrior listed here as well as in our texts array. So when that is equal, we're going to drag
out of here and bringing the branch node. And we are going to
drag out of our true. I realized that there is a
missing link right here. I'll get back to that
in just a little bit. Dragged out of here to
type in print text. And we're just going to
print out found warrior. And what we're gonna
do with this is drag and drop this all the way around into our break input, going to double-click on the
wire a couple of times here. Now, the reason I left a little gap here is
because I also want to inputs a prince text
node right here. So I'm going to flow like this out of our loop body into their, into their, in our
array elements. We're going to flow into there. So understand what we've got
going on with this setup. We're going to press the B key. We're going to then
loop through our array. We have three elements
in our array. Each of these array
elements we're going to print out to the screen, starting with major,
then going to warrior. However, we're
going to note that right here we're going to
detect if these are equal. If they are equal and
that equals true. We're going to print out, hey, we've found the warrior
and then we're going to break our execution here, meaning because warrior is
our middle index right here, we should never even get too deep because that is
our last array entry. We're breaking it as
soon as we find warrior. Let's go ahead and
test that out here. Quickly compile, save, and play. Pressing the B key. There we go. It says major warrior, found warrior, we never
even get to thief. Now some possible for each loop node uses
for you to consider, perhaps you can use
one of these nodes to destroy an array of enemies, or maybe spawn in
array of items, like loot drop items upon
destroying those enemies. Maybe you use a for each loop node to check the
parameter of all objects in an array and then do something to those with
a given parameter. As an example, for
any enemies with less than 50% health
Yulen to fall. Just some examples
to get you thinking, alright guys, that's gonna
do to offer this one. See you in the next one.
85. While Loop: Welcome. The while loop node
is the focus of this video and we will be demonstrating
a use case here momentarily. First, how does it work? Well, you will plug in an execution wire on the
input side of the node. And it will repeatedly
execute out of the loop body on
the output side. So long as the Boolean
condition here is true. Now note you've got to be
careful with this node, as it is very easy
to get stuck in an infinite loop if
you're not careful. As a good rule of thumb, do not enter a while loop node unless the condition can near immediately switched to false. For example, if you're waiting
to have your character and overlapping a trigger volume to switch a condition to false, you're guaranteed to be
stuck in an infinite loop. You have to immediately have a means of setting your
condition to false. Alright, now, onto an example use case of the while loop node. Now I'm just going to
do a little bit of pre-set up here before we
get to some scripting, what I've done is any content
characters, meshes, folder. I've simply drag and drop the Imani Skeletal
Mesh into my level. Really any sort of skeletal
mesh with some collision, static mesh, we'll do a basic shape as long as
it has collision will do. We're going to do something
off on hit events. What we're essentially
trying to set up here is a scenario where Manny is going to be a thief and
he's going to steal some excess inventory items from our ThirdPersonCharacter. How devious in deed. Now next, you need to have your ThirdPersonCharacter
Blueprint open because inside of here,
double-click on that. We're going to add a
couple of variables. So under the My Blueprint
panel we're going to click Add variable. This first one is going to be
called inventory max items. And then I can right-click
on that, duplicate it. Control D is how you can
duplicate it as well. This one is going to
be called inventory. Current items that I need to compile in order to
add some default values. So I'm going to say
currently our character has 75 inventory items, weapons, shields, health
potions, all that kind of stuff. And they're really only
allowed to bank 50, that is the maximum
they're supposed to have. So underneath this
hypothetical scenario, I'm saying our
character is carrying more items than they
are allowed to have. But we're allowing them to actually carry
these excess items until they actually bank them
if they're caught, however, wandering the open world
and a thief comes along, they can steal any excess items that are character may have. Again, we're seeing that
the maximum allowed to quote unquote bank is 50. Currently they are
greedy and carrying 75. So a thickens steel
up to 25 of those. Alright, with that, I'm
going to compile this. We're going to jump
back to our level. Makes sure that you've got your Manny Skeletal
Mesh actor selected. And with that selected
head on over to your Level Blueprint,
open Level Blueprint. I've done a little bit of
pre-set up here ahead of time. But here's how you
can play along. Firstly, I'm doing an
actor hits four are many. Skeleton there, Skeletal Mesh. If you right-click at events, collision, add on actor hip, That's how you can
add that node. Then out of here you
can drag out and do a Cast to ThirdPersonCharacter
to find that node. Now, if it is our ThirdPersonCharacter
that hits our thief, their Manny, the thief. We are going to flow
into this and do once. What we're going to do once is iterate through
this while loop. So even though
this says do once, we're going to stay
in this while loop until the condition
here turns to false. Now we have to plug
in a condition. Well, our condition is going to evaluate our inventory items. So drag out of your
third-person character, type in inventory,
we're going to get our current inventory items. And remember, we've got 75
is our current inventory. So I'm going to click on
these three dots right here and put it in 75 just
as a reminder for ourselves. Then I'm going to
drag out, if you're again type in inventory, we're gonna get our max items
that were allowed to have. And I'm going to click these
three dots and put it in 50. And we're going to
compare these two. So dragging out of
my current items, I'm going to bring in
a greater than node. So if our current items are greater than r max
items is long, is this is true, we will continue flowing
out of our loop body here. Now, every time we flow
out of our loop body, I want to decrement
the amount of items in our current inventory. So I'm going to drag out of
here and type in decrements. Now this node takes in an input and it will automatically
decremented from here. So it'll go 75 decremented. This will actually set it
back to the current amount. So 75 minus 174, it'll automatically set
that as a new value. Then it will loop again, 73, et cetera, et
cetera, et cetera. So long as this
evaluates to true, as soon as this
evaluates to false, will stop that process. So I'm going to plug this into our print string
here so we can see these numbers printed out
to the screen like so. And lastly, out of the
completed execution pen, I'm going to bring in
another print string. And I will simply
print out excess in vain Tory items stolen, stolen by that their thief. So that is our script if you
want to play along at home. Now this is an
example use case of the while loop because I know, I know that this is going
to evaluate to false. I know that my current
inventory items will eventually
reach this limits. So let's compile this. Save. I'm going to tuck
this right up here. Clicking play, setting
my debug object to my maps so I can see
this script firing off. Here. We go, There is my thief. I've got my 75 items
that I'm a rolling around within the
level watch up here. Immediately, 7473
is over and it said excess inventory items removed, and it only did
that the one time. You can see if I try this again, it gets stuck up at
the do want snow. So that is an example. Use case of the while loop. Now, as for differences between the while loop and
for loops in general, you should use a for-loop
when you know how many times the loop should run. If you want the loop to
break on a condition other than the number
of times it should run. Maybe then consider
using a while loop. All right guys, that is
gonna do to offer this one. See you in the next one.
86. Switches: Welcome. We're going
to be covering a switch nodes in this video. And right out of the gates, you may notice that
switch nodes come in a variety of flavors here. And they don't have a gray banner along the top like the rest of
our flow control nodes. I'm considering these part of the flow control
category because essentially we are going to be controlling the
flow of our script. That is which one of these
execution pins we flow out of, depending on the data being
input into the switch node. Now switch nodes come
in several varieties. In fact, a whole lot
of varieties we're gonna be covering the
main varieties here. That is a switch on int, switch on string,
switch on name. And we'll also do a
switch on enumerator. You don't see switch
on enums out here because the name of a switch on enumeration will
vary depending on the enumeration
that you have created. This is what I created
earlier in the course, and this enumeration consists
of the three labels, super okay, and her badly. So if I was to
drag a wire out of this and type in switch, I could bring in a switch on them that is specific
to this enumeration. You can see my outputs,
there are super, okay, and hurt badly. Now, if you were
to right-click in any event graph and simply
type in the word switch. You can find a whole
host of switch nodes, most of which will never use. But it's good to point
out that they do exist. Once again, we'll be covering the main flavors and this one
and something that you'll notice his comment about all
of these switch nodes is they have one single
execution input pin, but they do have
different data inputs to them depending on the
type of switch node. Also, what is
common amongst them is that you can flow out of different outputs depending
on the data being input. So this is what a switch on int that is
short for Switch on integer node looks like when you first search for it and
add it to your graph. However, over on the
right-hand side, you see what this
node could look like if I add pins to it. So for all of these,
you can click this Plus button and
add more pins to it. By default, they start off
with a default output pin. You can actually customize
this with any of these nodes selected over
in the Details panel, you can choose whether or
not it has a default pin. And you can also, in the case of a
switch on it, note, if you are adding
some pins to it, like I'm doing here, you can
choose your start index. So currently says
start at index 0. I could say choose to
start at index ten, and then I'll make the
first number here ten, and then it'll
number accordingly. I'll set that back to default. Switch on string. Very similar. I can add more pins like this. And with that selected
over in the Details panel, I can choose whether or
not it has a default pin. I can choose the pin
names, et cetera. I can choose it. They are
case sensitive or not. So there are some different
options depending on the type of switch node. Now, the default output pin, when do you flow out of this? You will flow out of this if the data being input does not match any of your different
output pins that you desire. This is easily seen on
the switch on internode. So right now I have a
selection of zeros. If I was to flow into this, I would fire out of
the 0 output pin. If however, my number
here was saved 50. And we were to run a
script through here. It does not match any
of these outputs, so we would fire out
of the default output. Okay, I've got a few examples
I'd like to show off here. So I'm going to be starting in my third person
Character Blueprint. Now what I've done
ahead of time here, I did this in an earlier video. I created an enum
called E health status. This enum, this enumeration
consists of three labels, super okay, and hurt badly. I'm just going to slide
this section over to this portion of the
graph where I have some nodes awaiting for me. And what I'm simply
going to do is upon pressing some input key, I am going to alter my
characters maximum walk speed. Now, you can alter these
parameters right here, this max walk speed parameter, if you select your character
movement component, you can see over in the
Details panel you have a parameter called
max walk speed that, that controls how fast
your character moves. So all you need to
do is drag and drop. Add this to your
graph, the drag out of here and type in
set max walk speed, and you will find that node. So what we're gonna be looking
to do here is based upon the value of our enum
here, super, okay, or her badly, you see those are the three outputs
that correspond with the three labels that
this enum consists of. If it's super, we're going to increase our max walk speed. If it's okay. We're going to set it to be. 500. If we're hurt badly, we're going to set
this to be 100s. So I'm going to right-click and I'll
bring in an input key. Let's try the aids key. I don't think I'm
using the aid key for anything just yet. So right now our health
status is super. So once I press the a key, we should increase our
maximum walk speed to 2 thousand years. So clicking play,
setting my debug. Object to my
ThirdPersonCharacter. Here we go. So I am wandering or bout wondering about I'm
going to press that achy. And now suddenly I
can move much faster. Boasted changed my health
status here to simply be hurt badly. I've
changed that now. So once I press the a key, we're going to evaluate
this value heard Valley. We will flow out
of here and it'll change our max B2, 100. Clicking Play. There we go, pressing the movement keys
right now, WAS and D. Here we go. Eight key. Now I'm hurt badly and I'm
an Olympian right along. So there is an example
of a switch on enum. For this next example, I am going to kill this enemy. Look at that scary guy out there by simply
clicking on them. When I do, I'm going to
use a switch on inch node to spawn some loop to kinda create a random
loot drops system. So if you want to
play along at home, I simply added a mesh. This S k, m at Manny from my character mannequins
meshes folder, a drag and drop
that into my graph. And with that selected, I went into my Level
Blueprint here. And I have a few nodes set
up ahead of time here. I added an onclick event
for that S KM many, again, you have to have
him selected and your level and you can add one of these by right-clicking. And events in input
events, a mouse input. And this is where I
did an onclick events. So what do I want to do
when I click on Manny here? Well, I'm going to drag
off of here and bring in a switch on node. And I'm going to add
some output pins here. I'm gonna go 1234. And I am going to pick an integer value
from a random range. So I'm going to drag
backwards off of this and type in random. Random integer range is
what I'm going to look for. So I'm going to say give
me a number between 03. So it'll pick 012 or three. And then I will fire out of the corresponding pins based
on which number it selects. Now what I wanna do is
if we get a 0 or one, I'm simply going to flow into
a play sound to the node. It's going to say fail. So 50% of the time we're
just going to play a sound and you are
going to get nothing. So we'll say 50% of the
time for killing a man. He there you get nothing
but the other 50% of the time we're going to spawn something into our level here. I'm going to drag into a
spawn actor from class node. You can right-click
and do a search for spawn actor from class. We're going to say if we
get a two or a three, we're going to spawn. I'm going to spawn in a BP man, a potion we created that
earlier in the course. And I got to feed this
a spawn transform because if I compile right now it's gonna yell
at me and say, Hey, you need to spawn
transform for this. So I'm going to say, where should we spawn this? Let me just get rid of
these two nodes down here. Well, I already have
Manny selected, so I'm going to right-click
and some empty space. Actually I'm not
going to right-click. I could right-click and get a reference to Manny like that. Or you can hold down
the RT left-click and get a reference
to Manny like that. Let's drag off of Manny and
type in get trans form. We're looking for the
world that transform. We get actor transform
is just fine. We'll plug that into. That's end. Let's play a sound
of sorts after this. So we'll drag off of
this play sound 2D, and we'll play teleports. Committed. Sure,
that sounds good. Let's compile our script here. So when we click on Manny, we're going to pick a
number random between 03, depending on what number we get. We will either fail
50% of the time or 50% of the time we will
spawn a manifestation. So this is a way you
can kind of create a randomized loot system
that is weighted. If I wanted to wait this seventy-five percent
of the time to span and to span
a man, a potion. You can see how I could go
with a setup like that. But I'll go 5050 instead. Compile, save. Get rid of this guy right here. And we'll deal with those string in name switches
in just a moment. Hey, This, moving this
over to the corner here, I'm going to set my map
as my test debug object. And here I go, I'm going to click on it. You'll see this
script firing off. Bam, there is a man, a potion at his feet, and I didn't destroy many. I probably should have
done that as well. Because we can now
continue to click on them. It's all spawning it in
the exact same spot. And actually I should do that. Let's kill off many. If we in fact spawn that Amanda potion
dragged out of money, we will say Destroy Actor. In the events that we click on. Both of these can flow
into there like so. So now when I click
on them, bam, dead, we have a man, a potion that
we can collect as well. Alright, next example
I am showing off here is going to be done inside
of my Level Blueprint. And as a little bit of
preparation done ahead of time, I do have a Manny added
to my level here. And just to show you what
else I did here is with Manny selected back in my
Level Blueprint, right away I got a reference
to Manny down here. So you can get that
by holding down the Alt key and left clicking. And then what I did is
I draw it out here. The actors location
by typing that in. I'll explain all this
in just a little bit, but let me backup a little bit. Firstly, we are
pressing the five key. So if you right-click
and type in keyboard, That's how you can
get the five key. Well, we're then doing
is we are going to flow into a switch
on string node. Now this is what the node first looks like when
you bring it in. However, you can add some pins by clicking
on this plus button. When you do, you can rename those output pins by
overriding these names. And you can see I did
that by naming them Bob, Pablo, and whoo. Alright, so I'm gonna
delete this one out in favor of the one
I set up ahead of time. Now we are flowing a
string variable into this, I created a variable here, namestring, and it is
of the type string. And I set the default
value to be Pablo. As you'll note,
that is the name of my middle output
execution pin right here. I left a note port right here. Then what I also am
doing is not only getting this string
variable to plug into here, I'm also setting that exact
same string variable back to Whoo As soon as I
release the five key. So I'm pressing it, evaluating this string variable's
contents, it's gonna be Pablo. So we will continue
flowing out of here. And then we're going to
teleport our player character, that is us, to the
location of Manny. Now we can't flow exactly
to the location of manny. I simply drug out of here, brought in a subtract
node and I'm simply subtracting by 200 in the x location just to
offset myself a little bit. And I plug that in as my
destination location. So note I'm pressing
the five key. This string variable
will read as possible, so will flow out of
the Pablo output. We're going to teleports to
the location near Manny. As soon as I release
the five key, it's going to change the
contents of that variable to woo so that the next time
I press the five key, we are going to do
nothing because there is nothing coming out
of the Wu output. Pin. Compile save. Let's go ahead and play
here in test this out. Alright, so check right up here. I'm going to be pressing
the five key and I will be teleported close
to many there. And just to really
prove this out, let me fly far away, run far away from Manny. Okay, here we go. Five
key. We've teleported. I'm now going to
release the five key, setting the contents to Wu
now for that string variable. So the next time I
press the five key, we can even see that
it output whoo. You can see that by mousing over this wire, it's showing Wu. And nothing happens because
we don't have anything happening off of
the Wu output pin. So there you have it for
switching on string. And last but not least, one more example of
the switch node. This one is going to
be switched on name. I'm also going to be doing
this within my Level. Blueprint has a
little prep work. I have a couple of name variables over in
the variable section. I created these way
earlier in the course. One of them is called a level 11 of them is called level two. And when I gave them
a default value, I named one starter
map in lowercase and the other level to hear
minimal default in all caps, these actually correspond to the name of some level assets. If I jump back to
my content browser down here within the starter
content maps folder, there is a minimal default map and there is a starter map. So I'm going to be using these variables to drive
which level we are going to transport to that we're
going to go to based upon the selection that we plug into this
switch on NameNode. And I'm gonna be
going about this a little bit differently. Firstly, I'm going
to left-click and drag each of these
into my graph. Like so. Then what I'm going to
do just to show off a different thing that
we can do here is I'm going to make array. An array is a list
of like things. These are both named variables, so we can create
a list of those. I'm going to add a pin so that I can plug in at level two here. Then I'm going to back this up just a little bit and I'm
going to drag out of this. We now have an array
consisting of two elements. I'm going to drag out
of this and type in random, random array item. And I will plug
this in like salts. So this node is going to
pick a random array item. We only have two possible
selections here. It'll choose one at random, and it will let me click
plus and plus flow out of each of these depending
on which element it picks. So I am going to change my case 0 here to match level one here. So starter mountain
just going to hit Control C, switch on name. I'll override that control V. And then for level to
Control C and switch on name Control V. Alright, so if it is the starter
map that gets chosen, we're gonna flow to the
level named started maps. I'm actually going to drag
and drop this level onto this open level
by name function. And if this chooses
from our array, the minimum default
level to here, I'm going to drag
and drop this onto here and go like that. Alright, so let's go ahead
and compile that. Save it. And we'll give this a play here. So as soon as I
press the five key, we're going to freeze
because we're going to be transporting the levels here. And so we did in fact transport to another level
playing once again, see if we get the
other one to show up here pressing the five key, there is our minimal
default level, and there you have
it, switch on names. So these switch on
nodes are super useful. I personally like to
use the switch on nodes quite a bit to chronic create a random
loot drops system. You can wait those
loot drop percentages, but lots of useful
applications guys that'll do to offer this video. See you in the next one.
87. Select: Welcome. In this video, our goal
is to gain knowledge and demonstrate use
of the select node. Now the select note isn't officially considered
a flow control node as it does not affect
the flow of execution. In fact, there are no
execution pins on this note. However, the select note does aid in the flow of
data in your script. So I thought it best to
include this lesson here. So the select node, what exactly does it do? Well, select notes, take in any index and based
upon that index, it will return one of
the options inputted. Now this is useful
because sometimes you want the return value here to be different
depending on the value input. Now just a very quick example. If I change our index type
here to be a Boolean, we see that our input pins here change to be true and false. Now, depending on
if this is true, we could have the true
value here, output. Or if it is false, we could have whatever
is input into the false being output. So you can see depending
on the value of this, we're going to pick one of these options to
return, alright, to bring one of these select
nodes into your graph, it's as simple as
right-clicking and doing a search for select. Or alternatively, another way that you can bring
in a select note is if you have one of these
index types, boolean, byte, integer, integer 64, or any enumeration you
could drag out of that variable type in find
the select note as well. Now just to demonstrate this, I'm going to choose, I have an integer variable over on my left-hand side here. I'm just going to drag and
drop this into my graph. I was to get it and
then drag out of it and type in select. You can see that I can find
a select node from there. And that integer is immediately plugged into the select node. Alright, let's quickly explore some node options here before
we show off some examples, I'm just going to delete
out this node quickly. You can right-click on a node, the node itself, and you can see how you can add pins to it. Right-click Add pin, or you could remove pin
by right-clicking on the node, remove pin. Remove pin. Right-clicking an option or return value can
change the pin types. Right now these are
set as wildcards, meaning that they can be changed to something
dynamically. Do whatever I plugged into this. Say if obviously
plug in a vector into option one is
going to change all the other pins
here the option in the return value to
be that same type. Or I could hard set a
here by right-clicking on either the option
or return value pins. And by doing so, I could
change the pin type to be one of the various options. Right-click Change pin type. And I could change this
to be say, transforms. I can also change
the index type down here either by clicking
on this drop-down. And I'm not sure why it's
showing it way up here. Once I click on
that boolean, byte, integer, integer 64, or
any of the various enums. Or I can simply right-click
on the pin itself and change the pin type with the little
drop-down there as well. But you've already
got this drop-down, so I don't find that option
to be all that useful. And then of course you can see on the note itself here you have the option to add pins simply by clicking on this plus button. So that's another way you can
add some more option pins. Alright, example time,
I'm gonna be showing off several select node examples
here in my Level Blueprint. So if you want to
play along at home, selecting your level
tab right here, open Level Blueprint,
That's how you can find your way on over here. And I'm going to start
off by right-clicking and typing unions select. Now the first example
I want to show off your is using a Boolean index. So I'm going to click on this drop-down and
select a Boolean index. Now notice that the
moment I do this and select boolean
is going to change my options here to be false and true because a boolean can
only be false or true. I'm going to drag backwards
off of my index here and I'm going to
type in random bool. So this node is simply
going to spit out randomly either the
value of false or true, depending on which
value it spits out. Let's just say, for example, it spits out false. It will choose that input, the false input here, to return. If it spits out true, it will choose the
true input to return. That's how it works. Alright, let's bring in
an event node right away. I'm going to Right-click type
in the five keyboard input. And we're going to drag
out of this and type in open level by name. Now this function will
open up a level by name. It is looking for
a name variable. Check this out. Over in the left-hand side. I've got level one
and level two. These are two named variables. That is the type here that I created earlier in the course. And after I compiled, I set the name values here to be starter
map for level one. Level two, I set the name variable type here
to be minimal default. Now this is not a mistake. I name these as
such because back here in my content browser, in the starter
content maps folder, there are two levels, two maps that we
can open up called minimal defaults and star map. You'll notice that the casing
of all the letters here, minimal default and starter
map is a little bit different here than what you
see in the variable names. Here's all capitalize, and here is all lowercase
for name variables. It doesn't matter. Alright? So I'm gonna plug level
one into the false input, level two into the true input. And actually before I drop
it in there, note this, the moment I plugged in a variable type into either any of these
inputs right here, or let me just snip this wire. I'm going to hold down
Alt and left-click. Or if I plug something into the return value
in this direction, it's going to change
both sides of the node to be that
corresponding variable type. So it knows that our return value desired
here is of the name. So it is going to say, okay, you're looking for a
name variable type, that means you've got to
plug-in some named variables. So level one, level two here. So once I press the five key, it's going to open at some level according to the name variable, we plug into it which name variable is going to
ultimately pass through here? Well, that's gonna be
determined by this select note. The select note is going
to take any random bull. It is spitting out false. It is going to pick, it's going to select
Level one here, the starter map, and return that to be the level
that we opened. If this random bool
spits out true, it is going to pick, select the true value here, plugged in minimal default, and pass that as
the level to open up compiling, saving, playing. I've got my test
map already set up there so we can see
this group firing. So when I press the
five key, here we go. It jumped me to my
minimal default level. In that case, it shows the true option because at random bool must
have spit out true. I know that was the
minimal default level. Alright, next example here
I'm going to start off by placing a Trigger box
here in my level. And you can find one of
those by coming right up here under the basic section, Trigger box, drag
and drop that here. With that, in your level, you can set your
box extent to be a 100100100 line
thickness of ten. And also, I also recommend making it so that you can see
this in your level as well. And you can do that
by coming under the rendering section and unchecking actor hidden in game. Alright, with that selected
here in our level blueprint, I'm going to right-click
and we're going to do something when we overlap that because we do a lot
of things in gains when we overlapped
a trigger volume. What we're gonna do is
we're going to drag out of our other actor and we're going to Cast to ThirdPersonCharacter. That is the characters
that we are controlling. And if it is true that the
other actor overlapping that trigger box was the
third-person character. We're going to spawn something, spawn actor from class. And we're going to
plug this in like so. Now what we spawn
in is going to be driven by an integer index. So what I'm gonna do is
I'm going to drag and drop an integer down
into my graph right here in integer
variable like so, you can create one
of these by clicking the plus button and adding
an integer variable. I'm gonna get it. And then I'm going to drag
out of here and I'm going to type in select. Because I'm dragging this
out of the integer variable. It knows that I want to
input that as my index. Now, I want to pick
something to spawn into my level depending on
the integer i input. So I'm going to go like
this to ensure that I have the proper classes
to put as my options. If I just drag backwards off of the spawn actor from class, knew like though, like so, and plug it into
the return value. It's automatically
going to change my input pins to be
of the same type. Here we go. Alright, so let me
add a third pin here. And now I can select different classes that
we want to spawn in. I'm just gonna pick
some at random here. I've got a man, a potion that I created earlier. We can spawn in some
fire blueprint effect. Fire doesn't really matter
what you slot it in here, and also do sparks. Those are some common
ones I like to. Alright, now my integer
here, if it is 0, if that's the integer
that we're feeding this, it'll choose Option 0
to spawn into the game. If I change this
integer value to one, it'll choose this option to return and spawn
into the game. If integer is equal to two, it'll choose these sparks to return and spawn
that into the game. Now I do need to give
us a spawn transform, because if I compile here, it's going to yell at me
and say, Hey you idiot, I need to know
where to spawn in. So I'll jump back to my level. I will bring in, let's bring in a target points. I'm going to click
right up here. I'm going to bring on
the place actors panel and type in targets. Target points. Place one of those
right about there. With that selected back
here in my Level Blueprint, I'm going to
right-click this time. Create a reference to that, will drive out of
this and typing get trans form good actor transform. And I know right now are
integer is a value of 0. So I'm going to
compile here. So we should be spawning
in a manner potion. So let's go ahead and play here. Shrink that down. So as soon as I overlap
this trigger volume, it should select
integer 0 here that man a potion to spawn into the game at the location
of that target point. Here we go. And it did in fact do that. Now, that is not super interesting because
we knew that that was going to be our
result because we have hard set our integer
value here to be 0. So what I could do
is delete this, drag backwards off of
our index and type in random integer in range. And I can say, Hey, pick
something between 02, compile, save in play. Here we go. Met a potion. If I keep overlapping because
I'm not doing this once. I'll eventually get them all. There we go. And so you can see
how it is picking a different option
here depending on the random number
that we're feeding it. Alright, one last example
here for this one, I'm gonna be using my BP
third-person character. So if you wouldn't
mind jumping into their double-clicking
on it to open it up, I am going to be
showing how we can use a select node along with
an e num in enumeration. Now we created this enumeration
earlier in the course. So if you want to know what
an enumeration looks like, I'm coming under my
scripting Blueprints folder. And in here I have the
enumeration eHealth status and you can right-click and
some empty space come under Blueprints to create
an enumeration asset. In this health
status enumeration, which is a list of
labels, if you will. I have super okay
and hurt badly. Then inside of my
third-person character, I created a variable, and I set the variable
type to point to that enumeration that I
created, eHealth status. I'm going to drag and
drop this into my graph. We're going to get that and
I'm going to drag out of this and type in select. So we can see
immediately because our enumeration
right here consists of those three
labels hurt badly, okay, in super, we see these as our three
inputs right here. Now what do we wanna
do depending on if this index here is hurt
badly, okay, or super? Well, what I wanna do is grab my character moving component,
drag and drop that. And I am going to, let's do something else here. You've seen me adjust my
max walk speed before. I'm going to set my
jump z velocity. Now the jump Z Velocity is a parameter inside of your
character movement component. There it is, that determines how high your character can jump. So I am going to drag backwards. Offices jumped z velocity. This is a float variable
than it is looking for and plug this into
the return value. Now the moment I do this, it's going to change all
of the inputs here to be a float value as well. Now I could plug
in some variables to determined these
values right here. I'm just going to
hard set them here. So I'm gonna say if
I am super my jumps, the velocity is going
to be 2 thousand. If it is, okay, I'm gonna set it to be 700, which is the default value
for the jumps, the velocity. And if I'm hurt badly,
I'm going to say we can only jump up to a 100. I'm going to need some
sort of input key here. So let me right-click. It's an empty space. I'll bring in the
five key here because I'm no longer using that
in my Level Blueprint. I deleted it out of there. So when I press the five key, we're going to set our
character movements. Jump z velocity property, that property right there. It's gonna be set to 2000s if our health status is said
to her, set to super. If it is set to okay, we're going to jump up 700. And if we are hurt badly, it's set to hurt badly. We're going to jump
up very little. Alright, so right now the
value of this is hurt badly, so I should barely jump up. So Compile, Save, play. Let me set my debug object to the ThirdPersonCharacter here so that we can see the
script firing off. So right now I'm hurt badly. So when I press the space bar, I don't jump up too far. But actually that's
my normal jumps. Sorry, I got to press
the five key here first. Now when I jump up, I'm barely getting
up off the ground. Let me set my health
status here to be super compile save, play, and now I'm
pressing the space bar, That's my normal
jump, pressing five. So I'm setting my
jump velocity now to be 2000s because the, the output for this is super. So now when I press the space
bar, I'm feeling happy. So there is an example use of the select node using an enum. Alright, so what are some other possible uses of
the select node? Consider these,
perhaps depending on the player's health status and you can add the player
played different animations. They could limp, for example, perhaps depending on a mood, enums, happy, sad,
that sort of thing, you could alter what
music track it's played. Here's another example. Perhaps depending on any
equipped weapon enumeration, you could display
different weapons holstered on the character. And lastly, perhaps
depending on a key integer, you could display x number of key meshes dangling
off the players bell. So if you had an integer
input that said three, you could display it three keys hanging off
the players belt. If that integer index at one, you could have one key hanging off the players
belt, that kind of thing. Alright guys, is
select node one of the most useful nodes
in all of scripting. Know what love it that'll
do to offer this one. See you in the next one.
88. Casting: All right, Welcome everyone. Well, we have hit
a very key portion of the course where
we're going to be talking about different ways to communicate
between blueprints. And we're gonna be talking about casting specifically
in this one. Now up until this
point in the course, you've seen me actually
do a lot of casting. The whole concept of casting
is essentially checking upon some interaction taking place if a given object is of the
type you're looking for, no matter if it is or is not, you can make some bit
of script fire off. Now you've seen me do a lot of casting up to this
point in the course, including our bp example pickup that we created at the very
beginning of the course. And now, just to jump
inside of this blueprint, we made it so that when
you begin overlapping the collision sphere for this BP example pickup that is this collision
sphere right here. We are doing this thing called casting to check to see if it was the
ThirdPersonCharacter that was the other actor that
did the overlapping. So once again, casting
allows us to check if a given object is of the type we're looking
for. In doing so. In this case, we were able to reach inside of our
ThirdPersonCharacter, grab the health variable
that lived inside of it, add some amount to it, and then set that
health variable back. We're communicating from
our bp example pickup here to our
ThirdPersonCharacter, increasing the health of
our ThirdPersonCharacter. So you can see
communicating between blueprints is a very critical
concept to get down. Alright, you've seen me Cast to ThirdPersonCharacter
here a million times already in this course. So I'm gonna be
doing something a little bit different
for our example. Let's head on back to
our level editor here. And then my scripting
Blueprints section, I'm going to right-click
and some empty space. And I'm going to choose
a blueprint class, and I will choose
the actor class. And I'm going to call
this BP underscore. Move when near. And you'll see why named it that here in just a little bit. I'm going to double-click
on this guy to open it up. And I'm going to add
for our components in the upper left here
we'll add a simple, Let's add a simple cone
under the basic shapes. And we're also going to
add one more components. And this one is gonna be
called interp to move. Now this is a really cool
component that allows us to move our blueprint here between however many
points we set up. Now I'm just going to
leave it at that name in Too movement and
hitting Enter on that. And with it selected,
I'm going to head on over to the Details panel to set up some points that
I'm going to have this cone moving between. Now I can set that up over in our control section over here. And if I click on
this plus button once and twice and expand
these arrows out, I can choose some points in space that I want to
move this cone between. I'm going to leave the first
one at 000 and the second. These positions are
relative to one another. I'm going to just set
to be 50 in the z. Now down below, little bit down here in the
behavior section, we can choose a behavior type, whether it moves just from point a to point B,
that's one shot. Whether I have it
do a looping reset, I'm going to choose
ping pong here. So it's gonna be
doing back-and-forth, back-and-forth between
these two points. Mi duration here is one seconds, so it's going to
take that amount of time to move between
those two points. Next, I am going
to compile this. We're going to save this and
we're going to head on over to my ThirdPersonCharacter
Blueprint. Now if you've forgotten
where that is, third-person blueprints, double-click on your
third-person character. Now, earlier in the course, we added this simulated hand, which is essentially just
some sphere collision. If you have this great, if you did not go through
that course and create this, you can create it now. Now I have this attached
to my capsule components. So if you do not have this, you can select your
Capsule Component, going to add type in sphere, and you can add a sphere
collision component. That's what that is. Now, I've set my
radius here to be 32. I think I'm just going to
set it out in front of my character just a little bit
more, something like that. And I'm going to
increase the size here a little bit to make it 50. And I called this simulated hand because I'm gonna be
doing some checking to see if something has overlapped
this sphere out in space. Alright, with that all done, we're going to head on
over to our event graph. And with our simulated
hand here component, we're going to
right-click on us. We're going to add an event
and we're gonna do something. We begin overlapping
that we already have something on begin overlap because I don't
see it in our list here. So the way we can
find that is with simulated hand selected
way down here. Under the events
section we can go to on component begin overlap. We can view where that is. And you can see that this
is the example that we set up in our function
library video. I'm just going to delete out
these nodes for the time being so we can make use
of our simulated hand. Once again, I'll delete out
this comment box as well. Move that into position. There we go. Alright, now the script I have in mind here
is I'm going to drag out of my other
actor pin right here. And now I can do casts to move to near that blueprint
that I just created. So what we're saying here is if the other actor that overlap
our simulated hand here, that sphere collision
right there. If that other actor
was the move to near a blueprint that I'm about to place in my level here. Let me go ahead and back
to my Blueprints folder. Move when near, I'm just
going to drag that out here. Alright, so there
it isn't my level. Going back to my
ThirdPersonCharacter, if that blueprint right here was the other actors that overlap my simulated hand,
I can do something. If it was not the thing that
overlap my simulated hand, I could do something else, but what I wanna do is reach inside of my BP, moved to near. This will give us access
to various components and properties inside of my
BP moved to near functions, variables, that kind of thing. I'm going to firstly,
right-click on this. I'm going to promote this
to a variable because I'm gonna be using that
variable just a little bit. So let's promote
this to a variable. We can leave it at
that name right there. And then we will drag
out of here and access our interp, two
movements components. Remember in our
bp moved to near, we had this component called
interpret to movement. Now inside of this component right here over to
the Details panel, I'm going to type in
the word activates. And you can see that it is
auto activated meeting. It would move between those two points that we had set up. Now I'm going to disable this for the time
being so that it will not move between those two
points that I had set up. It is not going to be
activated automatically. Let's compile and
save this once again, going back to my
ThirdPersonCharacter, we're going to say once our simulated hand is overlapped by our move to near blueprint, we're going to save that
out to its own variable. Then we're going to
grab inside of it the interp2 movement component. And then we're going to
drag out of it and type in the word activates. Vase, not active, activate. And here is where we are telling that interpretive movement
component that lives inside of that blueprint to become
active, to activate. Now the reason I saved this
out to its own variable is because now I'm going
to drag and drop this reference right
here in my graph. And we're going to drag out of this type in interp to movement. We're gonna get it once again. And I'm going to drag onto
this and type in D activates. Turn that back off. I'm just going to turn
it off with a key. Let me type in. Let's try the 0 key. So upon our simulated
hand components overlapping that BP moved to near blueprint
out in her level. We're saving that out
to its own variable, a reference to that guy. We're going to grab inside of
it and we're going to talk to our interp2 movement
component right there. We're going to tell that
interpretive movement to become active so that it moves
between these two points. Then back in my
ThirdPersonCharacter Blueprint, when I press the arrow key, I will deactivate
that movements. Alright, with that, let's
compile it and save. Let me kinda move this off
to the upper left up here. Gonna go in and play. Set our debug object to our
third-person character. And you can see our
simulated handout there and it rotates with
my character because it is attached to my
character capsule component. And I'll try to get
this from a side angle here so you can see
it's not moving at all. However, once I overlap that
with my simulated hand here, it does in fact move
up, down, up, down. Now when I press the 0, let me move away from it
and press the arrow key. It stops, it deactivates
that component. Now if I overlap it again, it doesn't activate it
again for some reason. I don't know the
reason behind that. Not sure if that's an
engine bug or not. But you can see it is trying to activate it up
here in my script. Once you deactivate it for whatever reason it
keeps it the active. But the point is well-taken here that by casting to
our bp moved to near, we were ensuring that it was that actor that are simulated
hand had overlapped. And in doing so, we
were able to follow this script out of
this execution plan. Now if that had failed, If it was not the other actor that overlap
that simulated hand, once again, we could have
done something our cast fail. And there you have it, guys
casting essentially allows you to check upon some
interaction taking place. If a given object is of the
type you're looking for, it is a great, great method for storing of some given the thing
to its own variable and also being able
to reach inside of it once you have cast into it
to access any variables, functions call any
custom events, that sort of thing
that you want to do to communicate from
one blueprint to another. That'll do it all
for this video, guys see you in the next one.
89. Direct Communication (Part #1): Welcome. Blueprint communication has been the focus of this
section of the course. And in the last video,
we focused on casting. And that being one of the
methods you can use to have one blueprint
communicate with another. Now casting is a wonderful in handy Blueprint
communication technique in that if your cast does succeed, you can capture a reference to the thing that
you've cast you, as well as it
enables you to reach inside of the thing
that you've cast you and access any components, variables, functions, call any customer events,
that sort of thing. However, it does
have a weakness. That weakness is you
must plug something into this object input
in order for you to actually get a reference to the thing that
you're looking to get a reference to or access
any of the components, variables, et cetera,
that you're hoping to access if you don't plug anything into that
object reference, let me go ahead and
just kill this out here inside of my Level
Blueprint and I compile, it's going to give me a
warning saying, can't do it, you must have something plugged into that object reference. So is there another way to communicate from one
blueprint to another? Yes, there is. There is a method called
direct communication. So in this video, our goal is to demonstrate how we can
have two Blueprints talk to one another
through a technique known as Direct
Blueprint Communication. Now with this approach, you set up a target blueprint
that gets referenced in response to whatever script you set up inside of a
working blueprint. Now let's show you what
I mean by setting up two different actor
class blueprints. We're going to have
a blueprint light and a blueprint button. And we're going to have
one talk to another using this method I just talked about direct
communication. Hop on back to your level editor here and inside of your
scripting Blueprints folder, let's create two new
actor class blueprints. Right-clicking Blueprint
Class I will create one of the actor variety
and this will be called BP underscore lights. And inside of here I'm going to double-click on
this to open it up. And I'm going to add
a few components. We're going to add a cone. I'm going to type in cone, basic shape cone. That's fine. And then I'm going
to add another one. Under the light section. I'm just going to type in light. I want to add a spotlight. And I'm gonna have to set some parameters
for each of these, starting with our
lights are Spotlight, we're going to set our intensity to be quite, quite bright. So with the light
selected spotlight set the intensity to be something
like a 100 thousand. You can set a different
light color right here, but I'm going to set it to
be 100 thousand right now. I'm also going to
have it facing down. So it's rotated this
on down like that. That'll do. And also under the
rendering section where it says a visible, I'm going to check
this or uncheck it rather so that it
is not visible. Okay, So you've got a
cone and the spotlights. That's great. Alright, head on back to
your content browser. We're going to right-click
again Blueprint Class actor. This won't be called
BP underscore. Button. Double-click on this
guy to open it up. And inside of here we're going
to add a few components. Add, we're going
to add a cylinder to start basic shapes cylinder. Next one we're going
to add is going to be a box collision. So I'm going to select
my default scene root. It doesn't have to be attached to my cylinder here and
it's fine if they're all attached to my
default seen routes. So I'm going to click
there and type in box. We're gonna go with
Box Collision. Box is a fine name. And then I'm going to select
my default seen route again. And I'm going to add a
text render component. Okay, with each of those, I'm going to set their
details one by one. Let's start off with
the cylinder first. So selecting your cylinder
over in the Details panel, I'm going to set my rotation in the x to be U1 AT pressing enter negative 90
in the y and the z, I'm going to set that to be 180. I figured out all these
numbers ahead of time. And then for the scale
I'm going to set it to be 0.4.4 and 0.05, something thin like that. So this is going to be our button that we're going to quote unquote interact with in
order to make our light, in our light blueprint
illuminates to turn on, to toggle on and off. Right next we're going to select our box collision
component right here. I'm going to set the location, the x location to be 100. And we're going to set the
box extent to be one hundred, five, fifty by 100. Something that extends out
a little bit like that. Okay, and then I'm
going to select my texts renderer component. You can see it just Showing some texts right there. With that, I'm going to
change the location. We're going to set the
location to be 20 in the x and one hundred and one
hundred and ten rather in the z something
right up above, right there. And I will change the text
to read right down here. Instead of texts, we're
going to have it say press I to injure act
exclamation point. And it's not centered above my button
there, that cylinder. So where it says
horizontal alignment, we can change that
from left justified to center just to make that
look a little bit nicer. And then in the
rendering section, I am going to
currently make this invisible so we can't
see it to start with. Alright, Next we're
going to create a couple of variables here in
the My Blueprint panel. So click the plus button along
the variables header here. The first one we're going
to create is going to be called simply light. And for the type, we're going to do a
search for BP lights. This is the blueprint
that we just created. So come under object types, BP light, choose an
object reference. And what we're gonna do is
over in the Details panel, we're going to check this box. It says instance editable. Notice that when I do this, this is going to have
the same effect as clicking on this little
close eyeball icon. So if I click right here, it's going to have
that eyeball icon on. Conversely, if I
click right here and turn that off,
it unchecks that. That's essentially
two different ways of setting this to be instance editable
doesn't matter if you click there or
click this eyeball. Both of those essentially
do the same thing. It's turning that on. Now that's gonna be great
because it's going to expose this particular
variable in the editor. You'll see that in
just a moment here. Now I'm going to compile here because it's asking
me to compile it, to give it a default value. But notice this I'm compiling. I am going to leave this as
blank for the time being. We're going to populate this
back in our level editors. So leave this blank
for the time being. All right, we're going to
create one more variable here, clicking the plus button. I'm going to call this can
toggle lights, question mark. And this would, this will
be a Boolean variable. If I compile here, I'm going to leave the
default value is false. So you'll see this guy in action here in
just a little bit. Now, like I mentioned towards the beginning of this video, Direct Blueprint
Communication evolves a target blueprint and
a working blueprint. So the target blueprint is
going to be our bp light. That's the one we're
going to be targeting. Our bp button here, that is going to be
our working blueprint. So inside of our
working blueprint here, we're going to reference, going to create a reference to our bp light in order to talk to it, in
order to work with it.
90. Direct Communication (Part #2): Alright, time to
do a little bit of setup back in our level editor. And it probably
helps if you have some kind of a wall surface, but you don't really need one. So I'm going to place
both of these out. And our love, I'm gonna
start with our bp button dragging and dropping this. And you don't have to be
super precise with this. However, I am going to
wheel it around like that. You want to have the majority of your trigger volumes sticking
out in this direction. By the way, I've set it
back along the wall again, I'm not going to be
super precise with this placement for
the time being. And then I'm going to
place our light out there. There's my BP light in all
of its wondrous glory. It's gonna look
something like that. That's good enough. Now if I select my B P button, check this out over
in the Details panel. If I scroll all the way on up, I've got my light variable. Let's review this once again, my BP button there is my light variable referencing the B P light variable type. It's currently set to none. So here in my editor, I can set this to directly
reference that blueprint. I'm saying, hey, I want that variable B of
the B P lights type. But I need to specify which instance of that
light I want to talk to because I can have multiple instances of
these lights out here. And in fact, let me set multiple instances of
this light out here. I'm just holding down the
Alt key and dragging. Now with my button
selected here, I'm going to click on
this little eyedrop icon over in the Details panel. I could click on
this drop-down to, to pick one of those four. However, I just want
to show the often if I choose this eyedropper icon, then I can move on over
to my viewport and directly select
that given lights. Now notice if I'm
highlighting it, that is not that
given variable type, it's going to say you
can't select that. However, are BP light is
of that variable type, so it allows us
to pick that one. So it has allowed me
to slop that in there. Next, let's head on
back to our bp button. Inside of here, we're
going to head on over to the Event
Graph right away. We're gonna do stuff when
we overlap this box. So head on back to
the event graph. I'm going to left-click, drag, delete those out right away. With my box selected. I can either right-click
on this to find some events or with
F-box selected, I could go way on down to the bottom of
the Details panel. There are my various
events related to it. I want to do something when
I begin overlapping that, as well as when i and
overlapping that. So I'm going to click here to add a reference to
that right away. Clicking back on
my box component, I'll do something when I
end overlap that as well. So what do we want to do when we begin overlapping that box, this box right here? Well, we want to
check first of all, to see if that is the ThirdPersonCharacter that
did the overlapping. So I'm going to drag out the
other actor will do some canceling here to
ThirdPersonCharacter. And when we do that, we're going to bring in
our Ken toggle light. And if you drag and drop
this right on this pin, you'll bring in a
setter right away. There we go. Handy trick there, just
dropping it onto the pin, I will say Yes, we can toggle the light if
our ThirdPersonCharacter is overlapping that box where essentially
against the urine range. And then what we're
gonna do is bring in our texts render component. We're going to drag and
drop this right here. And we're going to talk to
our text render component. We're going to drag
out of this and type in set visibility. Because remember right
now that is turned off. We're going to check
this box and say, yep, you're now visible. Now I'm gonna do much
of the same down here. So I'm going to select
hold down Control, select hold down
control and select, I'm going to copy these three
nodes control C, control V. Paste them down here for when we end overlapping that box. And I'll plug it all in like so. Don't forget this guy. And don't forget to uncheck
this box down here, as well as unchecking
this box down here. Because when we end
overlapping that box, we do not want to be able
to toggle the light and also we want to turn
off our texts render. We don't want to see that
interact message at all. Alright, I'm going to
left-click, drag, tap the CQI. We'll call this in range
to, toggle the lights. I'll turn this
black like my soul. Alright, that is
all well and good. And next I'm going to add some
interact script down here. Remember, our message
was going to say, press the I key to interact. So let's right-click down
here and do keyboard. We're going to add a
keyboard event for when we press the I key,
there's our icky. The first thing we're
gonna do is we're going to bring in a branch, going to hold down the B key and left-click
bring in a branch. So that when we press that
we're going to evaluate, Hey, can we toggle the lights? Remember, when we're overlapping or not overlapping that box, we're setting that
to either true or false when we're
overlapping it. It's going to evaluate as true. So yes, you can tie with light. So out of the achy, we're going to or not the achy, the true key, true pin, I should say we're going to
bring in a flip-flop node. Flip-flop node
allows us to switch a then B than a than B
every time we do this. And what we're going
to flip flop is having our cylinder drag and
drop this into our graph. Change the material,
good typed set material. Like so, going to Control C, Control V, that as well. And right up here, I'm gonna change this to
a green colored material. So let me just click right
there and I'm just going to type in the word green. Our material here will be, let's try doing a search
for green, vertex. Green that is in the engine
pathway is by the way. So if you don't see this, you can click this gear icon, make sure you have show
engine content turned on. So we're gonna go green there. And then on this node I'm going to click these
three dots and make a note for
myself that this is going to be a red material. Material here is going to be vertex vertex red. There it is. Got to set this to be the
target for that as well. And then I'm going to
drag and find my light. We're talking this light
right down here in the variable section drag and drop. We're going to get that. Then we're going to drag out
of this type in spotlight. Because remember in
side of our light here, this BP light exist
the spotlight. And we're going to tell this
spotlight dragging out of here to toggle visibility. So if it's off, it's
going to toggle it on. And if it's on, we're
going to toggle it off. So that's gonna be our
script right there. Now we're gonna be
changing essentially the color of our
cylinder right here, this cylinder
material to make it so that it looks green
is on, red is off. So let me give us a red coloring to start
with vertex Read Only. Alright, let's
compile this save. I'm gonna go back to
my event graph here. Left-click and drag,
tap as CQI and I'll say must turn on. This is a note to myself
for the next step to do. And for us to do
auto receive inputs. Well, two, player 0
in class D faults. Now you're gonna be like this, makes no sense for
what we just did. So why are you putting this as the comment box header here? And you'll see why. Because if I compile this, save and I go in and play,
you're going to be like, well, this is going to
work as soon as we overlap this Trigger box, we're going to say,
Yeah, you can toggle the lightened down here when
you press the I key. This will then evaluate to
true and it should allow me to change that material for the cylinder and then
toggle on the light, but it won't work because
of this right here. Let me just demonstrate
this quickly. If I jump in and play, I can even set my
debug object there. So you can see that script
has gone through saying, yes, I should be able
to talk with light. So now when I press the I key, let me just move this on up. Press the I key and I see
that I'd interact right? I'm gonna go ahead and
sit, press the I key. But nothing is firing off. Even though I'm pressing it. What is going on? Well, this message
right here was a reminder to myself
and to you that we have to turn on something
called auto receive input two player 0 inside of our
class defaults here. Now BP button should be
your blueprint here, class defaults down in here. Under the input section, you must change
your auto receive input here to be player 0. Why? Well, our parent class here
is an actor class blueprint. Actor class blueprints will
not recognize keyboard inputs unless you go inside
of class defaults and tell it to explicitly
receive inputs. Player 0 is us, the single-player,
just us, right? So that'll make that work. Also. If you have multiples of these
setups around your level, is probably a good
idea here to select your icky and uncheck,
consume input. In doing so, you'll
make it so that this kind of a setup
can work up for, work for more than
just one button. If you leave this to
just consume this input, it would work just in one case, not in all cases. So thought I would throw
that out there as well. Alright, compile, save, play. We're going to
overlap this here. Blueprint. Say press I to interact. We are within range. So now when I press the I key, it turns green and you
see that that light is now showing and
just this light, not every copy of the light, just that one because that
was the one that we had said specifically to populate
this light variable. If I go back in here, I can interact once again. And I turned it read
to turn it off, on, off, on, off. We're toggling the visibility. So this is a method called Direct Blueprint
Communication. With this method, we
have set up a variable of the type that we want to talk to a given
type of blueprint. In this case, we want to
talk to the BP lights. And with that BP light
variable created, we set it to the
instance editable so that we could target
it specifically. Here in the level editor
Working Class Blueprint is our button and the
target blueprint is our light inside of the
Working Class Blueprint, you have to create a variable of the target blueprint
and then set that reference here
in the level editor. Very handy method to
communicate between blueprints. Guys that is gonna do
to offer this video. See you in the next one.
91. Event Dispatchers: Welcome. Thus far we've talked
about casting and direct communication as
methods used to have one blueprint communicate with another blueprint and those are fine and dandy, great
methods to use. However, there are times in Blueprint scripting
where you need one blueprint to communicate
with many blueprints. So is there a
method to use then? Yes, there is. There's something called
an Event Dispatcher. Now, if you're unfamiliar with what event dispatchers are
there a lot like Twitter, that is the best analogy
I have heard to date. Now, if you're
familiar with Twitter, a user can tweet out a
message in any folks who follow your Twitter account
receive that message, then they can
respond accordingly. In Unreal, a blueprint
can dispatch, that is, to send out a signal to any other blueprints
that are subscribed, that are listening
out for that signal, and then they can
respond accordingly. Alright, so the example that
we're going to go through here is I'm going to create
a character blueprint, a boss character if you will. And when this character
is destroyed, we're going to make
multiple things happen. We're going to communicate from our boss blueprint to other blueprints, multiple
other blueprints. Alright, there's a
lot to cover here, so I'm gonna be moving
a little bit fast, but you have the
benefit of pause. So let's get right to it. In my scripting
Blueprints folder, I'm going to right-click
in some empty space, we're going to create
a new blueprint class. This time, character is our
parent class that we want. And we will name this
BP underscore boss. Going to double-click on
this guy to open it up. And let's select our
mesh component in our components list over in the Details panel
under skeletal mesh, Let's slot in Manny, Manny. And let's make a move as well. So the Anime Class, I'm going to do a P or a BP, many, that'll make a move. And then I've got
for the location, we need to drop them
down here a little bit. The z location I'm going
to set to be negative 93 is going to drop
them down a little bit. Now might be a
little bit too far. Let's go negative 85 or
something like that. Negative 85,
something like that. And for the rotation, I'm just going to
choose negative 90 and that'll get
them facing forward. That blue arrow
is facing forward also would not be a boss
if he remained that color, we got to make up scary, so
I don't have the materials, I'm just going to type in red. There's gotta be some
vertex red color in here. Any red will do. I'll go with this laser
pointer material. This is just for aesthetics, so that material covers in
that portion of his body. And then I'll type
in laser as well. Allude to the other
laser point material for his other part of his body. Look at that scary guy. Alright, with that,
we're going to create an event dispatcher
right down here. So you create event dispatchers in the My Blueprint panel
at the very bottom here, we're going to create one,
clicking this plus button, I will call this boss
destroyed and hit Enter there, go ahead and compile and save. Next we're going to
add an event for when we overlap this
capsule components. So I'm going to select
my Capsule Component down in the Details panel. This is one of several ways
I can add events for this. I am going to find
my own component hit event right there it is
clicking this plus button. It's going to jump me from my viewport to the Event Graph. And we're going to build
off of this event node. I'm going to drag out
of the other actor pin. And we're going to
find out, is that our third person character. If it was the third-person
character that hit us, we're simply going to call
out this boss destroyed. We're going to send out
the tweet, if you will. So the way we can
call for this is to drag this in here, like so. And it's going to say, do
you want to call bind, unbind all these options. In this case we want to call it, we're going to send
out that tweet. Now the note is going
to look like this. It'll have a little
envelope on it as well. So that's going to
send out the tweets to any subscribers if you will. And lastly, we want to drag
off of here and type in Destroy Actor to make sure
that our boss goes bye-bye. All right, with this, we can compile and save. The tweeting is accomplished. Next, we just need a
subscriber or three. So jump on back to our level. And won't you go ahead
and place some of these light blueprint
out in your level. We created these light blueprints
earlier in the course. And you can find those in your scripting
Blueprints folder. If you don't have these created, you could choose
some other blueprint that we created earlier
in the course as well. These are just the ones
that I happen to choose. Also, I have placed one rotating door blueprint that we created earlier in the
course out here as well. I'm going to show different
methods as to how this sort of communication
is going to work. But I'm going to start
with my BP rotating door. So inside of my
BP rotating door, I want to dig inside
of that blueprint. Let's head on in there. We're going to add a
brand new variable. So under the variables section, we're going to click
the plus button. And I'm going to call
this the boss character. And under the variable type, I'm going to click right
here, do a search for boss. And there I can find
my object type B, P, boss, that blueprint
that we just created. And I will make that
an object reference. Now with this variable here selected over in
the Details panel, I want to check this box, for instance, editable
so that we can slot in our boss from
the level editor. And if I compile here, we can see that there's nothing populating this
variable right now, but with this instance
editable check, alternatively, we could have
clicked on that eyeball. I will be able to select our
boss place in the level. In fact, I'll do that now. If I place my boss into
our level, like so. Now I can select
my door blueprint. And over in the Details panel, I can see it is asking for me to slot in a boss character
to populate that variable. I could select this right here
and select my boss there. Alternatively, I can select this little eyedropper here in order to pick the proper boss
character from the scene. And there you go. Now you can see our bp
boss populates that variable inside of
our bp rotating door. Now what I need to
do here is have a rotating door subscribe to
that boss destroyed event. And this can be done back in our rotating doors event graph. So the first thing
we're going to do is come up to this portion of our event graph
right up here above where our door
rotation timeline was. We created all this
growth when we put together our rotating door, I'm going to hold down
the p. P is in play key. And we're going to left-click
with the P key held down to bring in an
event begin play. Next, what we're
gonna do is bring in a reference to our
boss character. So I'm gonna hold
down the Control key, left-click and drag, and now it'll give me a
getter right away. However, I don't want this
to be just a typical getter. I'm going to convert this
to a valid dated gets. Now if I right-click on this, I can see that option
convert to validate the get. And what this does is it
allows me to check right here. If this variable is valid. By that, I mean, is it
populated with something? Is it actually something
that is not null, not none. If it is populated
and spoiler alert, it is because currently I've got my rotating door sets to have that boss character
value set to that boss. If it is valid, we can
fire out of this pin. If it's not valid, meaning
this variable is null, we could do something else. So this is a validated get, use those all the time. Next, what we wanna do is pull out of our boss
character here. And I'm going to sign in if I type in assigned correctly there here's what
I'm looking for. A sign boss destroyed. Now when I bring this in, I'm actually going
to be bringing in two nodes, so check it out. Assigned boss destroyed.
When we do this, we're going to bring
in a Bind node as well as a custom events. I'm going to leave this
custom event with that name. You can name it to
something else. But here's how this works. Upon beginning play. We're going to check to see if our boss character
variable here is valid. If it's populated with
something, if it is, we're going to bind this custom events to
this boss destroyed, this boss destroyed
Event Dispatcher. What essentially
we're doing here then is telling this event to wait for that
event to fire off. When we call, when we call
this boss destroyed events. Right here when we touch that capsule component
of the boss, we're going to call
that event right here, will be waiting out,
listening for it. This will not fire until that boss destroyed
event is called out. Our bp boss is
calling it out right here with this Event Dispatcher. And right here are
rotating door, is listening out for that
with this setup right here, that listens out for it. Once this happens, we can shoot
out of this custom event. That's essentially
the setup there. So what I'm gonna do is after
we have listened out for that boss destroyed events, we're going to delay or just
a short amount of time here, we're gonna delay
for one seconds. Then I'm going to wire this
down into my door rotation. So we're going to open the door. That's something
cool to do right? After you defeat a boss, suddenly that door
becomes unlocked. So I'm going to
compile and save this. And let's go ahead and
play test right away. So here I go. Set this write-up. Here. I'm playing. So you can see that fire
off right through there. So now this event, this boss destroyed
custom events, is listening out for
this boss destroyed. This boss destroyed
events to be called out. That Event Dispatcher,
that is the tweet, the message being sent out. So here we go. We're going to watch this
eventually fire off as soon as I run into the capsule
component of our boss. Let me bring on our
player window here. Alright, and that door will
open up after a second. So here we go. Boss goes, bye-bye. 1 s later. There it opens. That tweet was received and the BP rotating door
responded accordingly. Now note a setup like this
could be duplicated inside of our bp light blueprint or any other blueprint for that manner that we
place in our level. And that would work just fine. All of those could subscribe to our boss destroyed event
in a similar manner. By the way, a lot of times
it's great to have these listening out for that event
right upon begin play, so that whenever
that event happens, they can respond accordingly. However, I'm gonna go with a little bit different method of listening out for that event, so to speak, by using
our Level Blueprint. So I'm going to jump back
to our level editor here. We're going to open up
our Level Blueprint. So open Level Blueprint, find some empty space
inside of here to work on. Now the first thing we
need to do is jump back to our level and let's
select our b, a P boss. Now because our bp boss exists in the level and we do
have them selected. Please have them selected, jumped to your Level
Blueprint now, we can right-click and
some empty space and do a search for boss destroyed. So check it out. We can add a boss
destroyed event. So this event will
be called when our bp boss calls for that
boss event destroyed to occur. Now, what we're gonna
do next is bringing a reference to our
three light actors. So going back to our level here, I'm going to select
the first light, the second light holding
down Control left-click, and the third light as
well, control left-click. All three of those are
selected right here, heading back to my
Level Blueprint, I'm going to hold down the R. R is in reference and left-click
to bring in a reference to all three of these. Stack them numerically
like that. And what we wanna do is
drag out of one of them and type in set visibility. Sorry, we have to get the
spotlight important for us. So I'm going to say get spot light component because each of these lights consists of
a spotlight component, which we can see
with one of them selected consists of the
spotlight component. And I'm going to drag out of
the spotlight component and type in set visibility. And we will say that it
will become visible. And I can duplicate
Control C Control V, that spotlight for
each of these. Like so. And when this happens, I can also drag off of this
and say Place down to D. Let's bring in a little sound. Sure, like so. And will have an
explosion Q playwright. Alright, so now check it out. When we touch our boss with
our ThirdPersonCharacter, we're going to call this events. It's going to send
out that tweet. We already know that the rotating door is going to be listening out
for a palm begin play. And once they hear that the
boss has been destroyed, it will fire off this and
rotate open that door. Here in our Level Blueprint, we can just call this
boss destroyed events. We can add this
event immediately. By having this being called. We're going to then just set
the visibility of our lives. So let's go ahead and try this. This time we will
focus on our lights. In once we destroy the boss. Let's go on. Door opens. Now once again, I
could have taken a similar approach inside of our bp lights to have
that BP quote unquote, subscribe to the boss
destroyed Event Dispatcher. But I just wanted to
demo here that you can have these event dispatchers fire off directly within a level and actually
sublevel blueprints. So long as a reference
to that actor, in this case, our bp boss, contains an Event Dispatcher
that exists in your level. Well guys, there you have
an Event Dispatcher is a great method to use when you want to
have one blueprint, talk to many, base upon
one event happening. Guys, I'll do to offer this one. See you in the next one.
92. Blueprint Interfaces (Part #1): Welcome. In this video, our goal is
to learn about how to use Blueprint Interfaces to
communicate between blueprints. Now with a Blueprint Interface, you can create a collection
of empty functions. Then you can assign which blueprints have
access to those functions. Then those Blueprint
Interface functions, which can now be found
inside of those blueprints, can be given unique
functionality. Now this is great for a generic type
functions where do you might interact with something? And then depending
on the Blueprint that you've interacted with, they might respond differently. So we're starting off
with a graphic here. So we're going to
create a blueprint. Inside of our
Blueprint Interface, we're going to create a
function called interact. And then we're
going to implement this Blueprint Interface in three different blueprints
are blueprint light, our blueprint boss in our
ThirdPersonCharacter. Now, inside each of those
three different blueprints, we're going to get to customize exactly what interact does. Alright, back here in unreal, There's a lots to take care of. So let's get started. I'm within my scripting
Blueprints folder. Let's right-click in
some empty space. In here, I'm going to
call under Blueprints in, in the little fly-out menu, I'm going to choose
Blueprint Interface. We're going to name this
BPI underscore functions. Then we're going
to double-click on this guy to open it up. Now, inside of here, all you see is just empty graphs tab it says new function. And then the upper right
under the My Blueprint tab, it's waiting for us to
give this function a name. So let's create our
very first function and it'll be called interact. Down in the Details
panel you can see it also changed the name of this
tab over here to interact. And we're going to change
the output here to add one. We're going to create
one output and it's simply going to be called interacted with question mark. And we will leave
it be a Boolean. So this is our empty function. It's simply has one output. Now, note, you cannot do
the following from here. You cannot add any
new variables, just inputs and outputs. You cannot edit
the graph at all. You can't like movies around or tick that box
or anything like that. You cannot add components. This function isn't
set up to do anything. The idea here is that
this empty function gets added inside of other blueprints and then inside of
those other blueprints, we can customize what it does. So let's now add this
Blueprint Interface to other blueprints. Let's compile this
first and save. Then heading back
to a level editor. We're going to open up
our ThirdPersonCharacter. We're going to come back
under our blueprint section and we're going to
open up our bp light. And then we're going to
also open up our bp boss. Although those BP boss
MBP light were created in other videos right inside
of each of these blueprints, we need to add that
Blueprint Interface, and this is done under the
Class Settings button. So I'm going to start
with my BP boss right up here, Class Settings. And then over in
the Details panel, Here's where we can add the Blueprint
Interface and clicking right here in this
drop-down under add, there is our BPI functions. We're going to add
that BP light. We're gonna do the same class
settings, add bp functions. And then under our
ThirdPersonCharacter, same thing. Class Settings,
add bp functions. Now, if you weren't paying very close attention and
it's easy to miss this upon adding this Blueprint
Interface over in the My Blueprint section of
each of these blueprints, we now have an
interfaces section underneath the My
Blueprint panel. And if I open this up, we can see that we now
have access to interact. If I double-click on our
Interact function right here, will open up a function tab. And so now you can
see we can add unique functionality for
each interact function in each of these three
different blueprints. So let's start off with
our boss blueprint here, we have double-clicked on
our Interact function here. Let's give this some
unique functionality. We're going to say if we
call this interact function, all we're going to
do for our boss is we're going to
drag off of here. And I'm gonna say
destroy the actor. And then we'll just check
this box saying yes, we did interact with them, compile and save that. We're going to move on to our bp light next
in inside of here, we're going to simply grab our spotlight component,
click and drag. To drag off of this,
we're going to type in set visibility. We're going to wire our execution
wire through like this. And we will set our
visibility to true. And we'll also check this box for interactor interacted with. Let's compile and save that. And then we'll jump onto
our ThirdPersonCharacter and we'll add some unique
functionality in here. All we're gonna do is right-click
in some empty space and say get actor, location. And we're going to
use this location to spawn and emitter. So dragging off of here, I'm going to type in spawn
emitter at location. You could spawn system
at location as well. System uses the
Niagara particles. This is the older cascade
particles either will do. I'm going to plug this in here, and I will spawn
in an explosion. Because explosions
are always fun. I'm going to set the
scale to be nice and big. So 22. And so, and I will also check this box to say
yes, we have interacted. So we've now set up some unique functionality
under each of these three blueprints for when we call this
interact function. Let's go ahead and
compile and save this. Let's head on over to
our event graph here. And earlier in the course, we set up this line
trace functionality. So if you don't have
this already created, you can copy what you see here. We're sending out a line
trace into the world. And currently when
we hit an actor, we're just printing out the name of that actor to the screen. We're going to modify
this a little bit. So I'm going to delete out
these nodes right here. We'll get rid of this
branch node here. I will bring another
one in momentarily. But what you need to do
is out of this Hit Actor, you can drag out of your outfit and break this hit result, expand this down out
of our Hit Actor. We're going to search
for inter act. And in parentheses it
should say message. Hook this in like so. Now this is going to call the Interact function
inside of the Hit Actor. If that Hit Actor does in fact implement the
Blueprint Interface. If the hit actor does not implement the
Blueprint Interface, then nothing happens
to that actor. So what we're gonna do
next is we're going to drag off of our interacted
with output here. I'm going to bring
in a branch node. And we're going to simply
say that if this is true, we have interacted
with something and it did evaluate to true, we're simply going to
print out to the screen. Let's print out interacted with Thing number inside of our Interact function in
our ThirdPersonCharacter. We're setting that to true. Here we're spawning and
explosion inside of our lights. When we interact with this,
we're just going to turn on the spotlight and
we're going to say Yelp, you've interacted with it. Inside of our boss.
They interact function. We're simply going to
destroy the actor. And we said, yep, we've
interacted with it. One more thing here, we
need to set up inside of our boss in order
to actually have that visibility trace whips the visibility trace here inside of our
ThirdPersonCharacter. In order for this to actually
interact with the boss, come inside of your boss and select your
capsule collision. We just need to change up the collision settings
a little bit. Under the collision
Component, Collision section. Under the collision preset, we're going to change
this to be custom. And we've got to make sure that the Visibility channel
is set to block in order for our line trace here in the ThirdPersonCharacter
to actually hit it. Let's compile and save that. Alright, so back here in our ThirdPersonCharacter
Blueprint, we're going to be
pressing the arrow key to send out a line trace along the Visibility channel starting from our
actors location, the ThirdPersonCharacter
ending with our line trace endpoint, which if I go to the viewport, that is this point that we set up right here
earlier in the course. We're then going to
break out our hit for any actor that we do hit, we're going to call the
Interact function that lives within our BPI functions
Blueprint Interface. If the thing that we hit has implemented that
Blueprint Interface, it will call that interact
function and in fact perform whatever we set up that function to
do in our bp boss, it'll destroy the actor and say, Yep, we have interacted with it. It'll tick that Bool
in our bp light. We're going to
toggle the spotlight on and then also tick
that Boole to say, yep, we've interacted with it. If however, the
thing we hit has not implemented This
Blueprint Interface, nothing will happen,
which is fine. Now, if we have
hit something that has implemented this
interact function, this Blueprint Interface, we're going to pass that
Boolean along here. And if it's true, we're going to simply print that
out to the screen. Alright, back here
in our level editor, make sure you've got a BP
boss placed in your level as well as a BP light that
is about ground floor. We're gonna go ahead
and jump in and play and pressing the zero key. Once we are in front
of our light there, we should see some texts
appear right here. So zero key. You see that light, you see
that interacted with thing. Great, that works just fine. And we're going to shoot it out. And our boss character here you should see
some texts appear, as well as our boss
being destroyed. Here we go. Zero
key, boss has gone. You see our line being shot out into the
world there as well. There was the impact point
and that is indeed working. Alright, a little
bit of nuance to discuss here as it
pertains to calling a Blueprint Interface
functions back here in our ThirdPersonCharacter
you saw me earlier, drag off of our Hit Actor here and type in the
word interact and we see interact message and we got that envelope version
of it right here. This is identical to that. Now this signals
the supplied target right here to call
that function. However, something to note about this, calling
that function, you don't actually
have to implement the Blueprint Interface
itself within this blueprint to
be able to do this, what I'm talking about is
here in our class settings. You can see within this
blueprint, I have implemented. The interface is you don't
have to have this implemented in order to call this for
the supply to Target. And just to help drive
home that point, I'm going to jump back
to my level editor here. I'm going to place my BP
button out in my level. With this selected. We created this in
an earlier lesson. I'm going to slot my lights
here to be this light. So I'm going to choose
this little eyedropper. And I'm going to choose
this light right here so that BP Li2 is now associated with that variable
inside of our B P button. I'm going to open this
up now, RSVP button. And I'm just going to
modify this bit of script right down here
when I press the I key, when I'm within range. So I'm going to go like this, just going to not worry about this toggling of the
material at all. I'm going to break
this, holding down the Alt key and left clicking. What I can do right
now is right-click. And if I search for a message, not message, I'm looking for interact. That's what I meant. Interact. There's my B PI functions
interact message. So I can call it for this
light target right here. Because remember, my BP
light does do something, or BP light does have this function implemented and it will toggle the visibility. But no, it's, what
I'm talking about here is in my class settings, I don't have the BPI function's
interface implemented. That does not prohibit me
from calling this function. So just to further
drive home the point, what I'm gonna do here
is play the game. And I'm going to overlap
this button right here. I've now overlapped it. I see that actually saying, yes, I am within
range right now. That Texas backwards,
but never mind. I'm going to press the I key now is going to call this function. In my light blueprints. Here we go, pressing the I key, and it does in fact call that function and
turns on that light. Now note, when I search for that interact function here by right-clicking and
I type in interact, that is the only
option that I get. However, back in my BP
ThirdPersonCharacter where I do, I do have the BPI functions Blueprint
Interface implemented. I can right-click
in some empty space and I type in inter act. I have another version that says call function right up here. And now look at this version. This is a local function call. Now, I could set up
something like this here inside of my
ThirdPersonCharacter Blueprint. Let me just delete this out. That function that I
just deleted it out is identical to me, left clicking,
dragging and dropping my interact function right
over here into my graph. So either way you'll
bring in a copy of that local
version of the call. So for this setup right here, I'm going to press the nine key. This is going to call interact
on the target of self. My ThirdPersonCharacter
Blueprint. I'm just passing
along that Boolean and then we're going
to destroy ourselves. So if you remember here
in our local function, we're simply going to spawn an emitter at our
characters location. Compile save. Let me go back to my event
graph here and play. Set my debug object to my self. And now when I press the Nike, boom, it does in fact call
that interact function. So in order to call a local
version of that function, the Blueprint Interface does need to be added
to the blueprints in order to respond to that version of the
interface call.
93. Blueprint Interfaces (Part #2): Alright, still more to show here related to Blueprint Interfaces. So let's dive back into our BPI functions and
we're going to add a brand new function up in
the My Blueprint panel. So click Add Function
and we're going to name this damage. And we're not going to add
any inputs or outputs. We're simply going to
compile this and save. Now let's dive back into
one of our blueprints where we have implemented this Blueprint
Interface already. I'll go into my
ThirdPersonCharacter Blueprint. Now, note over in the
interfaces section, we now see our damaged
function appear. However, it shows up
in this yellow color. Now this color means that
the function has been added, but it cannot be
called inside of other blueprints since
it has no return value. And by that I mean, let's go
back in our BPI functions. It has no return value, whereas I select our
Interact function, it does have a return
value, return a node. So that's fine. No big deal. Here in our damage function, we're gonna go without any
inputs, without any outputs. We're going to
leave it just like this and we're going
to show how to use Blueprint Interfaces in a
slightly different manner. Here in my ThirdPersonCharacter
Blueprint. Remember I do have our
Blueprint Interfaces implemented and there
is a damage function. Now if I try to
add it to a graph, it's gonna be like
Nope, can't do it. However, if I
right-click on this, I can implement
this as n events. So watch what happens
when I do this. It'll add this as an
events to my graph. And now I can make some functionality
happened off of this. However, I have to make
sure that I actually call this events from
some other blueprints. So let's do this here inside of my ThirdPersonCharacter
Blueprint, I'll say, okay, whenever we call this, we're simply going to
destroy our character, Destroy Actor that's
simple enough. Compile and save that. Now from another blueprint, we need to actually call
for this to happen. So let's jump into say
are BP example pickup. I will double-click on that. And I'm just going to hijack the original functionality of this just for the time being, I'll set it back
after the video. I'm going to say
that when we begin overlapping this
sphere right here, we're going to check if fits
the third-person character. And then off of this, I'm simply going to
drag off of it and type in damage that BPI functions. Damage message. We're going to go like
this and like this. And I will get rid of these just to make this
a little bit more clear. So here's what we're doing. Inside of our bp example pickup. We're checking to see if
we've overlapped that sphere, this sphere collision with
the ThirdPersonCharacter. And if we are,
we're going to call for that damage
Blueprint Interface. Now, events to occur here inside of our
third-person character. So let's go ahead and
try this clicking play. And I forgot to add
that to our level. Let's add one of these. And so the moment we
touched that we should die, BAM, and we do. So that's another
way that you can use a Blueprint Interfaces
instead of implementing them and then adding some functionality
for each function, like we did with our
interactive event. We can simply leave them in our Blueprint Interface
without any inputs or outputs. And then do like we did in
our ThirdPersonCharacter, where we right-clicked
on it and we converted it to an event. Then in doing so, you can
do anything off of it, so long as you call that event from some
other blueprints. Now, this is kind of kind
of a way of calling out a custom event in any other blueprints that
implements this interface, right, Last but not least, we're going to talk about how to use a Blueprint Interface to communicate with a
Level Blueprint. Now, it is best to add a
Blueprint Interface to a sub level for easier
communication with the level. Let's get to a demonstration. First of all, let's
make sure you've got the level tab open over here. If you don't already have
that up in your editor, you can get that by coming under window and then opening
up the levels TAM. And earlier in the course
we did create a sub-level. I'll go ahead and create a another sub-level just so you can see how it's
done once again, right here where it says levels, you can go here and
you can create new. And it will prompt you to
create a new sublevel. I will choose an empty level. Create. It's going to ask us where do we
want to save this? Let's put this in our
scripting levels holder, and I will simply call this
sub-level underscore 02. We're going to save this out. Alright, I'm going
to right-click on our sub-level to here. I'm going to change
the streaming method. To be always loaded
instead of Blueprint, change it to always loaded. Then with our
sub-level right here, I'm going to click
right there to open R sub level Level Blueprint. And inside of our
sub-level Level Blueprint, I've got our class
settings right up here. And once again,
here is where I can implement our
Blueprint Interface. So I'm going to click Add. There's my BPI functions. Alright, next back
in our level editor, you can make sure that this is the current level by
checking right here. Level sublevel two,
that's our current level. If we click off of
it, that blue also shows that it is our
current working level. We're going to add an actor
to our sub-level here. I'm going to add, Let's
go under it right here. Let's add a shape. Let's do a cylinder. Sure, something like that. So we've got an actor
in our sub-level. We can view this by clicking
this eyeball icon off on to show that that is in
fact a part of sublevel two. And then we're going
to make sure we've got our cylinder selected
and we're going to head back into R sub level
two level blueprint. We're going to go into our
Interact function here. Double-click on
that to open it up. Hold down the R key, left-click to bring in a
reference to our cylinder there. And we're going to drag
off of here and type in Destroy Actor legs. So we will say then that yes
we have interacted with it. That's great. Compile and save this. Then we're going to dive back into our ThirdPersonCharacter
Blueprint. And what we're gonna do is
set up a very simple scripts. We're just gonna go right click, I don't know the eight key. I don't think we've got anything going off the eight
key currently. And I'm going to right-click then in some empty
space and typing and get streaming level. And here's where
we want to put in the exact name of
our sub-level O2. There it is right there. Sub underscore a
level, underscore 02. Then we can drag off of this and type in inter act
message like so. This will allow us to communicate with our
sub-level two and call that interact function that we set up inside of Sublime too. So that's going to kill
out that cylinder. Now, I'm actually
not going to be doing anything off the bools. I didn't actually have to
check that box, but I did. So let's go ahead
and compile this. Let's go ahead and play. And now when I press
the eight key, bam, it is gone. We have in fact communicated via Blueprint Interfaces
with our sub-level too. Well guys, that
is going to do to offer a Blueprint Interfaces. Once again, with
Blueprint Interfaces, you can set up a
functions inside of them. You can then add them to blueprints via the
Class Settings. And then once you do, you can set up
functionality inside of them that is
unique to wherever you have added these
Blueprint Interfaces quite handy into you guys that is gonna do it
all for this one. See you in the next one.
94. Parent (Base) Class: Welcome. In this video, our goal is
to initiate a conversation around the concept of
inheritance in blueprints. Now to truly demonstrate the power of inheritance
with blueprints, we're going to create
a parent class, a base class upon which other future blueprints
will derive. Now what this
ultimately means is that any blueprint we create as a child of this parent come pre-built with
all the components, all the functionality in variables that the
parent already has. Now, if you've ever
created a blueprint class, you've already used inheritance and may not have even realized that no blueprint
in unreal exists without inheriting
from something else. As an example of what I
just mentioned there, check out our
ThirdPersonCharacter Blueprint. If we open that guy up
in the far upper right, it lets us know what
the parent class was. In this case, our bp
ThirdPersonCharacter inherited from the character class are BP example pickup that we created at the very
outset of the class. The parent class
for that is actor. This is made even a little bit more clear if I come back to our content browser and I right-click choose
Blueprint Class. Down below, where it's asking
us to pick a parent class, you can see the hierarchy
of different blueprints. Object is the most base class
actor inherits from object. And if I expand out actor under here I can
see something like our bp example pickup that inherits from the parent class. Alright, so what we're
gonna do in this video is create our parent,
our base class. And then in the next video
we're going to create a child class that is based
off of our parent class. And you're going to
see how our child inherits all the properties of the parent just as
you are a child and inherited some properties
from your parents. So too will our
child class inherit from our parent class? Let's go ahead and right-click
and some empty space here. I'm gonna do this inside of my scripting Blueprints folder. Right-click Blueprint class. We will base this off of the
actor or a parent class. And I'm going to name
this my BP underscore. Parents pickup, like so. And I will double-click on
this guy to open it up. And I'm going to add
some components. So we're going to start
off by adding some sphere. Sphere collision. Will set the details here. After this with our sphere
collision selected, I'm going to add a static mesh source Static Mesh is attached
to our sphere. And then with our
static meshes selected, I am going to add, I'm going to type in Niagara. I want to add it in
Niagara particle system components like so. We're gonna, we're gonna add some Niagara particles
here in just a little bit. And we're also going to add a rotating movement
components as well as interpret Too
movement components. So our, our blueprint
here is going to both rotate as well
as bob up and down. So that'll be pretty cool. Alright, let's set
some details here. So selecting our sphere, first and foremost, come
over to your details panel. We're going to set our
sphere radius to be 100, something nice and big. You know, scrolling back
here are static mesh. I'm going to come under the
Details panel and I will choose 1M underscore cube. Let's just do any cube
mesh that on will be fine. Something 50 by 50 by 50. Sure, that's a little bit small, so I'll scale that up to
maybe double the size there. To actually, let me set this
back by lock our scale here. I can set that to be
two and hitting Enter, it'll scale it up accordingly
in the x, y, and z. Next, I'm going to choose
our Niagara component here. Now, I did, prior to this video, I did make sure that I had some Niagara particles
added to my project. And I'm gonna show you
where you can add these, because this can take
a little bit of time. Down here in the
Epic Games launcher, if you come under
Unreal marketplace, I simply came under
the free section here. And I did a search for Niagara. And in here, I chose these
base pickup VFX set. Now to add this to your project, you can click right here. Eventually you'll get this
Add to Project option. You can click right here. Now, I've already got
this added to my project, so I'm not going to re-add it, but you can select your project. If your project
does not show up, you can click this button to
ensure that it does show up. Then you would click here
to add to your project. Now I can take a little
while to be added. Once it has been added, I'm just going to
minuses once again back here on our
content browser. It'll show up as this folder essay underscore
pickups set, et cetera. And right here in my directory, right here as a pickups
FX nagger system. This is where we can find some
Niagara particle effects. This is the newer particle
system in Unreal, using Unreal Engine five. Alright, going back
to our parent pickup, Let's select our negra
particle system here. And where it says
Niagara system, I am going to slot in
one called energy. And I'll do this NS
energy underscore two. Next, I'll select our
interp2 movement component. There's our particle coming in. And I will set a couple
of control points here, clicking the plus
button once and twice, and I'll expand
each of these out. I'm going to leave the index
is zero at that location, index1, I'm simply going to have it bob up in the
z-direction by 20. And then I will also set
our behavior type here to be ping-pong so that it goes back and forth between
those two points. Now, our rotating
movement already has a rotation rate of 180 in the z. So if I was to simulate this, you can see what this
is going to look like. Spin around. Particles are attached
to our cube there. That is so lovely. Alright, Next I'm going to add
three variables down here, which will be eventually
inherited by our child. So I'm gonna click under the My Blueprint
variables section, the Plus button right here. The first one is gonna
be called pickup S FX. And we're going to change
the type here to be sound bass sound basis to search for that sound
base object reference. We'll set these all
a little bit later. I'm going to click
the Plus button. We're going to add another
one, this we call pickup VFX. I'm going to set the type
here to be egg garage system, that Agora system
object reference. And we're going to add
one more variable here. And this one will be
called item name. And we're going to change the
type here to be a string. Alright, compiling, we can then set some default
values for all these. So my itemName going to set the default value
to be item name. For our pickup v effects, I'm going to slot in coin Burst, that is a Niagara system. And for my pickup S of x, I am going to choose
one called objects. Object pickup. This is in the engine contents. If you don't see
that, you can click this gear icon and
right there you can turn on your engine contents so that you can find
that object pickup. That's what I'm
going to go with. You can swap in any sounds or a particle effects you want. Those will be my defaults. Alright? With that, I'm going
to compile and save right away and then head on over to my event
graph where we're going to do a little
bit of scripting. First things first we're
going to left-click drag around these three event nodes that are already
here by default, we're going to delete them out. We're going to right-click on our sphere collision component,
right-click Add event. We're gonna do something when
we begin overlapping that. So we're going to add
that to our graph. And as you may have
guessed for going to drag out of our other actor and see if it was the
ThirdPersonCharacter that did the overlapping. If it was, we're going
to play sound, 2D. What sound do you want to play? Well, we've got a pick-up
sound right here. We're going to just drag
and drop that on the pin. Moving on down. Next we're going to drag
off of here and we will do spawn system at location, spawn system that location
under the Niagara section, spawn system is where you
can spawn Niagara VFX. We already have one saved
in a variable right here. So let's drag and drop this on top of the system template. Let's feed this a location. So let's right-click. Get our actors location. Which actor? This BP parent pickup, wherever this is
going to be located, that'll be the location
where we want to spawn this. Then we're going to drag off
of this and print string. What string do we
want to print in? Well, we're going to drag
backwards off of this, bring in an append node. And four are a, we're going to type
in got colon space. For the b. We're going to slot
in our item name. So drag and drop that on here. We're going to add one more pin. And I will do a space
exclamation points. So this should read got colon, space, item name, space,
exclamation point. It's both, they don't
really need these spacer between the name and
the exclamation point. So I'm going to backspace there. And then last but not least, we're going to drag off
of this and we're going to destroy the actor. So that is going
to be our script. If you want to pause the video right there
and get a good look. See, alright, next, just to simplify our graph
here a little bit, I'm going to left-click
and drag around all of these nodes except
for our event. And then if you
right-click on any of your selected
nodes right here, I can right-click on them and
I can collapse to function. When I do this is gonna
be crunched down to a single node and right over in the My Blueprint panel
under the functions area, it's going to say,
okay, name this thing. I'm going to simply call
this function pickup. Like so. If I double-click
on this function, you can see what it looks
like on the inside here. And that's great. We've now got a very
simplified event graph. Let's go ahead and
compile and save. I'm going to place one of
these down in my level. And let's just give this a quick play test to make sure that we can in
fact collect this. So dragging and dropping
this red in here. Let's go ahead and play. And away. We go There it is. Little burst of particles
of air as well. Alright, We're off to
a great start here. And in the next video we're
going to create a child of this blueprint and
that child will inherit all of the components. The variables is the
functionalities of this parent. Now this is a great way to
go about working in unreal, because if you think about it, there are many
things in games that are similar to one another, such as pickups, weapons,
enemy types, etc. They all share some
common things about them. So why recreate the
wheel again and again? Why create a unique blueprint for every single blueprint pickup that you're
going to have. It's best to work by
creating a parent class. It's going to have a lot of the base functionality that say all pickups
are going to have. Then in each of the children
script functionality, add some components as some variables or
properties that are specific to each and
every individual pickup. But the shared
functionality should go within a parent blueprint. Alright guys, that is
gonna do offer this one. We will see you in the next one.
95. Child Class (Part #1): Welcome. In this video, our goal
is to show how to create Child Blueprint Classes and then how to customize
from there. Now creating child blueprints is awesome from the standpoint
of not having to recreate the wheel by having a child class blueprints inherit all of the
base components, variables, and functions
from a parent. We do not have to recreate
all of that in the child. Instead, we can now customize each child blueprint
as we see fit. Additionally, if there's
some added component, variable or
functionality that we want to retroactively
add to the parent. All child class blueprints
will gain that automatically, which is pretty sweet. Alright, so let's start
showing some of this off by first creating a child class. So here's my BP parent pickup. I'm going to
right-click on this. And to create a child from
any existing blueprints, simply right-click on it and the topmost option,
there you go. Create Child Blueprint class. It's going to prompt
us to give it a name. So I'm gonna change
this to be BP. Child pick up. Then I'm going to double-click
on this guy to open it up. Now, take a look here. So here's my child pickup. I have my parent pickup open right up along
the top here as well. And if I toggle between the two, you can see that
they look identical. You'll also note that
the parent pickup has this listing of components. And notice that in
our child we have that exact same
listing of components. Now in the parent pickup, we've got these variables
right down here. In the child pickup. We have these variables
right down here. And if you do not see these variables right down
here that were inherited, you can click on this little
gear icon and makes sure that show inherited
variables is ticked on. You must have that ticked on in order for those inherited
variables to show. Because if you tick them off, they go bye-bye, shown
inherited variables. And there you go. Now a couple of things
to take note of here. If you look in the upper right, it says our parent class
is the BP parent pickup. And also over in the
list of components, if you wanted to edit
any of these things, say you wanted to change out this sphere component
if you clicked right here in edit in Blueprint, note what happens here. It actually jumps you back
to your parent pickup. So in the child where you see all of these
right over here, if you click on any of them, it's going to jump back over
to the parent, be like, Hey, you want to edit this
here in your child, while the place to actually
do that is in the parents, because any changes that you
make here in the parent, they will propagate
down to the child. Now, just to drive home
that point really quickly, I'm going to add
a temporary light here in my parent pickup. So I'm going to come under, Add I'm going to type in light. We'll add a point light shore. I'll leave it at that name. Now, if I go to the
child pickup right now, you don't see it. However, if I go to my parent pick-up and then click Compile, save it, and go
back to my child. Boom, there is that
point-like component and that would be right now buried on the
inside of my cube there. So there's where it
actually resides. I'm going to delete that because I don't actually want it. So if I did want to delete
this out of say the child, I could delete it out here. Nope. Can't do it. Right.
Because you're trying to do it, but it's like, No, I'm inheriting
this from the parents. So you gotta go
Edit and Blueprint, deleted out here, then
Compile and Save. And that change will be
propagated on down to your child. Now once again, what
makes working in this fashion so awesome is
with our parent pickup, we created the
base functionality for picking up this pickup. Simple overlap here in
our event graph, right? And when we overlap it, we simply do this
functionality right here. We don't have to recreate all this inner child and
we can demonstrate this by dragging and dropping
this guy level. So I've got the
parents on the left. I'll make the parent
a little bit taller, the child on the right. And if I jump in and play, you can see that I
can pick up one. I can pick up the other. That functionality does indeed trickled on down to our child. But what makes us also great is that we can make
some changes in our child while keeping
that same functionality. So let me just do some
very superficial changes here in our child. I'm going to change some
of our components here, not the components themselves, but the actual properties
of the components. So e.g. I. Could select my Static Mesh Component and change it to be something
other than a cube. I could change this to be, let's go a cone, some cone shape and he
cone shape will do. I'll just shrink that down to be one all across the board there. Yell to sync that
down a little bit. I could change out
the particle effects from my lightning
bolts here to be something like We'll do the healing something
with some hearts. Sure. Let's do healing three
maybe something like that. Rotating movements. I can change that out as well. Yeah, once you change out
your Niagara system here, it's going to take a
little while to swap out. Actually, I don't
like that one because that's kind of a
fire and forget one. Let's try healing wants
something persistent like that. Interpreter movement. I can change this as well. In this case, we're going to
change out the duration from one seconds to 3 s. So it's going to take
longer for it to go from. Position zero here
to position one. I can change out my
rotating movements. I can change out the speed
at which it rotates. So I'm gonna make this one
spin a little bit faster here. We'll say 200,
something like that. And I can change my pick-up sound effects does not have
to remain this object pickup. I'm gonna change that
to be floating view. I close any option here we'll do just try
something different. My pickup VFX does not have
to stay the same there. I could change this out from
coin Burst to coin Burst O2. And my item name does not
have to stay the same. Instead of item name
as an item name, I'm going to change
this to be health back. Alright, so with all
those changes done, I can go back and save. Let's try this out. You can see that it
looks visibly different. Different particle effect. It will have a different
particle effect when we pick it up as well, look like that
particle effect goes away pretty quickly
here, but here we go. The parent, the child. Different particle effect,
different sound, etc. Alright, this is
all well and good in that our child has indeed inherited the functionality and the beginning components
of our parent. We just simply swapped out some of the superficial elements. Our child here,
that is the look in some of the sounds and that
sort of thing, the variables. But let's extend
our functionality in the child a
little bit further. Let's make it so that
while we haven't inherited all this stuff and
that's all well and good. We want to take our child
a little bit further. We wanna do something specific
to our child pickup here. So we're going to start off in our ThirdPersonCharacter
Blueprint. Going to go into third-person
blueprints that are Person, Character, and our
health function. We created this
earlier in the course. We created a modify
health function and it looks like this. We're going to drag this
out into our event graph. I'm going to right-click
bringing a custom event. I'm going to call this
health child pickup. I'm going to plug
this into our modify health function that we created. Again in earlier video, we talked about
creating functions in our health child
pickup custom event. I'm going to add one input here, clicking this plus button. I'm going to name this health. I'm gonna change the type
from boolean to float. And I'm going to
plug this right away into our function
for modify health so that we pass along this health
value into our function. We're going to pass
something into this in our child pickups. You'll see that here
in a little bit. Then what I'm gonna
do is I am going to bring in a print string here. Then I'm going to
drag backwards off my print string and
bring in an append node. And I am going to have my
a value here is simply say health colon space. And our b value is going
to be the current health that we're going to have
after we do this calculation, dragging this in like so it's simply going to bring
in a conversion node, converting a float to a string. So our modify health function
currently looks like this. If I double-click on it, you can see what it's doing right there. We're playing different
sounds depending on the health value
being passed in. We're clapping that
health value as well. But that's essentially
what we've got going on. Let's compile this very
important that you compile and save this. And it's important that
you compile so that we can actually call for
this function or this up rather custom events to occur from our child pickup. Alright, so all of this done in your
ThirdPersonCharacter Blueprint, head on back to
your child pickup. Now, inside of here, if you search around
your event graph, you're like, I don't, I don't see any of
this functionality back here in our parent. We are doing some scripting
right here, like so. And I know we created
this function, this pickup function here
inside of my parents. And it looks like that, but if I go into my child, I don't see any of that. Well, here in our functions section of the My
Blueprint panel, if you come right down here, you can override your
pickup function that currently exists inside
of your BP parent pickup. So if we click on this, we will now see that pickup function that we
created inside of our parent. And this is what it looks
like inside of our parent, inside of our child. It looks like this where
we're simply making a call over on over to our parent
pickup saying like, yep, that is the function
that we want to execute. Now, I can extend this
out even further. What I'm gonna do here is
right-click and some empty space type in, get
player character. Cast to ThirdPersonCharacter,
like so. Now because we created that custom event inside of
our ThirdPersonCharacter, and you are sure to
Compile and Save. We're going to make a call to this custom event
health child pickup. So in our child pickup, I can now drag out
of here and type in health child pickup. And this will make
the call on over to our ThirdPersonCharacter
Blueprint to execute this. Now, back here in
our child pickup, we do need to pass along some
health that we would like to pass in to either heel or
we could hurt our character. I'm just going to
hard set something however you could
right-click on this. You could promote this to a
variable or a local variable. A local variable would only be seen by this
function right here. I'm just going to put in
points to five right here. I will compile this as well. And let me go back to my ThirdPersonCharacter
Blueprint and just make sure that
our health right now, it's currently set to 100%. So I'm going to set
this down to be 50%. And just as a quick play tests, I want to make sure that
our health meter is in fact showing 50% health. Alright, so with this all done, we can actually
jump in and play. I could have just
tested it there but wasn't thinking straight. So notice my health
right ear is at 50%. This should heal it
up to about there on the health meter because that is what we're
instructing it to do. And here we go. We did indeed increase
our health 2.75. And you saw that string
passed along as well. So you saw here inside
of my child pickup, I simply extended that
functionality that we were already inheriting
from the parent. The parent pickup already
had script in it right here. So when we overlap that sphere, we're going to call
for that function, this pickup function
inside of the parents. So our child is going to
be inheriting all of this. And our child is also going
to be extending it by here. We're making this
call on over to the custom event inside of
our ThirdPersonCharacter. Something else worth
noting here is that when we did pick up our child here, notice in the upper left
it said Got Health pack. And the reason is
saying God health pack is because here in
our child pickup, we change the item name
to be health pack. And if you recall, inside of the parent
pickup function that we created
right here is where we are saying got item name
and then exclamation point. So let's respecting all of this. It is calling this pickup
function inside of our parent. But it's also respecting the variable names that we have changed here in
our child pickup, namely is not saying item name anymore in
our child pickup, we said nope, it's now
going to say health pack.
96. Child Class (Part #2): Alright, in part number
two here we're going to be discussing some of
the finer bits of nuances that you may
come across when working with parent and
child class blueprints, some things that you
should know about. So let's assume that you create a parent pickup like we've done. And let's just say we've
added this rotating, moving components like
we've done and we want to make it so that any children of this blueprint obey
this rotation rate of one atm that
there's no chance we want to have no way of the child class blueprints
deviating from this value. We want to lock them
out so to speak. Well, we can do here
is we can uncheck this editable when
inherited checkbox. And you're going to
find this checkbox on all of our different
components right here. What happens is when you
uncheck this and I will, I'm going to uncheck it. And then I'm going to compile
this once again and save. Now if I go into
my child pickup, It's going to inherit all of these values because I
just compiled and say that those changes will
propagate on down to the child once make some
edits in your parent. So our rotation rate is 180. Our child pickup will now
have that same rotation rate, rotating movement of 180. But check this out. I can't change any of the
properties right here. In fact, along the top it says components flag is not
editable when inherited. That is this
checkbox right here. When inherited must be edited
in the parent blueprints. So it's letting me know, hey, you can't change this here. You'd have to go back to
your pair blueprints. If you click right here, it's
sent me back to my parents. I could click this
box right now. And once I click that box, I can head on back
to my child and oh, I can't change it yet anymore. However, if I go
back to my parents, compile, then head on back, then I can change it once again. So that is something you should definitely, definitely
know about. Something else to note here
is that just because you have a property set in your details panel for
a given component, that does not mean that
that's going to be the actual property value
obeyed in the game. Now let me show
you an example of exactly what I mean by that. I'm going to change my
child pickup here to have a rotation
rate of simply ten. Okay? Rotation rate here of ten. And the parents with the rotating movement
components selected. I'm going to change
it here to well, actually I'll leave it at 180. So you might think OK,
parent hazard at 180, child has it at ten. However, if in my parent pickup in the Event Graph wanted to do something on
Event Begin Play. I'm going to hold
down the P key, left-click bringing
Event Begin Play. And then I bring into
my rotating movement in components so that I can
talk to this in some way. And I say with this rotating movement
components selected, I'm going to drag
out and I'm going to alter this property
rotation rate. So dragging out of
that rotation rate, I'm going to set
the rotation rate. And I'll say we're going
to set it to be 1,000. So note what I've
got going on here. The rotating movement component, I had it set to 180. But upon beginning play, I am changing that
value to be 1,000. Here in my child pickup. I have it to be ten, you may say, okay, it's
gonna be ten for this. But remember, the
child is going to inherit all of the functionality
setup in the parent. And the parent right
now is saying, hey, as soon as we began play, you're going to change you're
rotating movement to 1,000. So the child is going to
respect that as well. So if I jump back here
in my level test map, and actually a cone
is a really poor mesh to see that rotation rate, I'm going to swap that
cone out really quickly, coming back into
child static mesh. Let's do something that we can actually see
rotating around. How about this pipe? We will see rotating around. Alright, so now if I was to simulate that is
to run the game, but not actually
jump in and play. You can see that they're both
spinning around quite fast. Indeed, this one appears
like it's spinning around a little bit faster
because it's got those particles all
dancing around. But indeed they
are both spinning around at quite a rapid rate, the rate that we have
set up in the parent, which is to say 1,000 because our child is certainly not spinning it around
at a rate of ten. Now I think the key takeaway
there is just to be mindful, where you are creating a script. Just remember if you create
any script inside of your parents that is
going to propagate down, that is filtered down
to your child in any children that your
child may have as well. So if you want to have
some functionality that is unique to the child, only scripted within the child, and skip scripting it inside of the parent
because this is going to apply to anybody on
down the lineage chain. That leads into our
next point here. Just as you see this
parent having a child, our Child Blueprint can
also have a descendant. So let's try this out. I'm going to go back to
my content browser here. With our child pickup, I can now right-click
on this and create a child Blueprint class. And I'll call this
BP underscore. We'll call this
grand kid. Pick up. If I double-click on
this to open it up. And let me just
put it right here. So we've got parents,
child grandkids. We can see that the parent
class is the child pickup, but our child pickup has
a parent pickup above it. So check this out. Our grand kid, you would
think that our rotation rate would be the same as our parent pickup because
of what I just described, our parent is going
to override upon play are rotating movement
to be not 181000, the child's going to
respect that as well. And so should our
grandkids, right? Let's go ahead and
give this a try. Places out here. And we should give the grandkids a different mesh here as well, just to drive home the
point that it's different. So I'm going to select these
static mesh here and let's try this quad pyramids,
something like that. And so now if I was
to simulate this, alternatively, Alt plus
S will simulate it. They're all spinning
at the exact same way. It's just a little bit
of a visual trick. This one looks like
it's spinning slower, but they're actually all
spinning at the exact same rate. So whatever we set
up in our parent for script is going to propagate
down to the child, which will propagate on down
to the grandkids as well. Alright, one more concept I
want to demonstrate here, and it has to do with
input overrides. Now I'm gonna go back to
my parent pickup here. Once again, my parent
pickup descends from the actor
class a blueprint. Actor class blueprints
do not process. That is, they do not fire off keyboard input events
by default, however, we can make it so that
they do recognize that is to fire off keyboard
input events if we set them up that way. So I'm gonna go under
my class defaults here. And in the details
section where it says input, auto receive input. I'm going to change this from
disabled to player zero. In doing so, I can now add a keyboard input event or
a controller input event. And it will recognize that. Now we change this here
inside of my parent pickup. If I go to my child pickup, same class defaults, and we
come under the input section. It now also sets that up
as player zeros as well. Same thing in our grandkids, we go under your class defaults. That changes have
been propagated all the way on down the line. That's great. Alright, let's go
back to our parents. And in some empty space here, I'm going to right-click
and let's do something when we do the keyboard. Let's do, let's do the, we'll do the K key
shore the KCI. Alright, off of
pressing the KCI, we're going to print string. And what we're going
to aim to print out is simply going to be parents. And with our K key
selected here, note that over on the right
we have consume input checked as well as override
parent binding checked. Now, what will happen
here when I play, let me just click on
these three dots, will go to new editor window. I'll set my debug option
here to be my parent pickup. Notice that I can pick
any of these three, but I'm going to choose
my parent pickup. Bring on that window. When I press the K
key right up here, I see parent printed
out just onetime. Onetime only. Now you may be saying to
yourself, What the heck, I thought any sort
of scripting changes that you made in apparent that that scripting change is
going to propagate on down to the child and thus the
grandkids as well. So why didn't we only see
this printed out one time? Why didn't we see it
printed out three times as in the parents than the
child and the grandkids. Well, this is functioning
as so because our consume input
here is checked. Now what that means is
that other actors with lower priority won't
handle this function. That means it'll just stop
here and it'll die here. Now note what happens
when I uncheck this consume input checkbox. Let's go ahead and play again. I'm going to press
that KCI and look in the upper left of
our play window here, we see parent printed
out three times. That is because by not
consuming the input here, we are allowing that key, K key to propagate down. That is to function within our child in grandkids
pickup as well. So when consume
input is checked, it'll function just
in the highest level. With that uncheck,
that change will propagate down to
any descendants. Alright, so let's push this
all a little bit further. I'm going to left-click, Copy these nodes right
here, control C. And I'm gonna go inside
of Maya child pickup. And inside of my event graph, I'm just going to hit
Control V to paste those. Now with my K key selected
over in the Details panel, I'm going to say, let's
consume the input right here. And also I'm going to change out my print string and
now to be child. Okay, and let's go ahead
and play tests from here. Now what you'll see
when I press the K key, let me set my child
pick up right here as being the one
that we want to see. When I press the K key. Now, you'll see
child, an only child. Now, something to note here. This is because we've
got our child is set to consume input, meaning the parents
won't register it. Now, this is being greedy. It's saying consume it
here, ignore our parents. That is the one we want to
process this input key for. Now, if we uncheck it here, uncheck consume input here in our bp child pickup
and play once again, going to press that
KCI and now we see parent child child. What is happening here? Well, by not consuming it, we're allowing it to also show to also be used inside
of our parent pickup. Our parent is saying parent here in our child, we're
seeing child. And remember our grandkids
is descending from us, the child as well. So child, child, but
in the parent itself, which is also unchecking,
consuming input. It's saying parents. So that's why we saw the
result that we saw there. Alright, so there you have it. The concept of inheritance shown off in Unreal and the
power that it provides. Here we have
demonstrated that you can create a parent pickup. From that you can
right-click on it and create a child pickup that will inherit all of the
properties and functionality of the parent
inside of the child, you can create custom
functionality. You can customize
some of the variables and also some of the
component properties as well. And then we also showed that you can keep the lineage going. You can right-click on
your child and create a grandchild as well. So these powerful
concepts can be used all throughout your game to simplify various systems that you may want
to incorporate, such as a weapon pickup system, a lot of weapons to pick up. They all may have their
unique properties about them, but the pickup functionality, so to speak, would
remain the same. Guys that'll do it
all for this video. See you in the next one.
97. Framework Overview: All right, welcome everyone. In this video, our goal is
to gain a familiarity and understanding of
what are known as Framework blueprints in Unreal, this is a critical
topic that everyone working in Unreal
should know about. So what are these
framework blueprints? Well, they're high level
blueprints associated with a project that determine
key things about your game, such as the rules of your game. Those kinds of things
are oftentimes contained within a game mode blueprint, or the player in your game, otherwise known as the
character or the pond. Did you control those
sorts of things? So where are these
framework blueprints found? Well, every project
has some by default, and in fact, some have existed up to this
point in the course. Some of you have known about, others you haven't, but this is where we're going to reveal all. So you can find these framework blueprints
right up here in the upper right of your editor under Settings,
project settings. In here, if you select
maps and modes, we've got a default Game Mode. And your default
Game Mode contains all of these blueprints
inside of it. Oftentimes this is collapsed. You can expand this out. So you can see inside of
here we've got a game mode. It Default Pawn Class, a HUD class, player controller. And I would even throw in
the game instance class, which is down here. All of these blueprints
we're talking right here, and these right here, these are known as your
framework blueprints. Now I just showed
you that you could access these within
your project settings, maps, and modes by clicking on this button
right over here. Alternatively, if you
come under edits, you can find your project
settings there as well. You can access maps
and modes and find your framework
blueprints as well. Alternatively, if
you click right here and come under your project
settings right here you can see your what is known
as your game mode blueprint. And then down below
you can see some of those framework blueprints in this section right here as well. Now, each of these different
framework blueprints such as the game mode, a character, a
player controller. Those are all specific
types of blueprints. And we'll see some of those and how to
create those within upcoming videos in this
section of the course. Now, in just this
framework overview video, it is important to
note that while we have some blueprints, some framework blueprints
to be found within our project settings
here, maps and modes. These are our
framework blueprints. These are blueprints
that control things about our project. That is, every level that we
create within our project. It is possible to override these framework blueprints
on a per level basis, on a per mass basis. We can find that by coming
back to our main level editor. If I come under Window and
access my world settings, we can see if I come under the Game Mode section and I click this
drop-down right here. This is where I can override my framework blueprints
for a specific level. They're found in
the world settings. So if in my project settings
I had some framework, blueprints is setup for my project and determine
things like, Well, I'm going to be controlling
the ThirdPersonCharacter throughout that's determined
by my Default Pawn Class. I can actually make
it so that within a specific map with
any specific level, I can set a specific
pond that I want to control just within
that one level that is found in
the world settings. So you can find
that not only under the Window world
settings option. You can also find that right
here, clicking right there. And you can see are your
world settings overriding your game mode right
now we can see that we're not overriding anything. That's what that
alert is right there. Alright, so once again, that is our overview of
frame work blueprints, your framework
blueprints contain these blueprints right here. I would also throw in the
game instances, well, these are all different
blueprints types and they contain key information
about your game, such as the rules determining
the Gamow blueprint, what character you
are controlling, the Pawn Class, et cetera. We're gonna be
exploring those further throughout this
section of the course. We'll see you in the next video.
98. Game Mode (Part #1): In this video, our
goal is to learn about the importance of the Game
Mode blueprint in Unreal, we're going to learn what
it does, how to create one, and how to tell our
project to use this asset. Now, we have had a
game mode blueprint existing in our
project settings since the beginning of
this entire course. Now when we created
this project, we use the third
person template. And within our third-person
Blueprints folder was this BP
third-person game mode. If you come under your
settings, Project Settings, you can see in the
maps and modes section that the
default gateway mode was automatically slotted to be BP, third-person game mode. So there has been one
here the whole time. Now, what is the
Gamow blueprint? Well, it's one of
two main classes which handle info
about the game. The other being the
game state blueprint, which is another framework
blueprint down here. Now game modes are
designed to define and implement the
rules of your game. Some examples include the
number of players allowed, player spawn and respond functionality transitioning between levels,
that sort of thing. Now the game mode
also determines other default classes
use in your game. Now to help drive home
this point right here, I'm gonna go back to
my level editor here and double-click on our
third-person game mode. Now, if you see this, this is what is known as
a data only blueprint. But even here we can see within this
third-person game mode, here are our various other
framework blueprints such as our player
controller class. That's something that we
created earlier in the course. And our Default
Pawn Class are BP, ThirdPersonCharacter inside
of your Gamow blueprint. This is where you actually slot all the rest of your foot,
your framework blueprints. You can do it here or in
your project settings. If you change it in one spot, you change it in the other. Now, just for your information, you can open up what is known as the full blueprint editor by clicking right here
if you ever see that. But even in here, your third-person
game or blueprint, if you have class default
selected up here, right over here is all of your different
framework blueprints. Again, these are associated with your game mode blueprint. Now I just mentioned
earlier that the Gamow blueprint was one of two classes at handle
info about your game, the other being the game state. So the game mode exists
only on the server, whereas the game states
that guy right there. You can find it in
your project settings right there that exists on the server and is
replicated to all clients. Alright, let's create our
very own Gamow blueprint and then set it here in
our project settings. So to do this, I'm gonna go
back to our level editor. Now, earlier in the course
under my scripting folder, I created a folder by
right-clicking here, new folder. I named it Framework. Now actually I created one of our framework
blueprints earlier in the course is player
controller blueprint. I created this during the event. Begin cursor over video. If you want to review that. Although we will be talking about player controller's soon, within this directory
is where I'm gonna be creating a
brand new game mode. So right-click it some empty
space Blueprint class. And right here in our
picked parent class, we can choose a new game mode. It's known as Game Mode base. And it even says that defines
the game being played, its rules, scoring, et cetera. We're going to click on that. I'm going to call this our
bp underscore Game Mode. Then with that created, I'm going to right-click
and save it right away. Control plus S can
save that as well. And I can slot this in, in my project settings. Again, you can access
your project settings here and here. Under maps and modes
are default Game Mode. I'm going to change this
to be my BP game mode. Now note that once I do
this, check this out, it's going to automatically set the rest of my
framework blueprints. Now my ThirdPersonCharacter
is no longer in here. Now I was using that along with my player controller
that I made earlier. So I'm going to want to
set those back in here. So I'm going to close out my third person game mode that
I have open right up here. Close that out. And I'm going to open my
BP gay mode right here. So note that if I change my Default Pawn Class within my BP game mode
that I just created, if I change that back to
BP ThirdPersonCharacter, if I change it here back
in my project settings, under Default Pawn Class, it changed it here as well. Likewise, if I change
my player controller, this is the player controller that I created earlier
in the course. Bp player controller in the event begin
cursor over video. If I change that
here, my project settings, bp player controller. And I go and look inside
of my BP game mode. You can see that that change
is reflected here as well. So you change it in one place, you change it in the other. I'm going to go ahead and
save this out right here. Now note this is not the only place that
I could have edited all this information or even
set my game mode itself, Bacchae by level editor. If I was to click right here under this
Blueprints button, you can see project
settings, game mode. I could create a
game mode from here. I can edit my game
mode from here. And down below I've
got my different game mode classes as well. So I could select e.g. a player controller from here. I could create a player
controller from here. All kinds of options under this Blueprints
button right up here. That's how you can
access your game mode, edit your game, would
create a new one, change any of the
framework blueprints that exists with
inside of it as well. Alright, now for an example, use case of a game
mode blueprints. I'm gonna need a trigger
volume and I've got one over to the side
of my level here. But if you'd like to
get a trigger volume or a Trigger box, same thing. You can click right here. I like to come under
basic Trigger box. Go ahead and drop
it into your level. And then with it selected
in the Details panel, you can set your box extent. I've got 100s across the board. I set the line
thickness to be ten. And then I also under
the rendering section, turned off actor hidden
and games so that I can actually see this
trigger volume. Now inside of my
game old blueprint, I'm going to create a variable. So coming under the
variable section, clicking this plus button, I'm going to call this levels. And over in the Details
panel right up here, I'm gonna change
my variable type, at least the first half
of it to be integer. And then I'm going to click
this little drop-down right next to this because I'm going
to change the type here, the container type to be
a map container type. That's going to allow me to
create a key value pair. If you did not see the video about Map variable containers, this is a good time
to review that now, otherwise I will
continue forward. So our key here
is going to be of integer type R value here is going to be of the name type. I'm going to compile this and I'm going to add two
key value pairs. So the first one
we're going to add is clicking this plus button. And I'm going to set this
first one to be level one. And I'm going to set the
value here to be starter map. And then I'm going to click
the Plus button once more. I'll say level two is
going to be associated with minimal underscore default. Now if these look familiar, these two maps names, that is because back in
our starter contents, maps, I've got two
maps by that name, one starter map, one,
minimal defaults. You'll notice by casing for starter map within my variable there is a
little bit different, but that does not matter. Not for names, not
burning variable types. So that is going to
be all well and good. I am going to compile and save this very important that you
do that for this next step. And next what I'm
gonna do is come back to my level editor here. We've got our Trigger box. Make sure that you have this selected for
our next step here. And coming under our blueprint
button right up here, we're going to click this
open Level Blueprint. Make sure you've got
your trigger box here selected open
Level Blueprint. And we're going to right-click
and some empty space. We're going to add an
event for that trigger box for when we begin
overlapping it, we want to find out if the other actor was our
ThirdPersonCharacter. So Cast to ThirdPersonCharacter, we've done that 1 million times. And if in fact it was our ThirdPersonCharacter
that overlapped us, we want to access some information inside
of our game mode. Now, the way we can do this
is right-click and some empty space and type
in get Game Mode. Now, you might
think, Okay, great. We can now access with
this note right here. Well, why don't I just dragged out of here
and see if I can access this levels variable
that lives inside of here. So let's go ahead
and try that, right? Let's drag out of here
and type in Levels. And I don't see that
variable anywhere in here. Well, that's because we need
to cast to rbp game mode in order to actually access that level variable that
lives inside of it. So let's try this
drug out of here. Cast to BP game mode. That is the Gamow
that we just created. And so if you've got
a setup like this, now you can drag out of your SBP Game Mode
pane right here, type in levels, and
right down here, you can get your levels, your key value pairs. We're gonna do is
drag out of here. I'm going to type in bind. And I'm going to
say that when we begin overlapping that we want to find look number two there while we're talking
about here by me putting in the number two is we want to
access level to right here, and we want to then open up the map name associated
with level two. So we put in number
two right here. And I'm going to drag
out of here and type in open level by name. You can see the output here
is a name variable type, that is this name right
here, minimal defaults. Now, when we overlap
that trigger box, reaching on over to our game
old blueprint and saying, hey, Jay mode, you determine
the rules of our game. And this rule
determines that when I overlap that trigger box, I'm to go to level two. Let's compile this. Let's save. Let's go ahead and play here. Set my debug object. Sure. So you can see that
script firing off as soon as I overlap this. And here we go. There we are minimal defaults. The new level.
99. Game Mode (Part #2): Alright, let's try
another example here. This time we're going to
try responding the player. So for this, I'm
going to start off in my third person
Character Blueprint. Under third-person blueprints,
ThirdPersonCharacter. We're gonna do a little bit
of script in here first. So the first thing we're
gonna do is bring in a key. Let's see what
we've all got here. We make use of the four key. It looks like we haven't
made use of that. So I'm going to right-click
it some empty space, type in four. Let's do keyboard for. And we're going to say
when we press the F4 key, we're simply going to destroy the actor
meaning ourselves. So pressing for, we're
going to destroy ourselves. Great. That is all needed
for this next step. So compile and save this. Now in our bp Game Mode, head on over into there. We're going to head on into
the Event Graph of here. We're gonna do something
off of event tick. You always have to
be a little bit careful when you use event tick. You can Bork your game by doing it too much scrip
off of event tick. But for academic purposes, I'll be using this fact. If I come under class defaults, I'm going to say our tick
interval is going to be every 1 s. We don't need to be
taking every frame. So we'll say every 1 s. I'm going to right-click
and some empty space, get player character. We're going to then
drag off of this and do cast to our third
person character. Then what we're going
to do is drag out of here and type in on destroyed. Now, if I start typing
in on destroyed, I had this assign on destroyed. That is the one I
am looking for, a sign on destroyed. Now when I click on
this, I'm going to bring in two nodes, a Bind node, as well
as a custom events. I'll describe what's
happening here in just a moment's going to
hook this in like so. And I will leave this
custom event name as such. Now, if this all
looks familiar here, this binding, uh, to
this custom event. This is because this is a setup that we use when
we're talking about event dispatchers to listen out for this on destroyed
event in this case, for our ThirdPersonCharacter,
we are subscribing to our ThirdPersonCharacter is on destroyed Event Dispatcher. That's essentially
what we're doing. You may be saying to
yourself, wait a minute. In our ThirdPersonCharacter,
we did not create an Event
Dispatcher at all. Well, if I go back into
my ThirdPersonCharacter, if I scroll on down to
my event dispatchers, I will actually be
able to find under Event Dispatcher game a
dispatcher for on destroyed. Now this gets called when
I destroy the actor. Now if you don't see
any of this down here, it's because you
need to click on this gear icon and
show inherited. If you turn that off, don't show inherited,
you won't see it. This is an inherited
Event Dispatcher inherited from the parent class. So if you turn it in on ThirdPersonCharacter
event dispatchers game, this onDestroy, this
is getting called. This is sending out
a signal when we destroy our character
here in our game mode, what we're doing here
is we are subscribing, we're listening out for this on destroyed event to happen. And then when that happens, this will fire off and tell, tell the next node to do
whatever we want it to do. Now what we wanna do
is we want to respond, we want to restart
up with our players. So a way we can do this is right-click and
some empty space type in git player controller. And if we reach inside our generic player
controller here node and do a search
for restart player. There is a function node related to your player controller. This will restart your player at your player start
actor location. So this setup right
here will be enough. So let's check this out. I'm going to compile
and save in play. So it was the four key
that's going to destroy us. And when we are destroyed, we're gonna be respond
right back at this spot. So let me run off of that spot. The four key. I respond in that spot, tap foreign key, respond
to that spot, et cetera. Now, for those of
you saying, Hey, why are we using
event tick here? Well, if I did, an
event began play, Let's go ahead and
give Event Begin Play. Let's do begin, end event, begin play a try. What would happen here? And let's just disable this. Is we're listening now
for this onDestroy event. As soon as we begin play
here, That's great. But that listening out for that event has already happened. So this is only
going to fire off the onetime adheres this event. Upon beginning play, we're listening for it
just that one time. So if I press the F4 key here, it does rosette
us back one time. But if I press the F4 key
again, does not happen. That's because we
listened down for the first time upon beginning
play with event tick. Remember, we were
listening out for this every single second. That's how we set
up our event tick within our class defaults, alright, some Game Mode
notes to end this video on. Game may have any
number of game modes. We only have one, however, setup in our project
settings at a time, your primary game mode is set up in your
project settings. But remember, you can override which game mode is used
in your world settings. And you can find
that under Window world settings, right there. Always possible to override the game mode in your
project settings. The game mode
blueprint is where you set up the rules for your game. Things like respond locations, things like what level
to travel to next, things like number of
allowable players, that sort of thing. The Game Mode is not a great
blueprint to store variables that need to carry over data
from one level to the next. Things like lives or score. Now this is because when
you open a new level, any variables created and
stored inside of the game mode, or reset back to their
original values. And I want to
demonstrate this here quickly before we
end this video. Alright, let's assume
that in our bp game mode that this is a great place
to store how many lives are. Character can have
spoiler alert. It's not, but just play along under our
variables section, you're going to click
this plus button. I'm going to call this lives. And over here is where
you can make sure that it is set to a single
variable of integer type. I'm going to set my default
lives here to five. The reason mine
showed up as fives because I cut the
video there in, recreated this ahead of time. Now I'm going to
compile this and save very important to do that. Next, what I am going to
do is I will make it so that inside of my BP
third-person character, I'm going to decrements how many lives we have inside
of our game mode. So ThirdPersonCharacter. I'm going to right-click. I don't think I'm doing
anything off of the six key. So what we're gonna
do from here is right-click get Game Mode. We will cast to
our bp game mode. And once we have done this, we can then reach
inside of here, find out how many lives
we've got to hold it. Let's get our lives and will dry out of this and
type in decrements. This is kind of a special node in that we're getting
our lives here. We have five, this
will decrement one, subtract one from it, and then it's going
to set it back. So no need to set
lives here as well. So we're gonna go
54321, etcetera. That'd be great. Now when this all happens, let me go ahead
and compile this. Save. Remember in
my Level Blueprint, I've made it so that when I
overlap that trigger box, I'm going to transport
myself to level two. So after I transport
to level to, my third-person character is
going to come along with, I'm going to press
the six key and see how many lives we have. So that is going to be our proof that soaring lives
inside of our game mode. Not a great idea because
those variables gets set back to their default
when you change levels. Here we go. So click and play. I'm going to press this six key. We can see, well actually
you know what I need to do, I need to print this
out to the screen. Let's drag out here. Print string. Let's print this results. Like so. Compile,
Save, and play. Set my debug option to be
my ThirdPersonCharacter. So now when I press the six key, 4321, so I've got one
life left, so to speak. I'm going to overlap this. We're gonna go to another level. Now when I press the six key, you would assume
that I had one life, I shouldn't go down to zero, but 4321, that lives variable
gets set back to zero. So just a little bit
of nuance there to understand with the
Game Mode blueprint. Any variables that you
set inside of here, they will be set to, they're back to
their default values if you ever change levels. All right guys, that is
going to do it all for this discussion on
Game Mode blueprints. It is the blueprint that sets other framework blueprints here inside of your class defaults. And it is a great place to
set up rules for your game, such as respond functionality. That'll do it all
for this video. See you in the next one.
100. Pawn: Welcome and continuing our discussion of
framework blueprints. Our goal in this
video is to learn what a Pawn Class Blueprint is. How to create one in
how to set one up so that our project
knows to use are created Pawn Class Blueprint as the default avatar
we want to control. So let's talk about
what the heck a Pawn Class Blueprint
is all a pond, is an actor that can be
possessed and receive input. It is the physical
representation of a player or AI
entity in the world. Now pawns can be humanoid, as is our third
person characters that we've been controlling up to this point in the course. Or it might not be humanoid. So it could be something
like a car or spaceship, a rolling ball,
something like that, that you can control. Alright, let's go ahead
and create a pawn class. And I could do that
straight away from here inside of our project
settings, maps and modes, selected game mode
drop-down by clicking this plus button right here
next to Default Pawn Class, I could create the proper
blueprint using this method. I just choose a folder. I'd want to save
it in et cetera. However, I'm going to not
do this just to show you how we can create this back
here in our level editor, I'm going to come under my
scripting framework folder. And if I right-click in here, I can also come under
Blueprint class. And you've seen this
window 1 million times, pick a parent class. One of the most common ones
to create is a pawn classes. Second one down
here, and it says, a pawn is an actor
that can be possessed and receive input
from a controller. Let's go ahead and
click here the pawn. And I'm going to name this
guy BP underscore pawn. And then I'm going to
double-click on m2, open him up right away. We're going to set up some stuff over in the Components panel. So the first thing we're
going to add here, click Add under components
is we'll add a static mesh. And over in the Details panel, I have a given
static mesh in mind. It's HMD is what I
want to search for. I'm looking for
this generic HMD. Now, this is something found
in your engine pathway. So if you don't see this and you want to play along at home, click that gear icon, make sure show engine
content is on. This is going to look
like a VR headset. We're going to
control one of those. I'm going to send my scale here, 255.5 with this lock icon on, I can just change one of these. I'll choose the middle one here, the y scale, click F5. Then when I press Enter, because I've got that
lock icon set over here. By pressing Enter, it's
going to set it to five across the board. Alright, I'm also going to
change the material for this to be Chrome. I'll do a chrome ball. So we're gonna, we're gonna steer something
like that around. That's exciting. Alright, next component
I want to add here. Make sure we've got our
default seen route selected. So here's how it works. The default senior at all
your other components that you add are going
to be attached to it. So right now our static mesh is attached to our
default scene root. That's essentially a point in space where we are
attaching things to. So I'll choose
default seen route, choose spring arm, spring arm. Think of that as a selfie stick. We're going to be using this to attach a camera component too, which might, with my spring
armed components selected. I'm going to add and attached
a camera components, not Sony camera, just
plain old camera cameras. A fine name. I will accept that so we can see camera is attached
to our spring arm. For the camera, I'm going to set the location for this to be 100. Let me zoom out my viewports. I can see that the rotation we're going to set
to be negative 20. And if I select my spring arm, you can see right now that if I was to rotate
my spray arm around, pressing the space bar, the camera is going
to go along with it. Now the reason this is offset, it's not attached
to that red line. The spring arm camera, which is determined
by this arm length. By the way, you could
set that further, farther away, closer, I'm
going to set that to 300. Now the reason this
is not attached to that red line right there
is because I do have the Z height set up to be
100 and we're angling it down negative 20 degrees
in the y-direction. Last but not least,
we are going to add a floating Move are floating
pond movement component. And it says in our
little tool tip here, this is a movement
component that provides a simple movement
for any Pawn Class. I say we go with it, yes, As we will need that to move
this giant headset around. Now, I am going to cheat here. I'm going to copy and
paste some script from our ThirdPersonCharacter into the Event
Graph of our pons. So I've got my ThirdPersonCharacter
up open over here. If you forgot or that guy
is third-person blueprints. There's your
ThirdPersonCharacter. So what do I want
to steal in here? Well, I want to steal. The movements controls. So where it says
movement, input, gamepad and mouse, I'm
going to left-click, drag around all these Control C. I'm gonna go into
my ponds event graph. I'm going to delete these all out and do Control V to
paste those in here. And then I'm gonna go back
to my ThirdPersonCharacter. And I want to be
able to look around. So this is going to be our look around controls for the mouse. I'm using a mouse. You got gamepad. Look around controls over here. I'm going to steal
the camera input, the look around
inputs for the mouse. Left-click drag, Control C, back in my pond, Control V. Now, that is all well and good. This will allow me to
look left and right. The yaw and the pitch right here will allow
me to look up and down. However, I need to
change something back in my class defaults
of my pond here. So in my class defaults, pawn, I'm looking for a couple
of boxes to tick, and they're right
up here where it says use controller
rotation pitch. I want to make sure
that that is checked. Where it says use
controller rotation jaw. I want to make sure
that that is checked as well so that I can pitch my camera up and down
and also look left and right. Alright, with this all done, I'm going to compile and save. And now in order for me to
actually test this out, I need to slot in my BP pawn here to be my
default Pawn Class. Now I could do it here. But just to show off
different techniques, I'm gonna go back to
my level editor here. I've got this blueprint
of button right up here. So I'm going to select that my current Game Mode
is my b p game mode. Let me just go down to my
scripting framework folder. You can see in the last video
we created BP game mode, clicking right up here. That is currently my game mode. So if I choose in this
drop-down right here, pawn currently, ThirdPersonCharacter, let's
select a new Pawn Class. And I'm going to
choose my b p upon. So I'm going to set
it right there. You can see if I
come back in here, come right under here, that
has now set as my new pond. If I go into the Game Mode acid itself by double-clicking on it. You can see here my Default Pawn Class
has now been changed. And also, if you go on
your project settings, you can see your
Default Pawn Class has been changed here as well. So you change it in any
one of those three places. It changes it in
the other places. So now, when I go and click
the play button here, I will not spawn in as the ThirdPersonCharacter
right here at the player starts actor, I will spawn in as
his giant VR headset. Let's go ahead and
give this a play. Let me go back into my
pond right here as well. So you can see this
script firing off. So I'll click play right here. There's my giant headset. Let me select my debug object
as my spawned in BP pond. So you can see this is all
firing off continuously. The input axis turn right. Let me zoom up on
this a little bit. These are firing
off continuously. Input axis move
forward and backward, move right and left. Axis events do fire off
continuously like this. Let's see if I can move around. We can see i'm I
can look around and holding down the
right mouse button. Left and right. That's yaw, pitch up and down. W a S. Andy, it looks like
I'm moving around. Just find we now have a
pawn that we can play as. And so there you have it. If you have these
components in this script, you can have a upon a class blueprints to control
in your game as well. Of course, you have to have
it set within your game mode, your project settings in that
default Pawn Class slot. Pretty cool. Alright,
in part two here we're going to create a
character class blueprint. A character class derives
from a pawn class. We will see you all
in the next video.
101. Character: Alright, welcome back. In this video, our
goal is to create a character class
blueprint from scratch. Now the character class is an extension of the Pawn Class, and it is a special type of pawn that has the
ability to walk around. I thought I would include it
here within our framework Blueprint discussion
because inside of our project settings, where all of our framework
blueprints can be found, as well as inside
of our game mode, where the framework
blueprints can be found in slotted in either or. We have a slot for
Default Pawn Class, and that is where a character class blueprint
can be slotted in either a pond or a
character can be slotted in because the character
derives from the Pawn Class. Now to help drive
home this point, we're going to go back into our scripting framework folder. And we're going to right-click
in some empty space where we're going to
create a Blueprint Class. And right here in our
pick parent class window, we can see if we
choose a character. It says a character is a type of pond that includes the
ability to walk around. And if we come under
are all classes section check out the hierarchy of
different blueprint classes. Underneath the actor class. We can find, I just expanded
out that triangle there. We can find the Pawn Class. Pawn inherits from actor. And inside of here
we can see that the character class
inherits from pawn. I'm going to choose
character right up here. I'm going to name this
BP underscore character, underscore female. Then we're going to double-click
on this to open it up. And you can see we've got
a bit of work to do here because we don't see
anything in our viewport. So let's go ahead
and get started. The first thing I wanna do
inside of our character, female blueprint on
her class defaults. I want to come under the
Details panel and where it says use controller
rotation yaw. I want to uncheck this. Note. If left true, our
character would automatically be oriented in the direction that
we're looking. You know how you can
pivot that camera around your character. Well, if you did
leave that true, your character would
automatically be looking in that
direction as well. I want to uncheck that
because I want our camera to actually be looking face-to-face
with the character. You can experiment with
that if you'd like, when we're done with
this whole process. Alright, I'm going to
select our mesh next. And over in the Details
panel I need to slot in a skeletal mesh. Let's go ahead and shoes. We've got SKS, Manny, which is the male version I'm
going to do S, K, M, Quinn. It's gonna be the female version that's going to load in here. Now while that's loading,
and I'm also going to slot in an animation class as well. So under anime class, I'm gonna be looking
for ABP Quinn. And you'll see Quinn
now animating. Also, I need to set my character mesh down
here a little bit. So I'm going to
set the location, the z location to
be negative 87. I'm going to be super
precise with this. That's going to be good enough. The rotation I'm going to
set to be negative 90. This blue arrow
indicates forwards. So you want to have
your character facing forward just like that. Alright, next with our
Capsule Component selected, I'm going to add a
spring arm components. A spring arm component is essentially like a selfie stick, although there is a setting
or two that can be very useful for controlling
things about your camera. I'm going to leave
that name there as spring arm and over
in the Details panel, I want to find under camera
settings right here, Use Pawn Control Rotation. I want to make sure
that this is checked. Now this is going to make it
so that when we hold down the right mouse button in
our game and pivoted around, the camera is going
to rotate around, which is something
that we do want. So you can play around
with that setting as well as soon as we're
done with this video. Next, I want to select, with my spring arm
components selected here. Want to add a camera. Nowadays, Sydney camera,
but just a regular camera, and it should be
indented like this. The camera in this way is
attached to your spring arm, is essentially
attached to the end of your selfie stick here so
you can see my spring arm. If I was to change the
target arm length, the camera would
adjust with him. Set that back to its
default of 300 for now. So with my camera selected, there is nothing I
want to change here, although I will point out inside of here that
if you wanted to, you could change something like your field of view setting. Lot of users like to
play around with that. Play around with that, find a field of view
that is to liking. Next, I'm going to change my character movement
component here. I've got one inside of
here that is called Orient Rotation to movement. Now there is a whole lot of different
parameters inside of your character movement
component that control your characters
moving properties. If I search for this audience. That's the one I'm looking for, Orient Rotation two movements. I do want to check this. By checking this, I'm going
to orient that is rotate the character to move in the direction you're
trying to go. Without that, it's going to be so that your character
could be looking like they're walking in one
direction while they're actually moving in
another direction. So that's a good one to make sure that you've got checked. Next, if I jump over
to our event graph, you can see that I don't
have any script in here that's going to control
how my character moves. I'm going to cheat in
the interest of time. So I'm going to delete
out these nodes. We're going to jump into
our ThirdPersonCharacter and steal some nodes from there like we did
in the last video. So if you don't have
ThirdPersonCharacter open under third-person
character, blueprints double-click on
your third-person character. Inside of here,
we're going to steal our movements controls
right here, all this stuff, left-click, drag, control C, coming into our character, female, control V to paste. This is going to control our character is forward
and backward movements, as well as our left
and right movements coming under our
ThirdPersonCharacter. Once again, I am now going to steal my camera input mouse. If you've got a gamepad that you want to play
your game with as well, you might consider
stealing that. I'm only controlling
it with the mouse, so I'm going to left-click
and drag right here, control C, coming under
character female, control V. And with all that
done, let's go ahead and compile and save. Alright, next, we
are going to slot in our bp character female as
our default pond class. So let's jump on back to
our level editor here. And I want to set this in
side of our world settings. I'm going to override
our world setting, our project settings right now. I'm using my b p game mode. If I use this game mode
for my entire project, this is going to determine the framework blueprints
used for every level, every map in my project, unless I override them
in my world settings. So right now my project
settings are saying, Hey, if you click the Play button, you're gonna be
using your BP pond. And we can see that
by me playing. There is my child VR headsets. That is my BP pond
that we created here inside of our
framework folder, BP pond. I want to say I'm
a world settings. I'm going to change
it for just this map. This will override
the project settings. Now to do this, I'm going to choose a
different game mode inside of my project settings. I've currently got
my BP game mode. So I'll say for our
world settings. And if you don't have this open, you can come under Window and turn on your
world settings right there. That'll bring on this panel. For our game mode
here, I will use, will say BP,
third-person game mode. And while we normally have the third-person
character slotted in as the character to roll around with watches
by click Play, we now control the
ThirdPersonCharacter. Instead of our bp pawn, I can say instead, let's choose to use our
bp character female. Just to show another way of
slotting something in here, I could choose something
from the drop-down list. However, I could select my
BP character female here. And with that selected, simply click on this
arrow right here to use the selected acid
from the content browser. And now with that slot it in, I could control my BP female
character, character female. And you can see I'm moving in the direction my
character is orienting, or my character is oriented in the direction I'm
wanting to move. And also I'm able to run towards the camera like so
kinda show improvement. Some of those checkboxes, checkboxes just did let me
exit out of here quickly. If I was to go back
into my BP character, female character movement
component and uncheck, Orient Rotation to movements. And then click Play. Now check this out. When I move around, my
character does this. They're not orienting to the direction that
I'm trying to move. So I'm gonna go ahead and set that back Character
Movement Component. Let's go ahead and
check that. Next. Note that in our
spring arm component, we had checked this. I need to undo the
search filter there. We had checked this youth
upon rotation setting. If I uncheck that and play, and I hold down the
right mouse button, which I'm trying
to do right now. I'm not actually rotating
around my character. Instead, the camera
is just moving and rotating on its own to face whatever direction my
character is moving. I don't necessarily like that, so I'm going to
check that back on. And finally, if
you remember back in our class defaults we had made it so that we unchecked
use controller rotation. Ya if we did have that
check, if we did. And then we went
ahead and played, I'm going to run around
using WAS and D. You can see how you get this kind of scary result, which
looks terrible. I can rotate it around like so. And my character
is going to skate and simply facing in whichever
direction I'm looking. Don't really like that much. And so that is why I prefer having that unchecked as well. Alright, there you have it. We have created a character
class blueprint from scratch. With that created,
you can go ahead and slot in any character or pond into your default upon class and whatever game
mode you have chosen. You can see here in
our world settings, we are overriding the game
mode in just this map, just this world that we have
set in our project settings. If we had nothing set back
here in our world settings, the project settings
would determine Pawn Class that would
be used in this map. That's gonna do to
offer this one, guys, see you in the next one.
102. Player Controller: Welcome. In this video, our goal is
to learn about the role of the player controller
blueprint in the overall setup of
our gaming project. And also to explore some scripting concepts
that are often associated with player
controller blueprints. Now if I was to dive
into my settings, my project settings, over in
our maps and modes section. If we expand out our selective
game mode right here, we can find the player
controller class. Now once again, we can slot
in a player controller here or inside of our
default gateway mode. If we change something inside of our default
gateway mode, that is one of these framework
blueprints right here. It'll change it as well inside
of our project settings. So the game mode is the one that determines the arrest
of the framework. Blueprints change it in
one spot, like here. It'll change it in your
game mode and vice versa. If you change it here
in your game mode, like a player controller,
it'll change it in your project settings. So the player controller
class is going to be the focus of this video. Now those of you that have
been playing along all the way through since the
beginning of this video, may recall that we have created a player
controller blueprint. In fact, in the video titled
events begin cursor over. We did create bp
player controller. And the reason we created
that there is so that we could turn on and click events and also
show mouse cursor. There are some
things specific to a player controller
blueprint that we dove into earlier in the course
just to show it off there. But now, here's the
part where we explained what the heck a player
controller even is. What is general purpose is in the framework of Unreal
Engine blueprints. Now, to better understand
what the heck a player controller
blueprint is in Unreal. Consider this scenario. Consider a game like
Lego Star Wars, where you can control a
whole host of characters, but only one at a time. You as a player
have some desire, some things you would
like to do with your character and
the game itself. You, the player
wield a controller. In this case, we'll say
it's this Xbox controller. Now you're playing the game
and you are controlling just one character at a time. Let's say you're starting
off as Yoda here. You can press the a
button to make them jump. You can press the X
button to make him swing his lightsaber, et cetera. Now however, let's
say that Yoda dies. Sorry, Yoda, you are gone. That character is gone. Now, your player controller, which is represented by
this actual controller, possesses a new character, in this case Anakin. Now, again, with Anakin, you can press the
a button to jump, the X button to wield his
lightsaber, et cetera. But then, oh, and I can dies. So that character
class goes bye-bye. However, your player
controller lives on and it keeps attaching
itself to new players. In this case, you
are now controlling account Du Gu were once again, you can press the
a button to jump, press the X button to swing
his lightsaber, et cetera. And perhaps you want to even do something like access
the pause menu. Now, if you were to build
some of this functionality within the character
class blueprint, what happens if your
character is dead? Like e.g. what if you were
back here controlling Yoda? And that functionality
to pause the game existed inside of your Yoda
character class blueprint. Well, once he's dead, there'd be no way
to pause the game. Player controller
blueprints exists throughout your play session. And you can think of a
player controller as being the puppet strings used to control your puppet,
your character class. So any sort of
shared functionality that you may have between character classes or
any functionality that you want to have for you, the player itself,
such as pausing the game or interacting
with a menu screen. That kind of functionality
you'd want to build out in your player
controller blueprint. So in short, things to remember
with a player controller, blueprint controllers are
non-physical actors that can possess a pond or a pond
derived class like a character. By default, there is a
one-to-one relationship between controllers, a player controller, and
a pawn, aka a character. Each controller controls
only one pond at a time. And player controllers are
best used to implement user centric functionality like bringing up a pause menu
or an inventory screen. Or for shared
character functions, like swinging a lightsaber if all your characters can
do that sort of thing. Or jumping, if in fact all possible characters
can jump as well, any sort of character
specific functionality, that kind of functionality should exist within your pond or character class blueprint itself and not the player controller. Alright? If you
don't already have a player controller Blueprint built from earlier
in the course. You can create one now
by right-clicking. Blueprint class
player controller. And we named that guy
bp player controller. And once again, you want to slot this into your framework. The way you can do that is
under your project settings, which can be accessed
here under Settings, project settings, and
under maps and modes, you can slot it in right there. Alternatively, in your game
mode, blueprint itself. And once again, we have the BP Game Mode lording
over our project here. In this asset itself, the game mode blueprint. Over on the right-hand side, you can slot your player
controller in right there. You change it here,
you will change it in your project
settings as well. Also back in your level editor, if you come under your
Blueprints button right here, and you expand out
under Project Settings, Game Mode, player controller. Here you can edit your
current player controller, create a brand new one, or select an existing one. Now, if you open up your
bp player controller here, earlier in the course, we had class default selected inside of our bp player controller. And this is where we checked
on the ability to show a mouse cursor to enable click events and to enable
mouseover events. We can also enable
touch events as well. So there are some very
game-specific things, ways to interact
with your game and your menus that are housed inside of your player
controller blueprint. Now before this video started, I went ahead and created
some functionality inside of our bp player
controller here, I wanted to show
how we could script some character functionality inside of our player controller. Now remember, when
you're playing a game, you're player
controller attaches to whatever pawn
it is that you are controlling pawn or character
whenever you have set up inside of your
Default Pawn Class. Now my script here is I'm making it so that when I
press the Up button, I'm getting my current
player character, the one that I'm
playing as and I'm simply launching the character. Now the target here is a
character, not a pond. So this will only work for characters that I
am controlling. I could have also called
this jump function that also exists inside of my character
class blueprint as well. But I wanted to do
this launch character a because it's cool. And b, because it shows off another character specific
function that we could use. You must get player
character and drag out if you're first
in order to find this. And all it's going
to happen here is whatever character I
am possessing here. If I press the up key here, my player controller blueprint, I'm simply going to launched whatever character
I am controlling up into the z-axis
using that value. This is kinda like
a super jumps. So if I was to just play
here, I'll set my debug. Object to my loan
player controller. Bring on my character
once again. I've got a few more characters out here we'll be using shortly. So now when I press the
up key on my keyboard, that is like a super jump. So this does indeed
prove that I can script character specific
functionality here inside of my player
controller blueprint. Alright, now consider
this scenario back in my level editor. I've placed two more BP character females out
into my level itself. I simply rename them
character female green and one
character female red. And I simply change the material zero for one of
them to be green. And I did that by selecting
the character mesh, changing the element
zero to green, and selecting the other one, I selected the character mesh and change element zero to read. And then with each
of these selected, I did this one at a time. I went into my Level Blueprint and I created this
script right here. There is a reference to
my character or female. I believe that's the right one. I need to update this. I'm going to right-click on
this and refresh that node. There is the red,
there's the green. You, as long as you have
them selected in your level, like your red one right here, you can go back into
Level Blueprint, hold down the Alt
key and left-click. You could do the same with
the female green as well. And note my setup here. If I bring in a get
player controller node, I can find nodes, function nodes for
unprepossessing a target and then
possessing another target. So check out this
grip that I have going on here inside
of my level blueprint. When I press the three key, the very first time, we're going to shoot
out of this a output. In which case we are going to
get our player controller. That is whichever
player controller we are using at the time, our bp player controller, we're going to and possess whatever target it
was controlling. In this case, it will
be unprepossessing. In my world settings, I currently am spawning
in a BP character female. It will be unprepossessing
this female character. Then be told to possess. This player controller will
transfer possession over two. My BP character, female red. Then the second time I
press the three key, we're going to shoot out of the B output pin because
flip-flop goes a, then B than a than B. So the second time you press the three key will
shoot out of the beam. We're going to, I'm possessed whenever we're now controlling, which in this case will
be the red character. And we will then
transfer possession over to the character female green. So our player controller
is being told to and possess one character
and possess a new one. So let's just talk this up
in the upper left here. I'm going to click Play. Bring in our debug
object of our test map. And so check it out. So if I also press the
Up button right now, I've got that super
jump functionality built inside of my
player character. That's super jumping
kicking capability. That will transfer over to
any character I possess. So I'm pressing up key. Alright, now I'm
going to press the three key while mid flight. I've transferred possession over to my red character here. Check this out. If I press the up key here, my player controller
functionality transfers over and you
can see my other ones, cotton flight, they're
pressing the three key. I press F3 key. When I was in flight, I've
transferred possession by player controller is now controlling my
character female green. And of course that
functionality that I built out inside of my bp
player controller will transfer over as well. So if I press the up key while controlling
the green character, I can Super jump as well. So that is a demonstration
showing that inside of my bp
player controller, I can build out
functionality for any functionality that I want
all characters to share, all ponds to share. However, I have
functionality very specific to an individual
character or pawn. That type of script
would be best to put within the individual
pond or character. Alright, now I also
mentioned that building out something like
screen interactions, pausing the game, et cetera, that sort of stuff is
great to build out inside of a player controller
blueprint because pawns, characters they can
die player controllers exists throughout your
entire play session. So I'm going to come up
some empty space here. I'm going to right-click. I'm going to do a search for keyboard and let's
do something when we press the P key, P. And I'm gonna make it so
that when I press the P key, I'm going to bring
in a flip-flop node. So the first time we press
it will shoot out of a. The second time we press
it will shoot on a beat. And all I wanna do here
is set game, paused. Control C, control V. So the first time
we press the P key, we want to set the
game to be paused. The second time you
press the P key. We want to set it to be unpause. Now this is very important. Check this out with your
P key selected here. You need to make sure
that you check this box for execute when pause. Because if we left
this unchecked, you would be able to press
the P key to pause the game. But because the game is paused, it wouldn't recognize
pressing of the P key again to unpause it. So you got to make sure that that is checked if you want to be able to use it to
pause and unpause. So check this out. I am playing the game. I can run around, press the P key, game is frozen. Pressing the P key again, it will unfreeze it. I will press the three key, change over to my red character
here, press the P key, pause, press the P
key again on pause, and likewise transfer possession over to my green character. Press the P key, pause, press the P key again, unpause, shared
functionality all within the player
controller blueprint. Now something you
may have noticed here is that our player
controller blueprint recognizes and
processes input events without any sort
of special setup. We didn't have to go
into our class defaults and do anything special in order for this to work or in
order for this to work. Now, character and ponds do the same as does our
Level Blueprint. They all process these
input events by default. So what happens if
I use in this case, say the UP event in
a player controller, in a character blueprint
and a Level Blueprint. What happens? What's the priority? Well, let's run a scenario here inside of my
player controller. If I press the up key, I'm launching the character. Let's set up in our
bp character female, which I'm currently controlling here in my world
settings that is. My player controller class. I will just bring in the up key. I have to do search
for keyboard up. And I'm just going
to drag out of here. And I'm going to print string. And I'll say character. Female will just print that
out to the screen for say, 20 s. Just to give ourselves
a little bit more time here, we'll change it to be pink to make it nice and noticeable. Alright, compile, save that. And then inside of
our Level Blueprint, I'm also going to bring
in the keyboard up. And inside of here we're
simply going to play a sound and we'll just
do an explosion, right? Alright, so Compile, Save. Now I've got the up key implemented in our
Level Blueprints, our character, and our
player controller, which one of these is
going to take priority? So I'm going to go ahead
and click play here. And I'm pressing the up key
and I jumped super high. I didn't hear
anything and I didn't see any print texted
in the upper left. So the player controller
is the highest priority. Now what if I wanted
this up key to actually process in my
other blueprints as well. How would I set that up? Let's exit out of here quickly. And now with my Up key selected
here, my input events, this consume input is the
key that's determining that only this input
event is processing within my player controller
and not the other blueprints. So long as this is checked, this will consume this input, meaning this is the only place where it is going
to be registered. It's going to eat it
up and won't recognize it in any lower
priority Blueprints. If I uncheck this and
we try playing again, and I press the up key. Now you can see that I did
the Super jump and you also heard that explosion sound. What happened here is I press
the up key and said, Okay, launched with the character, we're not consuming that input. And here my level tests map. It also processed the upkeep, but it also said right here we are going to consume this input, meaning it stops right here, is not going to allow any other
blueprints to process it. So the order goes. Our player controller
has first priority, the Level Blueprint
has second priority, and then your pond and
characters have third priority. So if I wanted it to process
here in my female as well, here with my level test map, I gotta make sure
I've got up selected, do not consume the input. So our setup now is inside
the player controller. We are not consuming that input. We're allowing it to filter down inside of my
Level Blueprint. We're not consuming
that up input. We're allowing it to filter down inside of my character female. Doesn't really matter here.
This is the third priority. We can consume it here as well. It'll print that
out to the screen. So now when I play, I press the up key, I'm
going to super jump. You're going to see that texts for character female
right up here. And that explosion will be
heard as well. Here we go. Super jump explosion
character female 12.3. Alright, so to recap, the player controller
blueprint is one that can be slotted in within
your game mode. Player controllers are
non-physical actors that can possess a pond. They have a one-to-one
relationship controlling one pond or character at a time. And pleasure controllers
are best used to implement user-centric
functionality, like bringing up a
pause menu or for any shared functionality between characters or ponds that you
might be taking control of. Guys that'll do to
offer this one, we will see you in the next one.
103. Game Instance: Welcome. In this video, our goal is to
learn about and demonstrate use of the game instance
blueprint in unreal. That's this guy right down here. Now this is personally one of my favorite framework
blueprints in all of unreal because
it acts as a great, reliable storage container
that you can go to to access variables and whatnot no
matter what level you are in. Now, I don't know if this is technically considered
a framework blueprint because it is not one of these blueprints that gets
slotted into our game mode. Now you remember from earlier in our discussion about
framework blueprints, the game mode is what
determines the rest of these framework blueprints such as our Default Pawn Class, player controller, et cetera. The game instance is
separate from that. It is not part of your
game mode at all. We can see that I've got my BP Game Mode open
across the top here. And if I was to select our default classes or a
class defaults rather. We can see over in
the class of section, there is nothing here for a
game instance, blueprints. So what makes this
blueprint so special? Well, it is unique
in that it is not destroyed when changing
levels in your game. It persists so long as
your game is running. Alright, so at this point you're probably still wondering why the game instance
blueprint is so valuable like who
cares if it persists, if it exists throughout
my entire play session? Well, what makes
the game instance so valuable is that it actually carries over variable data from one level to another to another. Without getting reset. You see any variables you set in your pond or your
player controller, or your game mode, they will be reset back to their defaults when
you change levels, game instance does not
have that problem. It will store and
carryover variable data from level to level without
those variables being reset. Not a really helped
drive home this point. I've set up a scenario that
we're going to test out here. Notice my default mode, Pawn Class and player
controller class right here. Bp Game Mode, BP pawn and
bp player controller. Inside each of these,
I have created, and I'll start off
with my BP pawn here, a Lives variable. By default it's going
to be starting at zero. And inside of here, I simply created this script right here. So I'm going to
press the six key. We're gonna get our lives. This node is going
to increment it. This is a special note
and that is going to get our lives and it's immediately
going to set it back. So the first time I press six, it's going to change
this to be one, then two, then three,
et cetera, et cetera. And we're going to be printing
that out to the screen. We're gonna be doing the
same sort of setup here inside of our bp
player controller. So I simply copied and pasted this bit of script into
my player controller. I simply swapped
out the input key. There is my lives
variable as well. Now inside of my game mode, the game mode doesn't
recognize input events. However, inside of my game mode, I did create a Lives variable. I will start this off
with zero as well. Now, because I couldn't
increment that here. Let me compile and
save this quickly. I am doing that in
my Level Blueprint. So I went here, went into opened my
level blueprint, and through the Level Blueprint
I can press the achy, get my game mode, cast, my game mode, get access to that lives
variable that exist inside of that game
mode blueprint. I can increment it and print it out to the screen from there. So in three different
blueprints, my BP pawn, my
player controller, and my Level Blueprint, where I'm accessing that
variable inside of my game mode, I'm going to be incrementing
that lives variable. Then what I'm gonna do beyond that is here in my
Level Blueprint, I set up this script. When I press the L key, I'm going to open a new level. The level I'm gonna
be opening is this minimal default level. This is a level found in my
starter content maps folder, that guy right there. And I want you to
know that inside of my minimal default
Level Blueprint, I set up the same
bit of script so that we can increment our bp game modes lies
variable once again. So what you're going to see
with all three of these, I'm going to increment
these variables and I'm going to transfer
over to a new map. And then I'm going to attempt to increment these variables again after I transferred
to the new map, you're going to see that
those counts are starting over at zero once again. And hence that is the
detriment of storing some variables inside of a
pawn, a player controller, or a game mode if you're
transferring levels, which games oftentimes do transferring from level
one to level two, those variables inside of these three blueprints are gonna get set back to their default. Alright, so here we go. Here's going to be our
playtest, clicking play. Alright, so I will start
off pressing the six key. As you can see, I'm
incrementing my spawn. My pawn lives variables
sum up to 25 there, and I'm going to
press the seven key. The Lives variable inside of my player controller is
all the way up to 25. And now I'm going to
press the eight key. And the lies variable inside of my game mode has now been
incremented up to 25. Now I'm going to
press the L key to transfer over to a new level. Here I am. Now, because I've
got it set up in my project settings that this
is my default gateway mode, my Default Pawn Class by
default, player controller. Those are all going
to transfer over to control what Game Mode, Pawn Class, and
player controller I'm rocking with here
in this new level. So check it out. I'm going to press the six key. You can see my lives
variable inside of my pond started back at zero. I'm going to press the
seven key instead of my player controller
started back at zeros, so I'm having to
count from scratch again and then
pressing the achy. My lives variable inside of my game mode also restarted
from the beginning. So this is where the game
instance really comes in handy. If you want to have
something like a Lives variable transfer
over from level to level, remembering what that value was prior to coming
into the new level. Alright, so let's go ahead and create our game
instance blueprint. We can do that here inside of our project settings under
maps and modes, game instance. You've got this
plus button right here to create a
new game instance. However, I'm going to jump
back to my content browser. And inside of my scripting
framework folder, I'm going to right-click
and some empty space. And under Blueprint class, I'm not going to
see Game Instance up in this area is
not super common. But under the all
classes section, we can type in Game Instance. And you want to choose
this guy right here, game instance, not platform game instead it's just
good old game instance. Select this and
I'm going to call this BP underscore
game instance. Alright, Next, let's
go ahead and slot this inside of our
project settings. If you forgot where to
access Project Settings, you can access it here. Or under Edit Project Settings. You want to come
under maps and modes. And it's right down
here at the bottom. Clicking this drop-down,
I'm going to slot it in my BP game instance. That's great. No Save button or anything here, we can simply just exit out of our project settings or return back to our
content browser. I'm going to double-click on IBP game instance
here to open it up. And we're going to
add a new variable, and I'll call it lives. And we will make
it be an integer. We'll go ahead and
compile and save. And we are going
to leave this at a default value of
zero for right now. Now, what I can do
here is I want to print out how many lives
I have to the screen. A way that I could do this, you might think is, well just right-click and
do a search for Begin Play, and you'll find out that
that does not exist. What you wanna do is here inside of a game
instance blueprint, you want to look for an
event called event in knit. This is kind of like
the event begin play. Inside of BP Game Instance, inside of a game
instance blueprint, this will fire off at the
very start of our game. So if I print string, I can drag backward off of this. I will type in, append. In the a, I will put
in game instance. Let's do game instance. Lives in for the b value. Let me add a couple
of spaces after that. Game instance lives
double-space. And then I'll simply drag and
drop this into our graph, get it, and plug
this into the B, a conversion node
will come in as well. So if I compile
and save and play, you can see immediately
in the upper left it says Game Instance lives zero. Alright, let's go ahead and be generous and say
instead of zero lives, you actually start
with three lives. And we're going to say
that here in our level, I'm going to compile
and save this really quickly here in our game
instance blueprint, let's say back in our level, we're going to make it so
that when your character reaches this Trigger box that
we've had out in our level, we're going to award and
extra life, good job. You've made it all the way
to the end of the level. So back in my Level
Blueprint here, you can access level
blueprint like that. I'm going to modify this
script here a little bit. In fact, I'm going to
kill this out completely. So long. And so long as you've
got your trigger Volume selected back here in your Level Blueprint, we're
going to right-click. We're getting to
add events for when we begin overlapping that. Let's do a cast to actually I'm going to
have to cast to BP pawn, cast to be P pond because
that is currently. The pond that I'm
controlling in my game. So that'll be doing
the overlapping. I have no world setting override to the game
mode currently. So just wanted to
make that clear. When we overlap that trigger
box with our bp pawn, we're going to right-click
get Game Instance. Then we're going to cast
to BP Game Instance. Inside of our bp game instance, we had a variable called lives. And let's go ahead
and drag out of this and simply increment it. Alright, so that's gonna
be all well and good. So this is great. This should print out. I will, actually, I
will print this out to the screen, print string. And we'll print out that
updated amounts right here. So when we overlap
that trigger box, we're going to add a life and printed out to the
screen compile, save. Let's go ahead and
play test is quickly. Let me set my debug object. And I did see very
quickly that when we began play it said game
instance lives three. So I'm going to
overlap this look in the upper left here as I do. So we now have four
overlap again, 56, there it is, 67, etc. Now, here's the problem
with our current setup. If I press the L key
to transfer maps, I have no way of printing out our current lives
value to the screen. I mean, on our event in it, event initialized, we are
printing it out to the screen. And when I'm overlapping
that trigger volume, we are printing it
out to the screen. But in my new map, I have no means of printing
it out to the screen. Just because I'm
feeling fancy here inside of my player controller, I am going to make our bp game instance
lives value appears. So we've got a lot of Blueprint communication going on here. So inside of my bp
player controller, I'm going to modify
this script right here. When I press the seven key, I will simply get gamed instance will cast
to our bp game instance. We're going to get the lives variable that lives
inside of there. And we're simply going to
print this out to the screen. Like so. So I'm going to
compile and save here. So understand what we have going on here inside of
our bp game instance, this is going to
exist so long as our game is alive no matter
if we transfer level or not. So inside of our
bp game instance, upon initializing our game, we're going to print out how many lives we
have to screen. That'll be three. When we overlap this trigger a volume right here inside
of our level blueprint. We're going to reach on over to our game
instance blueprint, grab our lives in, increment it, and print
that out to the screen. And then when I
transferred to a new level here are new level is going to respect our
project settings here, including our player
controller class. And in our new level. Inside of our player controller, I'm going to be tapping
the seven key to get our game instance
and it'll show us our updated and modeled
lives is carried over. So here we go. Pressing Play, Game
instance lives three. We're going to
overlap this 456.7. I'm going to press the L
key to transfer levels. Now remember up here in
my player controller, the player controller is
going to carry on over, even though the value
of the variables inside of it are
gonna get reset. Our bp player controller is going to exist here
again in this level, that is what is lording
over our pawn here. So inside of our
player controller, I'm going to press
the seven key. Now. I'll set my debug objects to my spawned in
player controller. Now when I press the seven key, you can see that that
variable has carried on. We have seven lives inside
of our bp game instance. Now before we close
out this video, I wanted to show you
how powerful this was, especially as it relates
to widget blueprints. So down in my scripting
widgets folder, I'm going to open up my WPP HUD and over MEW BP HUD graph tab. What I've done
between Camera cuts here is off of Event Construct. I got my game instance. I'm casting to BP game instance. I right-clicked on this
pin and promoted this to a variable in order to capture my game instance in a variable. If you do this, this will allow you to back in your Designer tab
to create bindings directly two variables related inside of your BP
game instance, e.g. if I was to drag in
a text widget here, instead of this saying
textblock right here over in the Details panel, I could come under
where it says binding. And now because I
created a reference to my BP game instance,
Check this out. As BP game instance, I can bind this to
my lives variable. This will still say
text-block by default. But if I compile and save, I could then MIB P
player controller create this bit of script, event, begin play,
Create Widget, create your HUD through that, and then Add to Viewport. And so then what this
would allow me to do is play my game. And inside of my B, W BP HUD, my lives should be represented
right here in my HUD. So let's go ahead and play this. And you can see
game instance lives three and we see that now
reflected in the HUD. It's bound to that lives variable inside of
our game instance. If I was to go over
that for five, you're seeing that
update as well. And I'm going to press the L
key to transfer levels six. It's still present here
in my new level as well. Alright, so there you have it, the game instance blueprints. One of the main benefits
of it is it does not reset variables
between level changes. Something to note here, if you are ever getting
advanced enough where you can create and implement a
save system in Unreal, which is obviously outside
of the scope of this course. The game instance blueprint is oftentimes the facilitator
between grabbing data from a saved game file and bringing it to
your current game, as well as writing data from a current game to a save game. It kind of acts as a go-between. Alright guys, that's gonna
do it all for this video, we will see you in the next one.
104. Compiling: Welcome. This video is going
to be all about compiling. That is this button in the
far upper left of blueprints. So our goals will be as follows. Number one, we're going to demo ways to compile blueprints. Number two, we're going to
learn how to quickly locate an issue when your
blueprint fails to compile. And number three, we're
going to show how to combine the Compile and Save actions inside
of a blueprint so that you don't have
to obsessively compile, save, compile, save, compile, save can all actually
be done with one step. Alright, I've got my
ThirdPersonCharacter tab open across the top because
I'm gonna be doing some work inside
of here shortly. But let's start by talking about what the heck compiling even is, what is going on when we're
pressing this compile button. Well, when you are
compiling a blueprint, what you are doing is you are kick-starting the
process of converting the properties and
all the script in your graph of a blueprint assets such as our third-person
character here, into a class, namely our
third-person character class. In computer
programming, when you compile code, the compiler, which is usually another program gonna take the program
that the human Rhodes, in this case, our script and all the properties and
variables and whatnot. And it's going to convert
it into a program that the computer can
actually understand. Now I can help drive home
this point a little bit further by doing this, I've got this jump input script here in our
ThirdPersonCharacter. If I was to left-click
and drag around all these nodes, do control C. I've got a notepad app
opened down the bottom here. I'm just gonna do a
Control V inside of here. This is all of the code that is backing all of our jumped
script right here. So essentially when you are scripting via these nodes
that you're linking together, there is code backing all of
this when you're compiling your checking to make sure that your code in any
properties, variables, etc, that you are, that are all a part of this,
are good to go, that it's clean and
that there's no errors, that the machine can read
it and knows exactly what to do and can
make use of it thusly. Alright. Now,
something important to know about compiling is that
in compiling a blueprint, we can be made aware of issues with our
blueprint scripts. However, note that it
won't catch all errors because some areas are
simply human in nature. E.g. over here, I brought in a spawn
system at location node. Now I can say, Yeah, I want to spawn this system, this Niagara
particle right here. But what if I have my scale
set to 000 and then I've got some event trying to spawn this system in,
but I don't see it. I may be left wondering
what the heck is going on. There must be something
wrong with my script. Well, in fact, there might be nothing wrong with my script. However, I'm not
getting the result I'm expecting because I set
the scale to be zeros, zeros, zero, meaning
I wouldn't see it. So compiling a blueprint
won't catch errors like that. Alright, here in my
ThirdPersonCharacter event graph, I've set up a scenario where I'm going to make it where we intentionally create
some bad script and then try to compile. I'm going to make it
here so that when I press the B button, I'm going to spawn some actor. Let's go ahead and
say, Man a potion. However, I am going to
intentionally leave this spawn transform input blank if I
try to compile right now, you're going to see
that when I do, it's going to throw
an error here. And in fact, that tool tip is going to say there was an error during compilation is
see the log for details. So by log is pointing to this compiler Results tab that just appeared at the
bottom of my screen. And it will let me
know that, hey, you have something
that needs addressing. In this case, my
spawn a transform PIN is invalid for us to
spawn a man apportioning, we have to tell it
where to spawn. Now if you don't see this
compiler Results tab down here, or if you accidentally
close it out, you can get it back
in the way you get that back or just
about any other tab here that is missing
is you come under your window and in here you
can find compiler results. Turn that back on. Now your compiler results shows any errors or warnings when
compiling a blueprint. And what's nice about it is
it has some hyperlinks that you can click upon to
jump to the trouble spot. So we could click right here
on our spawn transform. And that'll just show us
where that trouble spot is. So if you are somewhere out yonder in your graph way
out here and you're like, Where the heck is this error? Let's go ahead and click on it and it'll jump you right to it. Now watch what happens
to our Compile button, our icon up here when
we go ahead and fulfill the spawn and transform requirements of this spawn
actor from class node. I'm just going to
plug in the world transform of our
line trace endpoint. That's just an error
component that I had added to my third-person character who's just out a little ways in
front of our character. I'm going to plug this in here. Note that as soon
as I plug it in, the icon over our Compile
button has changed. We now see a question
mark in yellow. So when it changes to this icon, that means that some change has been made to
our blueprint here. That's going to happen whenever anything new gets added to a graph or in any new
variable or function, or macro or component
gets added. It's letting you know, hey,
something is different. Now, there are a couple of
ways to compile a blueprint. You can click on it or there is a hotkey
associated with it. Pressing F7 will
compile as well. I'm not going to
actually press a seven right now because F7 is my hotkey for starting and stopping my
recording down here. But just know that F7 is what
you can use as a hotkey. So I'm going to go ahead
and click Compile here. That green check mark
means good to go. And you can see that in the
tool tip right there as well. Now let's discuss some
compiling options. These three dots right
over here reveal them. We can save upon compiling
and we can do it Never. We can do it on success
only or always. If it's never, which is what I've had it for
most of this course. We have to compile. And then if your
compiler is successful, you want to save it directly afterward in order to make
sure that all those changes made to your blueprint or
actually saved on success only, will save only when your
blueprint compiles successfully. And always means it's going
to save it whether that compiling was successful or not. We've also got this jump
to Error Node option. You can check this on or off. It's actually a checkmark
that you can check on or off. I'm going to turn it on here. And this is going to be
pretty sweet to let us know where an error
exists in our graph. It'll jump right to
it if we make one. So I'm going to
disconnect this quickly. You can hold down
Alt and left-click, and then I'm going to
navigate to somewhere random in my graph like this. So now when I compile, it's going to jump
me right to it. I like that option on a
lot highly recommended that's jumped to error node right there under
those three dots. Now, just a quick note about that jumped to err node option. It acts like clicking on one of your error hyperlinks down here. That's pretty cool. It obviously cannot jump to
all errors at the same time. If in fact you do
have multiple errors, it will jump to the error
at the top of the list. That is the most recently
discovered error. Also, I wanted to hit back on this Save on compile option. If I go to my Level Blueprint and I click on
these three dots right here. I can see that if I go under
the save on compile option, all of this is grayed out. You're going to find that
these options are not available any level or
a sub-level blueprint. This is because the
saving of a level or sublevel itself saves the
blueprint associated with it. So just thought I'd point
that out right here. You could do press F7, that is the hotkey within a
level or sublevel blueprint. Note that it will
save the level or sublevel itself as well. Now, lastly, I just wanted
to point out once again that your compiler results will
not show all human error. So back here, my
ThirdPersonCharacter Blueprint. We can say that, yes, indeed, this is where we want
to spawn this man, a potion out in front of
our character a little bit. However, if I was to break
this wire right here, I'm going to hold down
Alt and left-click. I'm gonna go ahead and compile. And it's gonna be like,
Yeah, Good to go. Even though you may think while you're playing
the game that Hey, I'm pressing the B key, but I'm not spawning
any man a potion. Once again, unreal, cannot
know your deepest desires. It does not know
that you actually meant to disconnect this
or have it connected. So will not catch
errors such as that. Alright guys, that's gonna do it on this video and compiling. We will see you in the next one.
105. Breakpoints: Alright, welcome back everyone. In this section of the course, we're going to learn how to better troubleshoot
our blueprints. That is how to debug them. We're gonna be starting off with this by talking
about breakpoints. The goal in this video
is to learn how to create and use
breakpoints within our scripts to help
us analyze what's happening when a
script is executing. Now I've set up a scenario here. I'm going to be
controlling them IBP pond, I'm gonna be overlapping One of my specific rotating doors that we created
earlier in the course. And you're gonna notice that our game is going to freeze up, but intentionally
not unintentionally. So watch I'm going to
overlap the trigger volume. Just trust me, there's a trigger volume in front of
this first door. Nothing seems to happen, but I'm going to overlap this second trigger volume
in front of this door. And lo and behold, we freeze up the game. We have hit a breakpoint. So what is a breakpoint? It is an intentional pause or
stop that you create within a script as denoted by this red dot on this
node right here. Now the purpose of doing
this is to find out whether the script is functioning
as you'd expect. Maybe an event we're
expecting to fire off isn't. Maybe a function we're expecting to fire off
isn't firing off. Maybe a variable that
we're expecting to have a value hasn't
been set yet. Essentially, a break
point gives us a timeout to more closely inspect how
our scripts are behaving. Alright, I'm gonna currently
quit our game and explain how to set up breakpoints
within your own blueprints. So clicking the Stop
button right up here. The first thing you should
understand is that you want to make sure that you are
assessing the proper blueprint, the proper instance
of the blueprint. I'm currently looking
at my BP rotating door now note out in my level
I have two of them. I've got this guy, BP rotating door
and the second one, BP rotating door to now MIB
rotating door blueprint. And this is a blueprint
that we set up during our rotator
variable video. I have set a break
point for when we begin overlapping
this box component. Now up at the top here, if I click this drop-down, I will note that I am
currently assessing, I'm currently debugging BP rotating door to and you can see it in
parentheses right there. That is the one that I
currently have selected. What this means is that
if I am overlapping that box component for BP
rotating door number one here, this will not pause. This will not stop the execution
of my game because I'm currently assessing BP
rotating door number two. So this is important
to understand. If you have, say, 50 instances of a given blueprint out there, it will only stop the execution for when you
overlap that given instance, that given copy
of the blueprint. So here I've got BP
rotating door number two. Now how did I get
this break point, this red dot on this
node to begin with? Well, there's a
few ways to do it. You can right-click on a node. And you can see in
our right-click menu, we've got breakpoint options. The first year that I will
use is toggle breakpoint. There is there is a hotkey
F9 associated with this. So because this is currently on, I can toggle it off
and vice versa, I can right-click,
toggle it back on. Once again, with this
node selected F9, we'll toggle it
off, on, off, on. I could right-click
on it once again and remove the
breakpoint like that. I could I'm going to press F9
to bring it on once again, I could right-click on this
and disable the breakpoint. What that means is it'll
keep the breakpoint on here. However, it will not
stop the execution of our game when I do overlap
BP rotating door number two, this or drive home this point, I can click on this and
overlap that and you see it, it's a fire off, but it did
not pause my game at all. It kept that
breakpoint on there, but it did not pause the game. Now, you may be wondering, why didn't I get rid of
this breakpoint altogether? Why did I just disable it? Well, sometimes you want
to have a listing of your breakpoints
that you can view so you don't lose track of them. If I come under,
Debug are right up here and I bring on my
blueprint debugger. In this window
right here you can see it's got my rotating door. Right here are my
lists of breakpoints. And you can see I've got
this breakpoint right here corresponding with
that guy right there. So if I was to double-click
on that, it'll highlight it. That empty circle right there shows that that is a
disabled breakpoint. I'm going to dock
this right down here. And if I was to right-click on this node and
enabled breakpoint, take a look now in our blueprint debugger
under breakpoints, we can see now that that
is a filled in red dot, that is an active breakpoint. So any other breakpoints
that we have in here, it'll be listed under here. And once again, that was under
Debug blueprint debugger. There's my rotating
door and my list of breakpoints can be toggled
on and off right there. Alright, now we can
see that we have this breakpoints
set up for when we begin overlapping
this box component for that rotating door. Number two, let's walk through what happens when a
breakpoint is hit. I'm gonna go ahead and
click Play up here. Now note this is rotating
door number one. I'm overlapping that
and nothing happens. I'm going to overlap the box for rotating door number two. Immediately the game stops. We open up our event graph for rotating door
number two here. And we can see that we
have overlapped that box. However, we're not sure
exactly what overlapped a yet. So we can continue on with
our script to further assess this red arrow is showing the current node that we are on. We're currently
overlapping that box. If we click right up here, we can step to the next node
in our execution chain, FTN. The hotkey will also
jump us over there. So note that tool tip. So upon overlapping that box, we're going to check if it was the ThirdPersonCharacter
that overlapped us. Now, I was controlling
our bp pons, so this cast should fail. Now because it does fail. We have nothing hooked up off of our CAS field
pane right here. This should kick us right
on out of here because there's nothing else
to continue on with. Our script is essentially
dying right here. Let's go ahead and try
jumping to the next node. As you can see, it did not
jump over to our next node. In fact, if I bring on our
play window once again, let me just minimize this. There we can see we're
back playing our game. Alright, let's go ahead and
quit out of our game here, return back to our engine. And now let's make it so that
in our project settings, we are no longer defaulting
to the Pawn Class of BP pond, but instead we're bringing
in our ThirdPersonCharacter. And the reason
we're doing this is because in our
rotating door script, we're checking right
here to see if it was the ThirdPersonCharacter
that overlapped us. Note back in our level, I've cleared out our
world settings as well. So we're going to be respecting
the project settings, the project settings that we have for our
framework, blueprints, BP Game Mode, BP
ThirdPersonCharacter, bp player controller. And now if I was to go
ahead and play our game, we're gonna go ahead and overlap the trigger volume for
BP door number two. It is going to hit
our breakpoint here. Now let's talk about
these various options we have across the top for
when we hit a break point, this guy right here will jump us right back
into our game. It's basically saying, hey, I'm glad you stopped the game. Thanks very much,
but we would like to continue on in play. Let me just overlap this. Once again. It'll stop the game
for us once again. Next up we've got this
advance, a single frame. So then I'll just jump us
over to the next node. If one is a not
time-sensitive at all. Next up we've got this
Stop button right here, which will do the same
thing as pressing Escape. You're essentially
quitting out of your game and you're returning
back to your editor. I'm not going to
press out right now. Next up over here, I'm going to skip over
this guy right over here. We've got this locate the
currently active nodes. So if we were on our Cast to ThirdPersonCharacter
node like we are right now, that's the one we're evaluating. Then we decided to navigate
somewhere random like this. If we were to click this button, that'll jump us right back to
our currently active node. Next, we've got this
step into node that has a hotkey F11
associated with this. I'm going to show this
off in our next example. This is not a good
example right here. Next, we've got step over
to the next node, F ten. We'll do that as well. I'll press F2 to do that. And one thing to note here, as you are stepping
through things, you can evaluate the
various bits of data being passed along by mousing
over these data pins. So e.g. I. Can see has key right here is evaluated to false. So I know that our script is essentially
going to be ending right here because we're only gonna be do something
off the true branch. We're not gonna be doing
anything off the false branch. Now this step out of button, we will explore that in
our next example as well because this is a good
setup to show that off. However, something else
I want to make note of. While we're here,
you can visualize the orange pulse of
execution up to this point, which is super handy when
you're evaluating a script. And once again, it's
not just about seeing which nodes are being stopped
at and being executed, but also evaluating the
data, getting passed along, mousing over these various
pins and seeing if that data being passed along
is what you expect it to be. Alright, now let's stop
with this example. We're going to jump into our
ThirdPersonCharacter next, going to click stop up here
to show off another example. Now the reason that we are headed over here
is because we have some customer made functions that we created
earlier in the course. We can step into and step out of that we could not do
in our last example. So let's go ahead and bring in our modify health function. We traded this in our
functions section of the course and we're going to
bring in a keyboard event. Let's right-click keyboard. Let's do something when
we press the arrow key. So when we press the zero, Kayla's modifier
health, say by 0.1. Let's drag out a fear print
string, dragged backwards. Let's append. And let's append
the word health, colon double-space with
our current health. That'll bring in a
conversion node going from float to a string like so. And then let me add a breakpoint to our event node here,
you got to press F9. Now, if you do see a break point with an exclamation
mark inside of it. That could mean that that
is an invalid breakpoint. Not sure why this one
is showing as such. However, if you are
questioning whether or not that is a valid breakpoint, you can go ahead
and compile here. I know that one is going
to be good and it is. So let's go ahead and
try this clicking play. You can make sure
that you've got your ThirdPersonCharacter as your debug option to view this script firing off
in real-time if you like. Let's bring in our play
window once again. And when I press the arrow key, we are stopping our execution. We can step over. And now this is a
function that we have some functionality
set up inside of. So if I click this
button right here, hotkey F11, we can
step into this node. And now we can step through the nodes of the
function itself. We can see that we have the Modify health
function tab open along the top now and now we can step through this one at a time. We can see is that
true or false? Let's step over one more time. And now, because we
stepped into this node, I can step out of this notes. Let me step on out
of this function. You can see now we are continuing on to our
next node in the chain, which is our print string. So with the step into
and step out of buttons, you can step into something
like a custom-made function, see every step of that function, and then step out
of it if you like. Now just a couple
of notes there. The Step Into option, if it is a custom made
a function or macro, it will drill down into that. However, if it is not a
custom-made function or macro, it'll simply just go
on to the next node. As for stepping out, if you stepped into a node, it will step out to the
next node in the chain, in this case to our
print string node. However, if there is
nothing to step out two, there's no other nodes
within your chain. It will simply resume the game. Now, lastNode, we can bring in our debug blueprint
debugger option on as well. From here, we're
bringing on this window. Once again, I'd like to dock
it along the bottom leg. So I realize I'm still
playing the game right here. Here are my breakpoints. You can see I could click on
that to jump right to it. However, if you had noticed when I clicked on this
debug option right up here, we have the ability up here to disable all breakpoints and
delete all breakpoints. If you have a lot of breakpoints set up
throughout your graph, it is a real handy way
to clear them all out. And again, you can
add break points and not just on event
nodes like this, you can set them on
a function as well. On this function as well. So if you set up on all
three and you're like, Hey, I just want to
get rid of all these. Just go ahead and
delete all breakpoints, and suddenly they're all gone. And so there you have it. That's the lowdown
on breakpoints. Breakpoints are an
intentional pause or stop that you create within a script so that you
can more closely assess your scripts
step-by-step. Guys, that'll do it
all for this video, we will see you in the next one.
106. Watch Values: Alright, welcome back. In this video, our goal is to learn how we can more easily monitor data values when
debugging a script. Now this can be done
through designating variables to watch inside of a blueprint by having
an easy means of seeing and assessing data values inside of our blueprints, we can quickly see if
data flowing through R scripts is as expected or not. Now for this example, I'm gonna be working inside
of my BP rotating door, as well as my ThirdPersonCharacter
here a little bit. So firstly, in order to watch
variables more carefully, we're going to bring on
our blueprint debugger. Now I showed you how to do
this in the last video, but if you forgot or skipped
over that video inside of any Blueprint are BP rotating
door will do just fine. We can click Debug, blueprint debugger,
and that'll bring on our blueprint
debugger window. I do like to have this on a
second monitor if I have it, but since I don't if you
have a single monitor, I just like to docket
right down here. Now note inside of our
blueprint debugger, we can specify which blueprint
we would like to debug. So even though we are inside
of our bp rotating door, I could set this to be my ThirdPersonCharacter
to debug if I wanted to. However, if you did that and
you hit a breakpoint such as our zero key inside of
our ThirdPersonCharacter. It would jump you over from this graph to your
ThirdPersonCharacter graph. I'm not going to
demonstrate that for you here, but just FYI. Alright, I do have
this set to my BP rotating doors and I do
have a breakpoint set. So now I'm going to set up
some variables to watch. I'm going to watch this has
key variable right here. And the way we can do this is by right-clicking and choosing
to watch this barrel value. Now when I do this, you're going to see
a little bit of a magnifying glass
icon appear on this. But you're also going to
see this window right up here that's going
to output true or false whenever this information is requested by our branch node. Whenever this gets executed, we're going to find
out if this is true or false and it's going to print
it right in this bubble. I'm also going to set
up a watch value on our rotator node right
here, the return value, so I can see where we're at in that rotation going
0-90 degrees in the Ya, I'm going to
right-click on this. We're going to watch this
value. Simple enough. If I want to remove
any of these watches, you can simply
right-click on it. Stop watching this value. Or if you want to stop watching all of your watches,
you can come under, Debug and delete all watches that can get rid
of them as well. Now before I show this example, I wanted to make
note that inside of my ThirdPersonCharacter here, ThirdPersonCharacter,
I did set this has key boolean to true. So if you haven't
already done that and you want to play along
at home inside of BP. Thirdpersoncharacter,
B has key Boolean. I set that to true,
I compiled and Save. And here I am watching
that variable. This variable lives inside
of my ThirdPersonCharacter, but I can watch it
right from here. Alright, so let's go
ahead and play our game. And I'm going to overlap that box component for our
rotating door number two, that is this door right in our level that is
rotating door number one. However, we are assessing
rotating door number two. So here we go, clicking play,
overlapping this door. Alright, we've hit
that breakpoint. Now in the last video
I showed you that you could step through things
by clicking right here, F ten will do just fine. I can also advance
one frame at a time. So that would stop
me over in this case as well because this is
not a time-sensitive node. However, note that down in
your blueprint debugger, you have these same controls. So let's just show this
off because we can, you can see down below, we have hit our rotating door. Number two, the
breakpoint has been hit. That yellow arrow right there
denotes that I'm going to expand this out by pressing this little
drop-down triangle. Right away. We can see that we have watches
setup in here for it has key and also that return value on that loop node right there. So that is denoting that we
do have some watches setup. Note right now, this bubble
does not say anything yet because it's information
has not been requested yet. I'm going to advance over to the next node by
clicking right here. That flow of execution. We're going to advance
over one more. Now because we've hit
this branch node, this information for the
condition has been requested. So we can see that we are
watching this value and now it is prominently showing that
it is evaluating to true. Now I could just hover over this pin without the watch and find out that that information
actually is true as well. However, by setting
up watches like this, it becomes very obvious. It's a way to more easily see what data is being
passed right along. Now, if I wanted to
disable this watch, I could, while this is running here, we're
debugging this. I could click on this
little magnifying glass icon and turn it off. And I can right-click
and turn it back on once again, Bye. Choosing watches value in it appears once again down here. Also, if I was to have navigated somewhere way beyond like this, if I was to click on
that watch down here, that'll jump me
right back to it. So that's pretty handy. Let's keep stepping
right through, through this because
we can see we have not hit our second watch
over here yet. So pressing over. Alright, so now we are hitting
a time sensitive node, this timeline, this is 1 s long. So if always suppress
right here or f ten, it's going to jump me over to
this next node right away. However, I could also advance
one single frame at a time. So in doing so, I'm
going to left-click. You can see now we've gone 0.01 s because we're just advancing
one frame at a time. We can see we are watching
this return value here. And as we increment
this one at a time, one frame at a time are watched. Your value is
increasing bit by bit. So, so we can see
how this is opening up over the course of 1 s. Now we can go ahead
and click resume right here to see the final
result play out, that played out over the
remainder of that timeline, that 1 s timeline. So we can see that value. The Ya, our door
opened up 90 degrees. Maybe that's what
you were expecting. Maybe not, but these watches
help you identify if that is actually outputting
the return value that you are expecting. And so there is a quick, simple overview of what
watches are and how they can be set and utilize when
debugging your script. Once again, if I was to stop here and remove these watches, stop watching. Stop watching. You can still see
the output value of these data pins by
hitting that break point. Let me just overlap
this once again. Advance over, advance over by
mousing over it like that. However, by setting up watches, it just makes it
a little bit more prominent and easy to see. Let me just advance this
all the way to the end. Once again, we can see that y'all red there is
being outputted 90. But those watches, again make them more prominent
and easy to see. Guys that'll do to
offer this video, we will see you in the next one.
107. Message Log: All right, welcome
back everyone. In this video, our goal
is to show the role of the message log in
debugging your scripts. While this is a window
that can report out all kinds of info related
to your projects, such as lighting results
when building your level. Here, we're just going to
explore its utility in ensuring our scripts are working
as intended at runtime. So I have an example
to show off in our third person character. So why don't you come under your third-person at
Blueprints folder, find your ThirdPersonCharacter. By the way, a fun
tip for you here. If you hold down Control
and use that scroll wheel, you can make those thumbnail
images bigger or smaller. We're going to double-click
on it where I have some scripts already set
up prior to this video. What we're gonna be doing is I'm gonna be pressing
the one key. And then just onetime here, I'm going to spawn
in the fire effect. And then I am going to
promote this to a variable. So I have not done that yet, so I just wanted to show off. We can do that once again by
right-clicking on this pin. We're going to promote
this to a variable. This was a spawn actor from
class node by the way. So if you're looking for
the name of that node, it is spawn actor from class. It'll change it to
Blueprint effect fire. Once you slot in that blueprint effect
fire blueprint from the starter content
promotes variable. We'll simply call this fire. There's the name of
it right down there and we can see it is of the type Blueprints effect fire. And what we're
gonna do down here is when we press the two key, we're going to destroy this fire that we've spawned when
we press the one key. So I can drag this
right on top of the target of our
Destroy Actor function. That'll hook it up
automatically like so. We're going to make
our message log appear on something else
I'm gonna do right away is after we
destroy our actor, I'm going to set the reset
of our do want snowed. And this is just going
to make it so that I can press the one key once again to spawn another
blueprint, effect fire. So that's what's happening here. We're going to press the one key and then we're going to just onetime spawn that blueprint
fire effect at the location, the world transform,
I should say, of our simulated hand, that is this
component right here. That's just going to spawn it
at that point in the world, wherever we are at that moment, we're saving out to a variable. And then when we press the two
key, we will destroy that. Now, I'm going to
compile here and save. And let's go ahead and run this. Set my debug object here to
my ThirdPersonCharacter. Alright, so this is the tests we're gonna
be running gear. So first I'm going to press one to create fire right here, and you'll see that script firing rate up above.
So here we go. The one key there is
that fire effect. Now I'm going to press two. That's going to
destroy that fire that we created and set inside of
that variable right here. So here we go, The two
key, it has now gone. We've also reset
this do once known. Now I'm going to press
the two key again. So I'm going to try
to destroy this fire. Now I pressed it and you
can see it is executing. But now when I exit out of here, escape, watch what happens. We are presented with
the message log. In fact, we have
numerous errors. Now the reason I
have numerous errors is because it is
yelling at me that I tried to destroy this
fire that did not exist. Now what was happening here is the first time I was
pressing the one key, we repopulating this variable, this blueprint effect
fire variable. With this spawned
blueprint effect fire. Once it's populated, we compress the two key and then destroy it. Now, when I press
the two key again, we had not yet reset the contents of this
variable to be something. So this was an empty variable. This is a very common message that is spit out to you
in the message log. Now the message log can spit out all kinds of different errors that occur with your script. But this is a very common
one where it is yelling at you that the contents of some
variable cannot be found. I'm going to drag and drop
this along the top here. Let's take a closer look
at our error message here. Now you can see that these
error messages appear in the play in editor section
of our message log. And it's repeated once again numerous times because
I was pressing the two key numerous
times to try to destroy the fire
that did not exist. Now what's useful about this
message log is that it has some hyperlinks that you
can click on to take you to the location, the air. Now if you click on
Event Graph here, I'll just click on Event Graph. It'll take us to the
appropriate event graph. If we click where it
says execute Uber BP, ThirdPersonCharacter, it'll click us over to
the Event Graph as well. And if you click on BP
ThirdPersonCharacter, it will also take you on
over to that Event Graph. However, if you were to click where it says Destroy
Actor right here, that is going to pinpoint exactly as to where
the problem occurred. This Destroy Actor node was trying to find a valid target. However, this message
log is saying that that was an invalid target. The target was not valid. And that was once again, because the first time we created our fire, we
could destroy it. But the more we press two key, you can't destroy some
fire that does not exist, that has not been set inside
of that fire variable. So how can we fix a
scenario such as this? Well, you can check to see if the contents of a
variable are valid. And the way we can do this is by selecting our fire
variable right here, that blueprint
effect fire that's getting populated right here, that's getting set
right up here. We can right-click
on this and we convert this to a validated yet. Now note that once we do this, it's going to change this node
from a pill shape looking node to a node that
requires us to hook in, in execution wire to it. So now we can have
a script like this. If we press the two key, It's first going to do a check. If this is valid, meaning that there is something set inside of this variable, we will continue on and destroy whatever wasn't
set inside of it. However, if we press the two
key and it is not valid, meaning there's nothing
inside of this variable. We can do something else. In this case, I'll just
drag out and print string. And I'll just say
fired, not valid. Like so. So now if I compile and save, and we play once again, before I even press the one key. Let's go ahead and
press the two key and look up here in the
upper left of my window. It's going to say fire not valid and I can
keep spamming it. Now it's not valid yet
because we have not set the contents of
this fire variable. It has not been
populated with anything. Now if I press the one key, we have now set the contents
of that fire variable. So now when I press the
Tab key, it will be valid. So look right through here. It did fire through,
that is valid. It destroyed the actor, and we are all good. Now this message log
window will appear automatically if it catches
an error such as that, it'll open it up for you. However, if you
would like to have this message log tab
open at all times, let me just close it out so
that I can bring it back on. You can simply come
under a window. And then right down here
under the log category, you can choose to have
that message log on. Alright guys, that is
going to do it for this video on the
message log window. We will see you in the next one.
108. Searching: Alright, so if you've watched every video up to this
point in the course, you're becoming a pretty efficient with
blueprint scripting. Now let's take your
blueprint scripting to the next level by learning
some productivity hacks. In this video, our goal is
to explore several methods of searching for things while
working with blueprints. We're going to search for a
blueprint acids themselves find out where they reside
here in our content browser, as well as search for
things that may exist inside of a blueprint such as
variables, functions, etc. Now you want to be
good at this simply for work efficiency reasons. The faster you can locate assets, functions,
variables, etc. The faster you can
ensure you've traded quality blueprints that
are free of errors. Now to demonstrate some of these concepts we're
gonna be exploring here. I'm gonna be doing
this inside of my ThirdPersonCharacter. You can do this from inside of any blueprint though
that's perfectly fine. So double-clicking on my
third-person character, the first thing we're going
to learn how to do is browse to this blueprint asset. Oftentimes when I'm
working with students, they have a blueprint open, but they have no clue where this blueprint is within
the content browser. They may be off in
some random folder. And if I ask them to locate their ThirdPersonCharacter
Blueprint, they have no idea where it is. Well, there's a couple
of ways you can find it. Way. Number one is you
have some filters. You're in your content browser. You can click on a
folder of your choosing. And you can choose the
content folder because that folder contains all
of the other folders. And click on Filters, Blueprint class,
and already you are willing things down mightily. Let me just hold down Control
and scroll wheel down. And immediately we can see our ThirdPersonCharacter
is right there. To toggle off a filter. You can just click it off. That's with it off,
that is with it on. Alright, so that is one way
you can quickly locate assets is to filter for them within
your content browser. But I want to talk now about
how to find this asset if you are within this
ThirdPersonCharacter itself. Well, you've got
a couple of ways. Number one is across the top of your
Blueprint editor here, you've got this Browse
button right here. If you click on this, it'll jump you right
to where this asset resides in your content
browser, that's pretty handy. In addition, if you're inside of here and you just
do Control plus b, that'll jump you
right to it as well. So Control plus b, was that hockey, Alright, Next, inside of a blueprint, you should have a
find Results tab open by default within
your Blueprint editor. That is this guy
right down here. Now this is awesome because you can find bullet tells
you right down here. You can find things
like functions, events, variables, all kinds
of things simply by searching for it
right down here. Now, again, this should
be on by default, but there are actually four
ways to access this panel. Again, the first way is it
should be on by default, but let's assume that it's off. You can also bring this on from the toolbar by clicking the
Find button right up here. They'll open up that tab. Let me just click
it off once again, we can also access
that by coming under the window
option right here. And you've got the
ability to turn on your final results
panel as well. Also, if you have that off, you can bring that arm
by using Control F, that is the hotkey
control plus F will bring on that find
results window. Now this is our
search tool within the Blueprint editor
that allows us to quickly tracked down a variety of things such as a node name, a pen name, a node comment, a property name,
a property value. So let's demonstrate this. Shelly. I'm just gonna do a
search for modify health, modify health, and press Enter here and we can see all of our different results
matching modify health. So I only need to
double-click on one of these options here
to see what we find. There is a modifier health function places
there in the graph. This is a modifier health
function place there. And this will even jump us
to the function in this case that we created called modify health by double-click here, That's my Modify help function. And once again we had
a modifier help pure function we could locate by
clicking right there as well. Let's try some more
search results. Let's clear out this. I will type in the word spawn and look at all of
these search results. Now it is worth noting, if you mouse over
these different icons, It's going to tell you what
they are associated with. So that's an execution pin. Double-click on
that, Look at that. It's talking about these spawn execution pins right here.
I can mouse over this. This is a spawn transform, struct, double-click on
that spawn transforms. So it's finding that word spawn, and I can see it is a
pen name right there. What else we got here? We've got a spawn
sound attached. I can double-click on this, that is a function
node right there. And it lets us know
that it is a node. The fancy F equals a function. There it is. Lots of fines here
in our find results. Option, alright, let's try typing in something
like variable. Pressing Enter. And note that
I have a comment results. So if I double-click on
this comment, yes, indeed, I can even find comments that have that word inside of it. In this case, it is finding that word variable
right up there. Let's try the word
targeted because lots of nodes have the word
target on them. As you can see, lots of function nodes have
that word target on it. That one's looking for
a character object, that was looking
for a pawn objects. Once again, you can get a lot
of information by mousing over the different
search results and double-click on
item to jump to it. Let's also try to find
a property value. I'm going to type in the word five-hundred because I think I have that out here somewhere
at where? 500? Yes. I said the max default
walk speed or the max walk speed to
a default value of 500 earlier in the course. So it can even find
property value. So let me just
double-click on that. That'll show me
exactly where that is. So that can be handy as well. If you're like I put that
value 500 somewhere. Where was that again? Now this is all well and good. Being able to search
for things quickly and efficiently within a blueprint
is in fact a key skill. However, it is a more powerful
this find a results window here by being able to search across all
of your blueprints. And yes, you can do that. The way to do that
is by clicking on this button with
the binoculars icon on it right over here, find in all blueprints. Now this becomes especially
important when you are communicating from
one blueprint to another. Maybe you have a health variable like we do inside of our
third-person character here that is referenced in another blueprints such
as our example pickup, that health pickup that we
created earlier in the course. So to find out where this health variable may exist
throughout your project, you can simply do a
search for health. It Enter. Now this is where this is referenced within
this blueprint. But if I click on this
button right over here, it will find out where
the word health is referenced in any
of our blueprints. So we've got it referenced
here in our WPP HUD. There is our example pickup
or child pickup, et cetera. We only need to double-click
on any of these to jump directly inside of that
particular blueprint. Let me just
double-click on this. Get Health inside
of our bp example pickup that will open that
up right across the top. We can see where that health
variable from inside of our ThirdPersonCharacter
is being gotten and then
also set as well. Super handy trick. Alright guys, that is going to do
it all for searching here in Unreal
Engine blueprints. We will see you in
the next video.
109. Bookmarks: Welcome and
navigating blueprints quickly and efficiently is an essential skill to
getting the most out of working in Unreal
and bookmarks. Blueprint bookmarks are
one of the things that you can utilize to help you
become more efficient. In this video, we're
going to learn how to set some blueprint bookmarks, how to locate said bookmarks, and then demonstrate why this is even a useful thing to do. So, what is a bookmark? You can think of a
blueprint bookmark as a way of identifying
a section of a graph. It could be within
your event graph or the construction script that you'd like to
navigate to quickly. Now this is sort of like placing a pin or a waypoint
marker down on a map. And then simply by selecting
that marker from a list, you can jump directly
to that spot in your map or in this
case, your graph. So prior to the
start of this video, I created a bookmark
called Overview inside of my BP
ThirdPersonCharacter. And just to show you
quickly how this works, if I double-click
on my bookmark, it'll jump me to
exactly where I placed this bookmark within this BP, a ThirdPersonCharacter
Blueprint. Now let me just exit out of my bookmarks tab here and create a bookmark from
scratch just so you can follow along
with this process. Alright, so inside
of any blueprint, you can create a
blueprint bookmark by coming right under here. Alright? Now I'm going to zoom up to a given set of nodes
here that Hey, maybe I want to create
a bookmark right there. Alright, So maybe
I am working on some script and I get called away and I'm
like, You know what? I don't want to forget about
these nodes right here. Let me go ahead and
set a bookmark. So you come right up under here. We're going to create a bookmark and I'm
just going to call this my health bookmark. Click Add here. Now, it
is going to remember this zoom level as well as this positioning in
our graph right here. Now I simply need to access my bookmark in order
to jump back to this. If I happen to navigate
away from this, like so. Now whenever I bring on
this Bookmarks tab that is found under the windows menu
right up here, bookmarks. And right here you can
see your named bookmark. So if I double-click on health, that'll jump me to
these set of nodes, that same zoom level. Now you'll notice also in
this bookmarks window, we can see we have
some common nodes. Anytime you create
a comment node. And I'm talking about these common box like this attached Static Mesh
to hand socket. They're going to appear
right down here in the comment nodes section
of your bookmarks window. So whenever you are creating a comment box, and once again, you can create a comment box by highlighting a
series of nodes like this and then tapping the C key and then creating
some comment right here. You can see as soon
as I tap that CQI, it added this comment right down here under the
comment node section. I'll call this my HUD creation. And so anytime you create
a comment box like that, all you need to do, and as you can see, it
did not update that. If you compile hover, it will update that. So if you double-click on that
comment node right there, it'll jump you to that as well. So by default, by creating
a comment nodes as well, these comment boxes, you are creating a bookmark of sorts. Now one last note here, you can create these inside of a construction
script as well. Over on the right-hand side, it'll show where this
bookmark is set. We've got these all set
within our event graph. But if we had created these inside of our
construction script, it would let us know
that it is inside of our construction script
right over here as well. Alright guys, that's gonna
do to offer bookmarks here, we will see you all
in the next video.
110. Palette / Favorites Panel: Welcome back everyone. In this video we're
going to show where to access the palate
panel within a blueprint, as well as how to add nodes to the favorites portion
of this panel. So as you can see over
on the right-hand side, I have the palette panel open. I'm within my
ThirdPersonCharacter Blueprint. However, you can add this
panel to any Blueprint. I've got my third person
game mode open here as well. And you can see I have it
open in there as well. How to access this panel? It is right under the
Window menu here. That's how you can turn it on. So if it ever goes off, like so you can just bring
it back on by clicking Window and bringing on
your palette panel. This panel shows a non
context-sensitive listing of all the various functions and events that can be used
in your blueprint. And this panel consists
of two sections. Starting at the top here we've
got our favorite section. Now this is a little
bit misleading because if we mouse over
the word favorites, it says this is a listing of your favorite and
most used nodes. Now you can define
nodes as your favorite, and I'll show you how to
do that in a little bit. However, it will detect which nodes you are
using the most. And that is super handy
because then instead of searching for those nodes
in your right-click menu, you can just search right here under your
favorite section. And if you're using
something like get all actors of
class commonly, you can just drag and drop it out into your graph like so. Now this list of
your favorites is shared by all blueprints. So if I was to hop over to my BP third-person
game mode blueprint. And you can see I've got my
palette panel open over here. You can see I have this same
listing of favorites nodes. Now, one thing that is a little bit of a
bummer is that you cannot reorder your favorites by dragging and dropping them. That would be nice
functionality, but alas, that does
not exist yet. Down below we have our
find a node section which is going to allow
you to filter by class, you'll find a given
event or function node. Now you could click
right here to whittle down which class
you want to look for. Or with this set
to the all class, you can click in any of these drop-down triangles
to see what's available, such as if I come under the characters
section right here, you can find nodes like
crouch and jump, e.g. now how to add nodes to your Favorites section
right up here. There's a couple
of ways of doing this in your right-click menu. If you were to right-click
and search for a given node, and I'll just type in print
string right over there. As you mouse over
these different nodes, you see this tiny little star
triangle off to the left. That is how you can
favorite something. So note that once
I click on this, it is going to show
a filled-in star. And that will now show that in my favorite
section right up there. Print string. Let's do print text as well. You see that appears as well. If you want to take them off, you can simply click right
here to take them off. Or you could let me just
click these back on. You can right-click on them here in your favorite section, and you can choose to remove
that from your favorites. You can also choose
to add notes to your favorites by coming
under the find node section. And just like we could do
with the right-click menu by starring those down here, as you mouse over a given
function or events, you can favorite them by
clicking on these stars as well. You can also right-click on
them from them down here in the note section and choose to remove them from your
favorites as well. Now, if there did happen to be a whole category of nodes you'd like to
add to your favorites. You don't have to start
every single one of these. You can simply right-click on that category and I'll choose character right here,
right-click on it. We can say Add Category
two favorites. And then you would see
up at the top here, all of these nodes, jump,
launched, character, et cetera, have been added
to our Favorites section. And because this has listed
all in alphabetical order, you might have to scroll
up or down to see all the various nodes
you can see on crouch, right down here as well. On crouch right there, stop jumping, stop
jumping, et cetera. Now, likewise, if
you wanted to remove all these nodes from
your favorite section, you don't have to do
that one at a time. You can simply right-click
right here and remove that category
from your favorites, and they will all get unstirred and removed
from your favorites list. Other options of note here, if you wanted to remove a given
node from your favorites, you can simply
right-click on it. I'll right-click on
my Les node here and remove that
from our favorites. Another option you have
here is to right-click and choose to clear
all favorites. That'll clear everything out. Another option that
you have here is to right-click and you could
choose to load a profile. And if you choose
default profile, simply get back
all the favorites associated with the
default profile. Alright, so there you have
it, the palate panel, it shows a non-contact
sensitive listing of all the functions and events that can be used in blueprints. It also has this Favorites
section right up here that it gives you easy
access to your favorite and, or most used nodes. Guys that'll do to
offer this one. See you in the next one.
111. Collapsing Nodes: Alright, welcome back everyone. In this video, our
goal is to demonstrate how one can go about collapsing nodes within a graph
for the purpose of graph cleanliness
and readability. Now after a while a given
a blueprint such as my ThirdPersonCharacter
Blueprint right here. It might start to have a lot
of nodes and node networks, making the readability of
it's somewhat difficult. Now by collapsing nodes, you can keep your grass
looking clean and condensed. Alright, so a way
earlier in the course, we created this
line trace script inside of our third person
and Character Blueprint. And it was good. However, you might want to clean up sections of your graph, such as this, just to make the readability of it
a little bit simpler. In fact, having all
these nodes out here, it can tend to overwhelm the
census from time to time. So is there a way that you can increase the readability
of this at-a-glance, we know this all works. Crunch this node
network down somewhat. Well, yes he can. What I'm gonna do
here is I'm going to left-click and drag and highlight all of
these nodes right here, except my zero key inputs here. So with all those highlighted, I can right-click over it and
then my right-click menu. And I could have
right-clicked on any of my selected nodes right here. I have the option
to collapse nodes. So I'm gonna go ahead
and do that now. And when I do,
we're going to see that this whole network of nodes has been condensed
down into a single node. Now we can name and in fact, it's prompting us
to give it a name. So I'm just going to call
this line trace, like so. And now we have a greatly
simplified graph. We have crunched down all those nodes into a
single collapsed node. In fact, it says it
is a collapsed graph. If we zoom Obama here, now you can see as I'm mousing over this collapsed
set of nodes, we have a little bit of a
preview in our window there. So that is handy at a glance. You can sort of see what
is inside of there, even though it is very small. But if you want to
get the full view, all you need to do is just
double-click on it and take a look at the top
here you now are within a tab that
says line trace. That is the exact
same name as what we called that collapsed graph. And here is our node network. We have an input node. Here's all the inside
of this graph, and then we've got
an output node. Now, nothing is needed for this output because we
didn't have anything that was necessary to pass along any data or
anything of that sort. Now you may be wondering what the heck happened
to our Event Graph. So I'd like to draw your
attention over to the, My Blueprint panel
right over here. And underneath our
graphs section, clicking on this
little down arrow, clicking under the
Event Graph section, we not only have
access to any of our event nodes that we've placed within an
art event graph. But we also have quick
access to our line trace collapsed set of nodes
that we just created. Now up at the top here, I've also got this back
arrow and is forward arrow. Now look at this back arrow. It is illuminated words. The forward arrow is
kind of grayed out here. If I click on that,
nothing will happen. But if I click my
back arrow here, it's going to jump
me back out of my line trace
collapsed graph here, back out to my event grass. So once again, if I double-click on my line trace
collapsed graph, it's going to change
my Event Graph Tab to my Align trace
collapse set of nodes. If I click back right here, that will set me back
to the Event Graph. Now I could also
just click right here on my Event
Graph to get back. And now back over here in
the My Blueprint panel, I can jump back into that line trace collapse set of nodes by
double-clicking right here. That'll get me back there. And also I can jump back
to my Event Graph by double-clicking on
the Event Graph option right here as well. So just showing
off different ways to navigate your
graph right there. Now, if you ever wanted to do
your collapsed graph here, all you would need to do, let me zoom back up on my line. Trace collapse graph is
simply right-click on it. There you've got expanded
nodes, so click on that. And that'll set all those
nodes back into your graph, like you had it before. And you'll also notice
that that collapsed graph now no longer
exists underneath the, underneath the graft
Event Graph section of the My Blueprint panel. Now, moving along here, we're going to demo
collapsing nodes that have other nodes plug into and
out of the collapse nodes. So I've got a setup right here. We're, if I press a to key, I would check this enums that I set up earlier in the course is health status enumeration, in which I have the possible
values of super okay. And her badly. And depending
on what this is set to, if it is super, I was going
to change the character. Movement components. Jump z velocity that is
controlling how high my character can jump to 1,400 if my
health status is super, if it's okay, I'll
leave it at 700. And if I had this
set to hurt badly, I would set my jumps
the velocity 2350. Now I'm just going
to demonstrate here again what
would happen if I was to collapse nodes
that have other nodes plugged into and out
of the collapse nodes. Now to demonstrate this,
I'm going to simply select these three nodes right here. So note these wires
right here, right here, and right here, and
even right here, they need to have
something to plug into. So when I collapse
these nodes and even I've got something flowing
into this selection nodes. So I'm going to
right-click on this. I am going to
collapse these nodes. And now check it out. My collapse node
looks like this. I've got an input pin, but I've also got
some output pins as well because we need to pass along this character movements information to
this set jumps ie, velocity notice, and
we also need to pass along those enumerators as well. So I'm going to name
this particular graph, my collapsed health graph. That's a fine name. And now if I was to double-click
on this and open it up, we can see that we've got
one execution input pin, and we can verify this by jumping on back to
our event graph. There is my one
execution input pin. Let me double-click
on this. Once again. Let me clean this
up a little bit. But it automatically set up some output pins on
this output node. So we've got three
execution output pins and one character
movement component, output pin as well. Now this does enable you to name these if you didn't
like you, you know, new enumerator six, I could
name this two super okay. And her badly. In fact, that would not
be a bad idea just to make that clear, more clear. Okay? Okay. And we'll
change this to hurt badly. So now if we were to jump
back to our Event Graph, just seems to make a little
bit more sense right there. Alright, so there you have it collapsing knows now this
is something I usually don't recommend until you are in the final stages
of your project. And you're happy with
all your scripts and you just want to clean up
your graphs a little bit, just for readability sake. Nice handy trick that
you can take with you guys that'll do it
all for this video. See you in the next one.
112. Custom Layouts: Alright, welcome back everyone. Well, after you've spent
some time working in Unreal, you will no doubt come up with your own way
of doing things, your own workflow, if you will, in your own way of laying out all these different
informational panels, not just inside of a Blueprint editor like
I have open right here, but inside of any of
the editors in Unreal, that goes for your level editor, Static Mesh editors,
material editors, all that kind of stuff. So then the question becomes, is there a way that I can save a customized layout that maybe
I want to load in later. The answer to that is
yes, of course you can. So to do this, you can find this option under
the windows menu. If you come under Window in
any of your editors here, window under the layout section, this is where you can create and save a customized layout. You can load that layout, you can remove that
layout, et cetera. So we're gonna show how
to do that in this video. Now want to point out
here that while I am in the level editor, I have this option under the
Window section right here. If I was to jump into my
third-person character. So I'm in a character
class blueprint and I come under window. I can see the layout
options and I can create a customized layout
right down here as well. And let's just jump into some other random
editor as well. I don't know, I'm
going to come under started contents maybe prompts that good old chair Static Mesh editor.
Open that up. Sure. And under the window
option right here, I have those layout
options as well. So what I am going to do before I create my own custom
layout is I'm going to bring on various window panels here and organize
them to my liking. And I'll start off here in my static mesh and nurse
will come under window. I will turn on, say my message log. Sure. I'll say I want to
dock that up next to my panels right up here. I'll then come into my
ThirdPersonCharacter Blueprint. Let's bring on another window. Let's see, I will
bring my output log. Sure, I'll dock that down here. I'm going to put
my level bookmarks next to my blueprint panel. Like so. I will take my palette panel and I'll also put it
next to my components. Sure why not? You have the benefit
of pause by the way, so you can see and remember where I am placing
all of these panels. And then I'll come
into my level editor. I've got my Levels window open from earlier in the course. I've placed that back on. I've also got my
world settings on. How about I bring on the
place actors panel as well. And let's see what
else do I got here? I will bring on, Let's
bring on world partitioner. This is if you're
working with landscapes. So I'll have that open
up over here as well. Okay, so with all
of these layouts, customize how I quote
unquote, like it. I'm gonna come under
my window option here. And I'm going to come
under save layout. And I can save my layout as it will bring up a
little dialogue here. And I'll just call this
my costume layout. And for my description here, of course it is
optional as it says, I'll just call this
my example layout. I'm gonna go ahead
and click Save. Let me know that
it has been saved to that directory
right down there. And now what I'm gonna do
is come under a window. And in my Load layout options, you can see my custom layout. But that's what I
currently have in place. So I'm going to
default this back to the default editor layout. Now when you do this, it's going to close out
your engine and default, all of your window panels back to where they
were by default. So this is my
static mesh editor, my third-person character. I've got my details
panel over here. You can tell it that
palette panel is all gone. Where are my windows down here? They're all gone. And back here in my
level editor itself, I'm missing my levels
tab over here. Where's my content browser? I'm missing my world
settings, world partition. It's all back to the
editor defaults. Now, I go back under a window. I can load that layout. And wallah, you can see that my palate panel is back on
right where I put it in. My bookmarks panel is
back right over here. Everything is right
back to where I had it. Level editor, place
actors, panel, levels, tab world settings, world
partition, et cetera. So it is worth noting
here that when you go to create your
own custom layout, once you go to save that layout, you're saving the layout for not just the current editor
you are working within. In this case, this would
be my level editor, but you're saving
that layout for all of the other
editors as well. Including in my case here, these static mash editor and the blueprint
editors as well, to remove allow,
you'd simply come under Window remove layout. There is my custom layout. When I select this,
I'm going to get a dialog pop up here saying, Are you sure you
want to do that? Now if you click Okay, now, you'll notice that
nothing happened to my custom layout because that is the layout that I
am currently using. So it's not going to remove the layout that
you are currently using. So if I truly wanted to
remove my cousin layout, I'd have to first go
back to another layout. In this case, I'll go back
to my default editor layout. And now if I was to come
under our window option, under the layout section and I was attempting to
load that layout. You can see it no longer exists. Now while we're here, I also wanted to point
out that you could import an existing
layout or you could, when you are saving a layout, you could look to export
a layout as well. I'm not going to
demonstrate that here, but wanted to make
you aware of that. Highly recommend that you create your own custom
layouts as it will help you improve your workflow. Guys, that'll do it
all for this video. See you in the next one.
113. Tips & Tricks: Welcome. In this video, the
goal is to arm you with additional
tips and tricks to help you work more efficiently with
blueprints in Unreal, not a show off these tips
and tricks I'm gonna be working inside of Maya,
BP ThirdPersonCharacter. However, note that
you can be working in any of your blueprints. Alright, with our
ThirdPersonCharacter open, I wanted to draw
your attention to these two arrows right up here at the top of my Event Graph. They are back and
forward arrows like you see in any sort
of internet browser. What this allows you to do is to move from graph to graph. Now, right now is grayed out. And if I tried to click on them, nothing happens because
we just open this up. However, as I click on different areas of my
my Blueprint Panel or my bookmarks area that
I have open right here under Window bookmarks. As I begin to click on
some of these things, as I say, jump around to
where my zero input key is. I come into my
turbo run function. Or I navigate to one of my
Blueprint Interfaces here, Let's go The interact function, or one of my macros on fire, or jumped to one of
my bookmarks here, I'll go to my health bookmark or even my overview bookmark. Now you saw me click on a
variety of things there. So now I've built up a history, and now I can use these
back and forward buttons to navigate to those things
that I had clicked upon. So if I go back here,
I'm going to jump back to my health
bookmark, back again, to my macro here, Maia on fire, macro, back again to my
interact interface back again. And as you can see, it works like any of the
Internet browser, back and forward
buttons, forward, back, forward, back, et cetera. Now, as you mouse over it, it's going to say
you can right-click to see a full history. I know at one point in
time this was working. However, if I try to
right-click right now, I can't see that full history. I got to imagine
that functionality is going to find its way back. Alright, next up, I
wanted to show you how to copy and paste values in unreal. Now this is something I know, you know how to do through so many other computer
applications. Control C to copy, control V to paste. But this is one of
those tricks that for whatever reason escapes a lot of people's minds
as even being possible. What I'm gonna do here
in my components panel, and I'm going to jump over
to my viewport here because this is going to be a little
bit visual in nature. I'm going to add a
brand new component. I'm going to add a nice
Agora particle system. This is gonna be attached
to my Capsule Component. I'll leave that Niagara name. That's going to be just fine. I'm going to set a Niagara
system asset here. By clicking this drop-down, I'll set one of these
magic ones. Sure. Now currently it is
appearing right at the center here
because this is at the 000 location relative
to our Capsule Component. This is attached to my
counselor component. But let's say I wanted this
particle to appear right at the location of my
simulated hand component. Well, this would be as simple
as copying this location. This is a relative location. This components
relative location relative to our
Catholic component. And to do this, I can simply
right-click right here on location, right-click Copy. You can see shift plus rice. Right mouse button is the
hotkey for doing that here. Then I can come over to
my Niagara particle, right-click right here,
and I could paste it. So for whatever reason, that is a super handy
trick that escapes people's minds as
even being possible. But trust me, I used
that tip all the time. Next, I'd like to draw
your attention over to the My Blueprint panel where
we've got this gear icon. And if I click on this, what I want to talk about is this top most option showing
inherited variables. Currently I have
this checked on. Now if I check this off, you're going to
notice that a lot of variable categories here
are going to go away. And the reason that
those go away is because those were inherited variables category
there were inherited from our parent
class of character. Now the reason that
this is important to even know about is
because if you're creating some base class and then you inherit
from that class, you may be wondering like, Hey, where all the variables that
I set up in that base class, where do they even exist? Now to help drive
home this point, I'm going to open up
another blueprint here. Earlier in the
course, we created this child character blueprint, this one inherited from my
third-person character. So let me just open this
guy up really quick. This is a child. If you ever see this,
you can open it up the full blueprint editor
by clicking right here. You can see that the
parent class here is my BP third-person character. Now if we look over in the
variable section of the child. Like wait a minute,
where all the variables inside of
my parent class here, I created all of
these variables. I hit actor variable, a sock, and a variable. These are variables
that we credited throughout the course.
Where are they? Well, if I go into the
child and I click on this gear icon in the My Blueprint panel and
show inherited variables. And we open up our
variables category here. Now we can see all of those
various variables that we had set up within
our parent class. Next, I'd like to draw your
attention to a gear icon that's located in
the far upper right of our Details panel. If you click on this,
you're also going to see a variety of options. I'm going to talk
through some of these that I really like using, such as show only
modified properties. If you check this on, you will whittle down your
details panel to showing just the properties
that you modified. That is super handy
for knowing like, Hey, what in the heck did I actually change about this component? I find this especially
useful for something like the Character Movement
Component because the Character Movement Component contains all sorts
of properties. So if I want to find
out the just the ones that I have modified, I can click right there and show only the modified properties
versus if I check this off, this huge laundry list of properties that I'm
presented with otherwise, some of the other
options that I like to explore within that menu, we've got to show all
advanced details. What the heck is that? Well, in any of these
given categories, we've got some advanced
properties that are lesser known, lesser use, et cetera. You can click and show
these like so manually. However, if you
didn't want to do like I'm doing right now, and exposing them
all one by one. You can simply go into that gear icon and
show all advanced. And it'll turn all of those advanced
categories on right away so you don't have
to click them all on. That's handy. Let me
just turn that back off. Something else
that I like to use here is in this category, I can collapse all categories
or expand all categories. Once again, I've
got my character movement components
selected over here. There's a lot of different
categories here. Character movement, jumping,
falling, component, tick character
movement, networking, a lot of different categories. So if I want it to
collapse them all, I could just simply click
on that and see all of the individual
categories so that I can open up just the ones
that I'm interested in. And of course, I can
do the opposite, which is to expand
all categories. So that's an easy
way of opening them all up without having
to do it one by one. Alright, Next, I'd like to
talk about what this hide unrelated button does along the toolbar within
a Blueprint editor. Now that really
see this working, you need to be within
your Event Graph or your construction script
or function or a macro, something with some nodes. I'm going to highlight
my capsule component within this node network. And I'm going to
click on this button. This is like an on-off
toggle button right here. When it's blue,
it is toggled on. When it is gray,
it is toggled off. Let me just toggle that back on. What this has done is
it has grayed out. Any nodes is ghosted them out. Any nodes that are unrelated to the one that I have selected, one or ones that
I have selected. So why are these all
illuminated yet? Well, my attach actor
two-component nodes right here, they are reliant on the
capital component because they are plugged into
the parent input. These spawn actor from
class nodes right here. They are reliant on the world transform that we're getting
from the Catholic component. So those are
illuminated as well. Now if I was to
zoom on back here, you can see that
all the other nodes are ghosted out as well
because they are not related to the one that I currently have selected,
this Catholic component. Now this is extremely helpful if you have a tangle of wires, it's hard to make heads or tails of what your script is doing. And you're really trying
to shine a light to focus in on just a given
subset of nodes. Now I also wanted to point
out here that right to the right of our hide unrelated button here we've
got these three dots. If you were to click on this, you have the option
to lock node state. Now, if I click
and turn this on, and we can now see that it's
on with that checkmark. What that's gonna do is it's
going to keep all nodes in their current state
highlighted or doses. So that means if I was to click elsewhere and click
on another node, it's going to keep all the
other nodes still go sit out. And the ones that I had
locked to being illuminated, they will stay illuminated
until I unlock them. So that is good to know. Alright guys, there
are some tips and tricks for working within
Unreal Engine blueprints. Hope you'll find them useful. We will see you all
in the next video.
114. Productivity Hotkeys: Alright, welcome back everyone. In this video, our
goal is to summarize all of the productivity boosting shortcuts built into the
Blueprint editor so that you can construct and navigate your scripts more efficiently. Now for starters, I'm
going to show you where hotkeys are set inside of Unreal so that you can customize your productivity
boosting hotkeys for all areas of the engine, not just inside of
blueprints but everywhere. So where can you
customize these hotkeys? Well, that is done in
your editor preferences. You can access your
editor preferences by coming under the Edit
button right up here. Editor preferences. And
with this tab open, I'm just going to
open it in along the top right, up here. Along the left-hand side, you've got keyboard shortcuts. You click on here. And this is where all
of the various hotkeys are set for every
area of the engine, every editor, Blueprint editor. Here's where we see some
hotkeys such as compiling F7. You've got backspace
for going to a parent graph control plus F is going to bring up
that find menu, etc. Now this is obviously
great because if you find yourself doing a given
action again and again, you can create some
hotkeys for yourself. Also, you can customize the
hotkeys to your liking. And in fact, that is
valuable for me to do here because the F7 key, which is currently bound to compile is also the hotkey I had bound to my OBS recording software for starting
and stopping my playing. So if I wanted to
change this out, I could just simply click this right here and say
I want this to be the clicking that
space will go F8. And you can also add
a second binding. So I can say, sure, F9 is gonna do that as well. Now there's no Save
button or anything here. So if I was to go into my
ThirdPersonCharacter Blueprint and make some kind of change
like just snipped this wire, then hook this back up again. Now you can see it's
asking me to compile. So if I was to press
F8, that'll compile it. But let me snippet once again
and hook it back up again. And if I was to press F9 and obviously you can't
see me pressing those. You're just going to trust it. I'm doing it. F9, That's going to
compile it as well. So real handy way
to customize you're hot key bindings for various
areas of the editor. Alright, so with
that out of the way, I'm going to show
off how to perform a bunch of hot key commands
within blueprints. These are gonna be specific to blueprints that you
should know about. Now, gone through a lot of
these throughout the course. But this is going to
serve as a great summary. So back in my
ThirdPersonCharacter, just find a selection of nodes, if you will, to
play along at home. If you want to select any node, it's as simple as left clicking
on it, that'll select it. If you'd like to add
to a given selection, you can simply hold
down the Shift key. I'm gonna hold down Shift
and left-click like so. If you would like to
toggle a selection, you could hold down the
Control plus left-click. Like so. To create a marquee selection, you can simply left-click
and drag and you're gonna get this little
dotted line box. And whenever this touches, that is what you're going
to be selecting that the marquee selection
left-click and drag. If you'd like to add to your marquee
selection right here, you could hold down
Shift and left-click, and then you can add some
nodes to it like so. If you would like to remove selections from your
marquee selection, you can simply hold down, Control, left-click and drag, and that will remove whatever your marquee selection touches. So those were a blueprint
selection commands. Alright, navigation commands
you should know about. You've got the right mouse
button holding this down. We'll drag you around
the entire graph. You've got this hand icon
to drag around like so. If you'd like to
zoom to selection, you can simply press
the home key on your keyboard and
that'll zoom in on whatever you have selected. Frame it up if you will. If you'd like to zoom in
and out on your graph, that is simply scroll
willing in and out like that scroll
wheel up and down. Now if you would like to
zoom in Beyond scale 1.1. So right up here
is your zoom level in the upper-right Zoom one, colon one, if you'd like
to zoom beyond that, hold the Control key, and then you can
actually zoom in Passat up to a zoom
level of plus seven. Alright, let's see
some generic commands you should know about
control plus b. That'll jump you to
wear this asset. In this case, the
ThirdPersonCharacter lives within the
content browser. Let me jump back
inside of there. You have control plus S that
will save your blueprint. Then we have generic sort
of computer commands here where if you were to do something like Control plus y, that will redo something, Control plus z that
will undo something. So let's explore that by simply moving this node
down a little bit. I'll do Control Z to undo that, Control Y to redo that, to find something in this blueprint you can
do control plus F. I also have this
fine results window open right down here.
Let me close this out. So if I was to do
control plus F, that'll bring in
my final results. If I was to try to find
something like say My anything related to health,
I could search for it. They're just within
this blueprint. However, if I wanted to find
something in any Blueprint, I would do Control Shift and F, that'll bring on my find in
any blueprints menu here. And if I was to type in
health now and press Enter, I can find out where
the word health is referenced within any
sort of blueprint. Thirdpersoncharacter, my WPP, HUD example,
pickup, et cetera. Now, as you remember from
earlier in the course, F7 is the default hotkey for
compiling your blueprint. I did change it
for me personally, in my editor preferences, I changed it to F8, F9, but F7 is the default
way to compile your, alright, some variable actions
you should know about. Let me just go to
some empty space. I'm just going to quickly
bring on an ad node. Operators, Add a way to get
and set a variable quickly. If you're going to be plugging
it in on the input side, you can simply left-click
and drag on top of a pin like that to get the
contents of that variable. However, if you're going
to drag and drop on the output side of a node, left-click drag on top
of that pin and you will automatically bring in a
center of that variable. You should also know
that if you hold down the Control
key and left-click control plus left-click and drag this into a graph
and drop it anywhere. You can get that variable
if you hold down the Alt key and
left-click and drag, you can bring in a
center of that variable. And if you're not sure what you want to do with
that variable, you can left-click drag and then you get that menu for
getting or setting. And that's a way that you can decide on the fly what
you wanna do with that. Now, something a lot
of people are not aware of with variables in
the My Blueprint panel, you can reorder these by
simply dragging them around. So if I wanted to place all of my float variables
near one another, I can simply
left-click and drag. So whichever one you're going
to kind of drag on top of, it's going to jump that
right above it, like so. So you could do
something like that to organize your variables, all nice in your
myvariable section. Next, I'm going to show off at various node actions
you can take. And I'm going to
delete out a few of these getters and
setters right here. I'm going to leave this
add node right here. I'm going to also
right-click and bring in a custom events. I'm going to leave that at
a generic name right now. I'm also going to bring in one of my
custom-made functions, my Modify health
function as well. Alright, first we've got
node specific context menu. If I was to right-click
on a given node, I will bring up a node
specific contexts Menu things that I can
do with that given node, I could add a breakpoint
or toggle a break point. Those are two very
common actions. Breaking node links is
a very common action. Refreshing a node is
a very common action. Obviously, you've got
your copy and cut, duplicate, all that
kind of stuff as well. Note, however, this was my right-click menu for
this function node. If I was to right-click
on this addition node, check out one of my options that I have specific to this node. I have the ability to add a pin. I could add a pin
specific to this node, that one is not available. If I click on this function
node right here, however, different nodes may have
different node actions such as this addition
node right here. Now some nodes do allow
you to double-click on them to go to that
associated node or a graph. This is a custom made functions. So if I was to double-click on this function that
I created earlier in the course that will open up that given function tab to show me what is all
inside of that function. So that's good to
know Timeline nodes. You can do that as well. To open up the Timeline Editor, move a note around, you know that you can
already left-click and drag it around like this. However, you can also
use the arrow keys on your keyboard to
nudge it up and down, left and right, et cetera. To delete a node,
you can simply have it selected like this and press the Delete key to rename a
node such as a custom event. Note again, this is not
available on all given nodes, but custom event where
you can name it. You can simply left-click
on the title right here. And that will allow you to
rename it my costume events. Press Enter. Alternatively, you can press F2 with that selected, and that'll allow you
to rename it as well, renamed custom event. Other commands here, let me just delete these
out and bring on a few fresh nodes are going to right-click bring
in the seven key, will say seven key. We will modify some health. And let me just go back here, accidentally
double-clicked on that. I'll bring in a
delay node as well. So you should know
by now that if you select the node and
press the F9 key, you can add a
breakpoint for that, and I can do that
for each of these. So each of these has
a breakpoint on it. To clear all breakpoints, I can do Control Shift and F9, that'll get rid of all
of them right away. To cut a selection, I can simply do Control X. Obviously control a
V is to paste that. To copy a given selection. I can just have a
couple of nodes selected like this
control C, control V. You should know that
from just about any sort of computer
application. Let's see to duplicate
a selection. So I'm just going to select
these and do Control plus D, and that will duplicate them. And lastly, you
should know by now that you can add
a comment around a selection by simply selecting the nodes that you want to create a comment around. Like all these three, press the C key to add a
comment box, my comment box. And again, once you have created a comment box in your
bookmarks window, which is accessed by Windows. Bookmarks. You should then be able to find that comment box
somewhere in there it is right down at the bottom
is known as Comment. However, if I compile, now update to my comment box, if I was to navigate
away from it, I could double-click on it
to jump to my comment box. Alright, various pin actions
you should know about. Let's bring on a couple
of nodes here to help facilitate this discussion. You know what, I'm
going to bring on a spawn actor from class node because that's a
good one to demonstrate with. If I was to right-click
on a given pin, like my spawn
transform right here. I'll bring up a menu of different pin actions
that I can take, can promote this to a variable that's a very common pin action. You can see that on
just about any pain here promotes a variable also with a spawn transform or
a vector or a rotator pin. If you right-click on this, you can split the
Struct Pin because a transform consists
of location, rotation, and scale data. So foster right-click on this. I can essentially expose the given components
of that pin, the location, the rotation, and the scale data
of that transform. If I bring my Add
Node back on here, I'm going to right-click,
bring in that add node. If I was to right-click
on these gray pens, these are wildcard pins. I could right-click on it. And I've got
different pin actions I can take here as well, even though these aren't
listed underpin actions, I consider them pin actions. I can convert the pen
to a given datatype. So if I know I want this
to be an integer plus say, a float pen, I can change
those accordingly. Now sometimes as you begin to
create some spaghetti code, you've got wires going
every which way. Sometimes you just
want to emphasize a connected wire just so it's easier to read, so to speak. So if I was to hook up
one of my wires here, let me just take any
float here health, going to drag it
on top of there. If I was to mouse over this pin, you can see how it illuminates
that wire right there. And it works both ways. It doesn't matter which side of the wire here I'm mousing over, but you can see
that gradually that wire gains in strength and
illuminates a little bit more. So that can just help for
readability purposes. Now let's say that I wanted to connect this variable
to a different pen. I could snip the
pen by holding down Alt and left clicking on the
Pen tool snippet like that. However, if I wanted to move it, I could hold down
Control left-click and drag it to another
input as well. And again, that works on both sides of our
connection here. So if I wanted to move
this pin as well, I could hold down Control, left-click and move it. Or if you want to
snip that wire, hold down Alt, left-click, and that'll snip that wire. Alright, And finally, let's
show off the hotkeys for adding some of the most commonly used nodes
to your graph. We've got holding down
the B and left clicking. We'll add a branch node. If you hold down the
D key and left-click, you'll bring in a delay node, use those all the time. Hold down the S key and
left-click that brings in a sequence node, the GT, and left-click that
brings in a gate node, the M, M as in Mary, and left-click, they'll
bring in a multi gate node. If you hold down the
F key and left-click, you bring in a for each loop. If you hold down the
N, N as in Nancy key, you left-click and that
will bring in a do n node. If you hold down the 0 key and left-click, I
do want snowed. And if you hold down the
P key and left-click, you will bring in
Event Begin Play if it has not already been
added to your graph, I use those hot
keys all the time. Well guys, that is going to
do it all for this video. We'll see you next time.