okay guys we are back and in the
previous video we were working inside of
our light blueprint and we were focused
on adding the components or things that
are going to make up our blueprint here
so we've added our static mesh which
we've renamed to lamp fixture and then
it's an appropriate name because it
looks like I'll have fixture there and
we've also added a spotlight to give us
a little bit more illumination with our
little blueprint light here we've added
a box collision which will be our
trigger volume that when the player
enters we could fire off events and let
us know when the player has entered or
exited our box collision here and we
also added a text renderer component now
our text is currently invisible we've
set this to hidden by default as we're
going to turn this on later when the
player enters this volume letting them
know how they can press a button to turn
on and off our light and that process of
actually being able to turn on and off
the light we're actually going to do
that in the next video in this video
what I wanted to do instead was recreate
that same setup that we did for our
level blueprint so if you recall back in
our level we could fly into this room
and turn that light on and then we can
fly out and turn it back off if we hop
up to the level blueprint here and we
open it up that script that we set up
we're gonna recreate this inside of our
class blueprint now and you may be
wondering again why are we gonna do this
why what's the purpose of redoing this
if we've already done it in the level
blueprint if it works the real reason
why we want to show you this is to kind
of help display the modular aspect in
benefits to using class blueprints and
I'll show you why here in a moment so
let's go ahead and close our level
blueprint let's go back to our light
blueprint and let's hop over to our
event graph so we're on the event graph
and I'm gonna pull this up just a little
bit more something like this zoom in so
we're now on our event graph and we want
to begin scripting that same
functionality that we had in our level
blueprint inside of our class blueprint
so how do we go about doing that so we
have our in the background there we have
our blueprint selected
in the level blueprint if you recall
when we selected something in the level
and we open and opened our level
blueprint we could right-click in the
graph and the level blueprint would know
that we have something selected in the
level and it would offer up suggestions
for us to take on the actor that we have
selected
however with class blueprints it's a
little bit different so we have our
class blueprint selected if we
right-click in the graph in the event
graph of our class blueprint so I'm
gonna right click notice we do not get
those actions we're getting something
else we're getting context-sensitive
actions for text renderers and the
reason we're getting context-sensitive
actions for text renders is because we
currently have our text or indirect
components selected over here so class
blueprints work similar to level
blueprints however class blueprints are
only aware of their individual
components they're not aware of the
things that are placed in the level
they're only aware of their components
so if we select our box collision here
and then we right-click now we're
getting contextual actions for our box
collision and we can do the same thing
for our spotlight or lamp fixture etc
but I just wanted to point that out
because there's a little bit of maybe a
little bit of confusion there on why
things are different
versus the level blueprint versus the
class blueprint so kind of wanted to
illustrate that so with that out of the
way we know the script that we want to
create we want to create this script of
the delay well actually I want to kill
those two ladies we're not going to do
the delays for the class blueprint
version of this we're just gonna have
the player overlap our box collision and
toggle the visibility of our new
spotlight so that's the script that
we're gonna recreate inside of our light
blueprint so let's go ahead and start
working on that so again what we're
gonna do first of all is need to get a
reference to our spotlight now there's a
couple different ways that we can do
this let me maximize this a little bit
more we can take our spotlight component
here and we can left-click and drag that
directly into our graph and what this is
gonna do when we release is add a new
node called a get no now we are
currently using a getter here just as we
did with the level blueprint and I keep
popping back to it but just as we did
here this
pointlight is a getter to the point
light in our level inside of our class
blueprint here this spotlight getter is
a getter for the component spotlight so
we are actually getting a reference to
this spotlight component now from this
we can modify its properties or again
access that visibility setting to turn
our light on and off which is what we
want now there's a couple other things I
want to show really quickly before we
continue down below the components down
under my blueprint panel you may have
noticed that we have a list of our
components again these components
depending on your workflow depending on
how you like to work you could create
your class blueprint add all the
components that you need to make up your
blueprint and then close the components
window and no longer need to work with
it however how would you access those
components how would you drag them into
your graph and work with them that's why
they are listed here inside of the my
blueprint panel because you can perform
that same procedure of taking the
spotlight and left clicking and dragging
it into your graph however when taking
it from the my blueprint panel when I
release here you'll notice we're gonna
get a little context menu and it's gonna
give us two options now we can either
get it get reference to our spotlight or
set reference to our spotlight and if we
choose set we're gonna get a little bit
of a different node the center will
allow us to change this spotlight to a
different spotlight so if we had another
spotlight variable we could plug that in
here and say set our new spotlight to
equal a different spotlight for example
that's what the setter would do for us
we're not going to worry about the
setter so I'm actually going to delete
that but I just wanted to show that
really quickly again also if you close
your components one only you don't know
how to get it back you go to the window
option here from the toolbar and scroll
down until you find components and that
will pop it back up for us so I just
wanted to show that really quickly
depending on your workflow with earlier
versions of an origin for the components
window was its own separate tab so it
was not included when you are working on
the event graph so if you're on an
earlier version of unreal you may not
even see this components window but as
of I think it's 4.6 or four dots
and this this was added so that you
could see it from any of the graphs that
you're working on so continuing there's
one more thing that I wanted to talk
about regarding getters and setters
there's a there's a quick shortcut that
you can use when dragging from the
components window we didn't have to
actually do anything we just left-click
and drag and drop it in we can hold the
Alt key while dragging in our spotlight
and that will perform a setter as well
so it's just a shortcut of quickly
performing a center or a getter you
could do the same thing from the
components window down here if you hold
down ctrl and drag in our spotlight that
will perform a getter if you hold down
alt and drag in that will perform the
setter then I say getter for the getter
for this one that's what I meant
so getters and setters so we have a
bunch of them in here we're gonna kill
four of them here so that all we have
left is our getter because that's what
we want to worry about for right now so
to toggle the visibility of our light we
kind of already know how to do this we
just need to drag off of our spotlight
here and search for toggle visibility
and it's right there right there ready
for us so let's go ahead and choose
toggle visibility and that's gonna add
the node for us now we need to add our
overlap events for our box collision
however before we do this I kind of want
to rename these so that they're a little
bit more clearer so it's not just box
and text renderer and I think spotlight
is fine really I'm fixtures fine too but
really it's these two I'm just gonna
riesling our box trigger here before we
add it and I'm gonna click on it again
it's gonna give me the opportunity to
rename it I'm gonna rename this to
trigger so it's a little bit clearer and
for our text renderer I'm gonna press f2
on it now with it selected that I'll
also let me rename it we're gonna call
this the help helpful text because this
is gonna be the helpful text for the
player so they know what to press when
we get to that portion in a later video
here so back to our trigger here let's
go ahead and select it now if we right
click inside of our graph now so what a
right-click on side of our graph and now
we can add events for our trigger so
let's go
and add our collision and there's our
overlap events now kind of wanted to
point this out notice it says on
component begin overlap and not actor
because we are talking about components
that we are overlapping the actor is
this light blueprint entirely so we are
talking about a component of the light
blueprint actor so let's go ahead and
add a on component begin overlap like so
and I got to move these down just a
little bit can I get them out all the
way there and it's gonna give us a bunch
of other pins about the component that
we could use to determine the types of
collision that occurs with this trigger
box we're not going to worry about any
of those all we're gonna do is take our
executable wire here and plug that
directly into our toggle visibility now
before we had a delay we're not gonna
use that for this particular example we
just want to turn it on and turn it off
when the player enters and exits our
trigger volume some of the select the
trigger again and gonna scroll down just
a little bit I'm gonna right click add
event for trigger under collision and
now we're adding the on component end
overlap so I'm gonna select that and
just as we did before gonna take the
executable now left-click and drag and
plug that into our toggle visibility
like so so our script is complete now we
can compile let's compile and save and
I'm gonna squish this back down again
and zoom out so you can kind of see it
like that so it's in the background
there now let's test this let's play in
the editor here so I'm gonna play then
you make sure my sounds down let's play
in the editor here now when I run over
to it it's on by default there's one
thing that we forgot to do actually I
made escape let's go back to our light
blueprint here let's select our
spotlight and then over in the details
panel we forgot to do this let's
actually scroll all the way down and
let's find our rendering section and
there's that visible option let's
uncheck visible so we want it off by
default it's gonna turn it off in our
level which you can see up there so
let's compile and save and then test
this again
let's say and now when we play our line
is off when we approach it our light
comes on you can see it fires and the
blueprint script there down below when I
leave it turns it off turns it on and
turns it off so our script is complete
we recreated that same setup that we did
for this section here it's currently not
working here because we disconnected it
but we recreated this inside of a class
blueprint now why did we do this let's
take a look at why we did this here let
me hit escape going to actually let's
actually dock all of our blueprints up
here we can close the level blueprint
for now because we don't need that
let's go back to our level here so
here's our light what we can do now this
is the really cool part of class
blueprints with our class blueprint here
selected we can hold alt and grab this
green arrow and just drag out a copy of
this light blueprint so I'm gonna go to
the other side somewhere along the back
here
move it along the back I'm gonna hit hit
eat into rotation mode and rotate it 90
degrees like so W to go back to
translation and push it up against the
wall something like this what's along
the backside of our wall here now the
beauty is with the class blueprints this
blueprint that we just placed should
automatically work we shouldn't have to
do anything else we can go into our play
session here we're gonna run over to
this light and turn it on it turns on we
can run over to this one and this one
comes on as well it's kind of sticking
into the wall a little bit I guess I
could move it out so it's not inside the
wall I think the light bulbs inside the
walls of me pop it out just a little bit
more oh not on the wall at all actually
a way to go let me put it on the wall
like so so now what we've done though is
we've created a class blueprint that we
can then place multiple instances
without having to recreate that script
you only had to create that script once
and it just works for us okay now try
again there we go that looks a little
bit better so I can turn this one on
that one's still off I could turn this
one on that one comes on so that's
that's the real power of class
blueprints there if we had done this
inside of our level blueprint what we
would have had to have done
is create copies of our trigger create
copies of our point light inside of our
level blueprint here we would have to
recreate this script for each individual
point night for each individual trigger
so it just cuts down on our workload by
by quite a bit actually when we're
working with class blueprints so that's
actually going to cause us to pause
you're about 13 minutes and we're gonna
pause here and again we've worked inside
of our class blueprint and set it up so
that we can have multiple instances of
it inside of our level not only that we
could take our class blueprint hair and
place this in an entirely new level new
level and it will just work
automatically without having a new extra
script that's going to do it for this
video in the next video we will begin
modifying this blueprint so that we can
set it up so that the player can enter
the volume and press a button to turn on
our light or turn our light on and off
so thank you guys for watching and we
will see you in the next video