In this lecture, we're giving our players some feet so that we can prevent the player from doing many,
many jumps up on a wall.
Before we start on preventing wall jumps to show a quick tweak I've made to my game, my player was
looking a little bit too manic, running around quickly.
I've changed the run speed to seven, the jump speed to 20, and the gravity scale to six, just to
make him calm the heck down a little bit.
So now it's a little bit more floaty, a little bit less super mega speed and a little bit less flying
off into the wall, into the sky.
So I'm pretty happy with that.
Okay.
So in terms of preventing wall jump, I'm going to give this to you as a challenge, see if you can
figure it out.
It's not super difficult, but it requires a little bit of pondering prevent the player from multi jumping
when touching the wall.
That's what we're trying to do in this instance.
A little bit of a hint for you is one way of doing this is to add a second collider to represent feet
and then to do something with that collider different to what we're doing with our capsule collider
around the body.
So there's your challenge.
Have a think about that one and no worries.
If you can't get it, we'll go through it together when you come back from giving it a try.
So pause the video and I'll see you soon.
First step, I'm going to click on the player.
And you know what?
I've not been paying attention to my pre-fab.
Let's apply any of our overrides we've made to the prefab.
That would be a smart thing to do and add a new component which would be a box collider to DH to represent
the feet.
Now what I'm going to do, first of all, I'm going to make these icons a little bit less.
I can't even see the player.
These gizmos are so huge.
So the 3D icons, I'm just going to reduce them down a little bit.
I tend not to pay attention to them anyway, so I'll have them just little there, just in case we need
them so we can see them going on.
But I don't want them to get in the way of being able to see stuff.
So on our player, we currently have a capsule collider two D that's going to stay there because that's
what we need to say.
Don't stick into the walls.
I'm going to make it a little bit wider.
So hit edit collider or click on Edit Collider.
Just stretch it out a little bit, stretch it out a little bit.
And after going and applying that stuff to my prefab, I've kind of done the same thing, haven't I?
I'm working right in my instance.
I'll apply all will go work in the prefab by clicking on the prefab button and these bad habits that
I've got from the olden days where things worked a little different.
But there we go.
There's our capsule collider.
Now, while I'm in my prefab, I'm going to jump down to add component at a box collider to DX.
Click on the edit collider and we'll make this the size of the feet or make this in the feet area so
it doesn't need to be all the way up high.
It just needs to be down at the bottom to say, Are you touching the ground or are you touching a letter
nice and low?
I'm going to bring it inside of the capsule.
Collider So you can see the edge of the capsule.
Collider Here is on the outside and the feet are on the inside because we don't want the feet.
Collider Accidentally touching the wall that we're trying not to grip too.
So I have it on the inside a little bit there, not to too far.
I think that should be okay in terms of our structure.
So now we have two different colliders.
There's other ways that you could do this.
You could have these colliders as children to the player, but this for me is nice and clean.
All of our stuff is on the player at the moment because I'm pretty sure I'm just going to need these
two colliders and we can access in our script the different colliders.
We can say, grab this box.
Collider Or Grab this.
Where are we?
The Capsule?
Collider All the way up here.
Capsule Collider If I wanted to have two or three or four box colliders, I'd need to do it a little
bit differently.
It wouldn't work so well, but simply because this is a different type of component.
Box Collider two DX Versus this, which is a capsule.
Collider two DD We can do it this particular way, but take note.
This wouldn't work if we had to box colitis the way that I'm about to do it.
Now that we've got all that, I'm going to jump over into my script.
We'll have a look for where we currently have our capsule.
Collider two DX I'm just going to rename this from my Capsule Collider to right click Change All Occurrences
or Control f two.
I rename this to be my Body Collider Just so it's really clear in our code what's going on and it's
a capsule collider I'm going to create another one which will be of type box collider to DX and we'll
call this my feet.
Just my feet.
My Feet Collider on my feet.
What's the convention we're doing here?
My feet.
Collider is probably a wiser thing because we've got my body Collider My feet collider And in start
we need to grab that.
So my feet collider equals get component.
What type of component?
It's a box collider two dx excellent de parentheses semicolon.
Now scroll down, have a look where this is relevant.
Currently it's in the jump and in what else?
The climb ladder where we need to know are you touching these things?
So within on jump I'm just going to change from my body.
Collider To my feet.
Collider That's what we're interested in.
Same thing down here and climb ladder instead of my body.
Collider Be my feet.
Collider Save.
That should have changed it.
Now we should be assessing, jumping and climbing based upon whether this particular box collider is
touching as opposed to whether our capsule collider is touching.
Scroll out a little bit, jump out of the prefab, click on play.
First test is can we actually run around and move?
We can.
Can I jump?
Double jump.
I'm tapping on the spacebar.
I cannot double jump.
Perfect.
So we stopped the double jump.
Can I still do my bouncy bounce?
Yes, I can.
And can I climb a ladder?
Yes, I can.
So I've got all the functionality in there that we needed and we've stopped the wall jump, we've stopped
the grittiness in the last lecture and we've got some bounce.
There we go.
Pretty happy with the character.
And as I said at the start, I've tuned it a little bit.
So make sure you take time to tune your character.
So it feels good.
But I think for now we've got most of our character movement functionality.
Feeling good.
Okay, I'll see you in the next lecture.