♪♪♪
(Wes Bunn) Hey everybody, good to see you again. Welcome back. In this video, we are
going to continue where we left off from the previous video creating the Blueprint script
for our sliding door. We left off by creating the Timeline with our keyframes on it and
our curve. So let's continue. Let's actually hop over to the level really quick. Hopefully,
you have the Level and the Blueprint tabs open. Go ahead and click on the Level tab.
Go ahead and make sure your door is selected. So go ahead and select your door, and then hop
back to the Level Blueprint. Now, what we are going to do is we are actually going to
scroll up a little bit to those two nodes that we started with. We are going to move
the Event Tick out of the way; we don't need that, but the Event Begin Play is kind of special.
We are going to use that. We are going to Right-click in the graph and when we do so,
you can see there is an option that says Create a Reference to Door. So let's go ahead and
select that. This is a reference to the door in the level. We are going to need that
so that we can tell it to move through our Timeline here. Now again if we open up our
Timeline, our first keyframe says Timeline at 0 our Value is 0. At 1.2 our Value is 110.000008.
(Laughter) Don't worry about the float value at the end; that is fine. Our Timeline does
not know our Door's initial position, so it cannot add the values here over time to something
it doesn't know. We need to tell our Timeline what our Door's initial position is. If you
recall, the Event Begin Play is called at the beginning of our game. So what we are going to do
is grab our door here. We are going to drag off this pin; Left-click and drag off of it
and we are going to type Get Actor Location. So this is getting the Location of our door
Actor, so go ahead and select that. Once we get this node, we are going to drag off the
Return Value here. It is giving us a vector, which is also the same as our Movement. We
are going to drag off this Return Value and there is going to be an option to promote
that to a variable. So go ahead and select that (Promote to variable). When you do so,
over here in the left it is going to have the option to ask you for a name, so go ahead
and enter a name for it. We are going to call this DoorLocation, I guess. Well, let's get
something more descriptive. Let's call it InitialDoorLocation. There we go; that
is more descriptive. What we are going to do now is grab our Event Begin Play executable
wire here and connect that to our variable. So when the game begins, get our Door Location
and store that as a variable. Now we are going to hop down to our DoorMovement, our Timeline
here. We are actually going to click on our Door here and hit Ctrl+C to copy it. Down
below our Timeline, I am going to hit Ctrl+V to paste our Door. What we need to do is set
our Door's Location during the course of our Timeline. So we are going to drag off the
Door here and we are going to say Set Actor Location. It gives us a bunch of stuff here
that we don't need to really worry about right now. We are just going to move it up here
so that it is nice and clean. What we are going to do is grab this Update pin off the
Timeline here. Every time our Timeline is updated, we are going to set the Actor Location
each time. Grab the Update executable and connect that to the Set Actor Location. Now
we could grab the Movement here and just plug that straight into New Location, but that
is not quite going to work for us. As you recall, the Timeline does not know our Door's
initial Location; it just knows that we need to move 110 meters, but it doesn't know 110
meters from where. So let's grab our variable here (InitialDoorLocation). We are going to
hold Ctrl and drag that into the graph here. When we do that, it is going to get what is
called a Getter. It is going to get this value that we started with from Event Begin Play.
We are going to add to this. So drag off this pin and hit a plus sign (+) and there is Vector
+ Vector, so go ahead and do that. Now this is just a little nit picky thing; what we are
going to do is connect our Movement to this, but you can see this wire is connected to
the top. We could just do this; it is totally fine for you to do that, but I am going to
be really nit picky here. I am going to Ctrl+Z. I am going to hold Ctrl and grab this pin
and move it down there just for the sake of clarity. Then, reconnect our Movement to this
pin. Don't cross the streams is what I have been told, so I am doing it that way. Okay,
and the last pin, as you guessed it, is going to plug into our New Location. So we don't
need to worry about Sweep and all this other stuff; this is everything that we need right
here. So we are going to hit Compile and we are going to hop back over to our level here.
I am going to back up a little bit. We are going to hit Play. I am going to turn my sound
down so that you don't hear that. (Laughter) We use WASD and we are going to move as we
approach it, our door opens. It stays open because we are inside of our Box Trigger.
As soon I pass through the door, it closes. Now it is doing it instantly, as you see there,
because we didn't add a delay. So let's go ahead and do that really quickly. I am going
to hit Esc to exit out. We will hop back to the Level Blueprint here. On the Event End
Overlap here, we are just going to drag off this and we are going to search for delay.
There is Delay, right there at the top. Go ahead and hit Enter. For the Duration,
we can set this to whatever we want. For us for right now, I am just going to set it
to 0.5, half a second delay before it closes. Let's re-compile and then go back to the level.
Let's fly back over here and Play. As we approach it, it opens. As we move away
after half a second, it is very subtle. There we go. If we do it really quickly, it is a
little bit more apparent. So there you go; opening and closing. So that is our door set up. I
guess we can stop this video here. This is a pretty short video since we continued off
the last video. In the next video, we will add some finishing touches to our level by
adding some props and some lighting, and that will wrap this series up. So we will see you
in the next video.
♪♪♪