Next, let's take a look
at some environmental blockers we can put here.
I'm going to put in some destructible objects
and I'm going to trigger a door with a pressure pad.
First, let's take a look at the destructible objects.
We have two:
we have this destructible column, here,
and I'm going to delete that,
and we also have this destructible wall,
so this is a bit chunkier,
and I think I like this one best, so I'm going to put that here.
Now, let's take a look
at the "DestructableWall" in the Hierarchy.
as you can see, when I've got this selected,
there's not really any components here.
And this is because for the destructible objects,
we need to open them up,
so I'm going to click on the arrow to expose its children…
and on the "DestructibleWall_Whole".
This is where all the options and components live.
You might recognize
that it also has a "Damageable" component,
so this is the same
across anything that needs to receive damage.
This wall is actually destructible,
it needs to receive damage, and when it receives damage,
the Sprites will change, and destruct, and show you that.
First, let's take a look at its "Starting Health".
It's currently set to "5",
which means if I hit it five times, it will destruct,
so let's take a look at that…
Jump on the moving platform,
and I need to hit it with my staff, so, pressing K…
Five hits and it destroys.
Ellen does one hit of damage
for every staff swipe and every bullet
that comes out of her gun.
I'm going to exit Play mode now.
This takes a little bit of a long time,
so if I reduce this to "2",
if I hit it twice,
then it will change into the broken pile of rubble
and then I'll also run and die at the same time,
because I'm really great at platformers.
So, if I'm hitting this,
it'll go, that took two swipes.
I'm going to get out of Play mode again.
I think that's fine.
Let's move on to block her path once again,
and I'm going to add in a door.
I'm still in the "Interactables" folder
in the Project view,
and I'm going to click and drag into the Scene this door here.
I think I'm going to put it here.
I think that's good. Right there.
Cool. So Ellen won't be able to get past this door at all.
This door is just a door,
nothing will happen when we walk up to it,
it will just block her path.
One thing I'm going to do just for quick testing
is move Ellen's position,
so when I start and press Play
I don't have to run through the whole game
to test a mechanic that I've just made.
So do this, let's look at the Hierarchy
and find "Ellen" and click on her.
And then I'm going to CTRL + click on Cameras.
This will make sure that when I press Play,
the Camera will start in the correct position.
I'm going to click on her Transform
and then move her into position.
I'm going to zoom in and place her about there.
There we go. Just a quick test.
By pressing Play,
the Camera on Ellen should spawn in the correct place
so I don't have to carry on and do this.
All the gameplay is still active, it still works,
I've just moved Ellen and the Camera.
I'm going to exit Play mode
and I'm going to activate this door with a pressure pad.
Let's look at the pressure pad,
still in the "Interactables" folder.
There's the pressure pad.
I'm going to click and drag that in.
This can be a little bit fiddly with positioning, so…
I think that's OK.
If I press Play now and test this,
I'll be able to step on this pressure pad.
And stepping on it will activate a sound,
the button will light up, but nothing will happen.
And that's because it doesn't know that it needs to open a door.
The door doesn't have anything connected to it,
it's just two separate objects.
So, let's link these objects with the Event System.
I'm going to exit Play mode
and take a look at the "PressurePad" in the Inspector.
I'm going to scroll all the way down,
and here you can see we have a "Pressure Pad" component.
This holds all the settings for what a pressure pad can do.
So we can see that there's
the type of items that can be on there,
how many items need to be on there for it to be activated,
and once it's activated,
it causes "On Pressed ()" event here.
When it's pressed,
it will change the Sprite, so it looks lit up,
and it will play a sound.
Another thing that we want to happen when we press on this is
we want the door to open.
The way the door opens in this Project is
it plays an animation.
So, let's look at doing that now.
I'm going to add an event here by pressing the "+" button
and I'm going to find the "Door" in the Hierarchy.
Click and drag that
into this empty slot here
and now this is changed to say "No Function".
One thing to note when you're clicking and dragging something
from the Hierarchy into the Inspector
is that if you just click it, you will start inspecting the door.
So what we want to make sure is that we actually click and drag,
and not just single-click.
So, looking at the "PressurePad", I'm going to scroll back down,
after showing you that.
We need to play an animation.
We're going to click this option here
and here are all the different types of functions we can do.
We want to look at the "Animator".
And here, in the "Animator",
we have a bunch of functions that we can trigger,
and what we're interested in is playing an animation.
So, we need to find the "Play (string)".
And "string" is important,
because what it's going to do is look at the file names
of different animations
and we need to match that file name.
But how do we know which file names to plug into here?
We have a folder filled with animations.
If we go to our Project view
and we go to "Art" and expand that, we have…
I'm going to close this "Sprites" folder,
just so it's nice and tidy…
If we expand the "Animations" folder,
we have an "Interactables" folder.
And this matches the Prefab structure.
If you have an "Interactables" Prefab,
chances are its animations or art will be stored
in an "Interactables" folder in the corresponding section.
I'm going to click on this,
and here we have "DoorClosing", "DoorOpenClose"…
and "DoorOpening" is the one I want.
If we click on this,
we can inspect it and see how it spells,
so it's "DoorOpening".
The function will look for this specific word
to trigger this animation.
So, if I go back to the "PressurePad",
here, in the Hierarchy, and scroll down
and, in the empty slot here, if I type in "DoorOpening"
and press Play,
when I step on this pressure pad,
an animation will play, and a sound will play,
and the door will open.
And now Ellen can get through to the next part.