1
00:00:03,050 --> 00:00:08,480
In this lecture, we're giving our players some feet so that we can prevent the player from doing many,

2
00:00:08,480 --> 00:00:10,160
many jumps up on a wall.

3
00:00:10,160 --> 00:00:14,660
Before we start on preventing wall jumps to show a quick tweak I've made to my game, my player was

4
00:00:14,660 --> 00:00:16,940
looking a little bit too manic, running around quickly.

5
00:00:16,940 --> 00:00:22,640
I've changed the run speed to seven, the jump speed to 20, and the gravity scale to six, just to

6
00:00:22,640 --> 00:00:24,890
make him calm the heck down a little bit.

7
00:00:24,890 --> 00:00:30,380
So now it's a little bit more floaty, a little bit less super mega speed and a little bit less flying

8
00:00:30,380 --> 00:00:32,060
off into the wall, into the sky.

9
00:00:32,060 --> 00:00:33,170
So I'm pretty happy with that.

10
00:00:33,170 --> 00:00:33,560
Okay.

11
00:00:33,560 --> 00:00:37,520
So in terms of preventing wall jump, I'm going to give this to you as a challenge, see if you can

12
00:00:37,520 --> 00:00:38,330
figure it out.

13
00:00:38,330 --> 00:00:43,040
It's not super difficult, but it requires a little bit of pondering prevent the player from multi jumping

14
00:00:43,040 --> 00:00:44,210
when touching the wall.

15
00:00:44,210 --> 00:00:45,860
That's what we're trying to do in this instance.

16
00:00:45,860 --> 00:00:51,560
A little bit of a hint for you is one way of doing this is to add a second collider to represent feet

17
00:00:51,560 --> 00:00:56,570
and then to do something with that collider different to what we're doing with our capsule collider

18
00:00:56,570 --> 00:00:57,230
around the body.

19
00:00:57,230 --> 00:00:58,700
So there's your challenge.

20
00:00:58,700 --> 00:01:00,470
Have a think about that one and no worries.

21
00:01:00,470 --> 00:01:03,950
If you can't get it, we'll go through it together when you come back from giving it a try.

22
00:01:03,950 --> 00:01:05,810
So pause the video and I'll see you soon.

23
00:01:08,840 --> 00:01:10,340
First step, I'm going to click on the player.

24
00:01:10,340 --> 00:01:10,760
And you know what?

25
00:01:10,760 --> 00:01:12,590
I've not been paying attention to my pre-fab.

26
00:01:12,590 --> 00:01:16,250
Let's apply any of our overrides we've made to the prefab.

27
00:01:16,280 --> 00:01:21,710
That would be a smart thing to do and add a new component which would be a box collider to DH to represent

28
00:01:21,710 --> 00:01:22,390
the feet.

29
00:01:22,420 --> 00:01:25,280
Now what I'm going to do, first of all, I'm going to make these icons a little bit less.

30
00:01:25,280 --> 00:01:26,390
I can't even see the player.

31
00:01:26,390 --> 00:01:27,710
These gizmos are so huge.

32
00:01:27,710 --> 00:01:31,340
So the 3D icons, I'm just going to reduce them down a little bit.

33
00:01:31,340 --> 00:01:36,080
I tend not to pay attention to them anyway, so I'll have them just little there, just in case we need

34
00:01:36,080 --> 00:01:37,460
them so we can see them going on.

35
00:01:37,460 --> 00:01:40,160
But I don't want them to get in the way of being able to see stuff.

36
00:01:40,160 --> 00:01:45,470
So on our player, we currently have a capsule collider two D that's going to stay there because that's

37
00:01:45,470 --> 00:01:46,130
what we need to say.

38
00:01:46,130 --> 00:01:47,750
Don't stick into the walls.

39
00:01:47,750 --> 00:01:49,310
I'm going to make it a little bit wider.

40
00:01:49,310 --> 00:01:51,830
So hit edit collider or click on Edit Collider.

41
00:01:51,830 --> 00:01:54,200
Just stretch it out a little bit, stretch it out a little bit.

42
00:01:54,200 --> 00:01:57,800
And after going and applying that stuff to my prefab, I've kind of done the same thing, haven't I?

43
00:01:57,800 --> 00:01:59,870
I'm working right in my instance.

44
00:01:59,870 --> 00:02:04,970
I'll apply all will go work in the prefab by clicking on the prefab button and these bad habits that

45
00:02:04,970 --> 00:02:08,150
I've got from the olden days where things worked a little different.

46
00:02:08,150 --> 00:02:08,810
But there we go.

47
00:02:08,810 --> 00:02:09,889
There's our capsule collider.

48
00:02:09,889 --> 00:02:14,770
Now, while I'm in my prefab, I'm going to jump down to add component at a box collider to DX.

49
00:02:14,780 --> 00:02:20,900
Click on the edit collider and we'll make this the size of the feet or make this in the feet area so

50
00:02:20,900 --> 00:02:22,310
it doesn't need to be all the way up high.

51
00:02:22,310 --> 00:02:27,020
It just needs to be down at the bottom to say, Are you touching the ground or are you touching a letter

52
00:02:27,050 --> 00:02:28,010
nice and low?

53
00:02:28,010 --> 00:02:30,230
I'm going to bring it inside of the capsule.

54
00:02:30,260 --> 00:02:31,940
Collider So you can see the edge of the capsule.

55
00:02:31,940 --> 00:02:37,010
Collider Here is on the outside and the feet are on the inside because we don't want the feet.

56
00:02:37,010 --> 00:02:40,310
Collider Accidentally touching the wall that we're trying not to grip too.

57
00:02:40,310 --> 00:02:43,430
So I have it on the inside a little bit there, not to too far.

58
00:02:43,460 --> 00:02:45,830
I think that should be okay in terms of our structure.

59
00:02:45,830 --> 00:02:47,390
So now we have two different colliders.

60
00:02:47,390 --> 00:02:48,890
There's other ways that you could do this.

61
00:02:48,890 --> 00:02:53,600
You could have these colliders as children to the player, but this for me is nice and clean.

62
00:02:53,600 --> 00:02:57,020
All of our stuff is on the player at the moment because I'm pretty sure I'm just going to need these

63
00:02:57,020 --> 00:03:01,250
two colliders and we can access in our script the different colliders.

64
00:03:01,250 --> 00:03:02,300
We can say, grab this box.

65
00:03:02,300 --> 00:03:04,070
Collider Or Grab this.

66
00:03:04,070 --> 00:03:04,490
Where are we?

67
00:03:04,490 --> 00:03:05,060
The Capsule?

68
00:03:05,060 --> 00:03:06,590
Collider All the way up here.

69
00:03:06,920 --> 00:03:11,270
Capsule Collider If I wanted to have two or three or four box colliders, I'd need to do it a little

70
00:03:11,270 --> 00:03:11,810
bit differently.

71
00:03:11,810 --> 00:03:16,070
It wouldn't work so well, but simply because this is a different type of component.

72
00:03:16,070 --> 00:03:19,280
Box Collider two DX Versus this, which is a capsule.

73
00:03:19,280 --> 00:03:22,760
Collider two DD We can do it this particular way, but take note.

74
00:03:22,760 --> 00:03:26,270
This wouldn't work if we had to box colitis the way that I'm about to do it.

75
00:03:26,270 --> 00:03:28,820
Now that we've got all that, I'm going to jump over into my script.

76
00:03:28,820 --> 00:03:31,370
We'll have a look for where we currently have our capsule.

77
00:03:31,370 --> 00:03:38,600
Collider two DX I'm just going to rename this from my Capsule Collider to right click Change All Occurrences

78
00:03:38,600 --> 00:03:39,920
or Control f two.

79
00:03:39,950 --> 00:03:45,590
I rename this to be my Body Collider Just so it's really clear in our code what's going on and it's

80
00:03:45,590 --> 00:03:52,730
a capsule collider I'm going to create another one which will be of type box collider to DX and we'll

81
00:03:52,730 --> 00:03:54,800
call this my feet.

82
00:03:55,310 --> 00:03:56,120
Just my feet.

83
00:03:56,120 --> 00:03:57,890
My Feet Collider on my feet.

84
00:03:57,890 --> 00:03:59,270
What's the convention we're doing here?

85
00:03:59,270 --> 00:03:59,690
My feet.

86
00:03:59,690 --> 00:04:04,700
Collider is probably a wiser thing because we've got my body Collider My feet collider And in start

87
00:04:04,700 --> 00:04:05,540
we need to grab that.

88
00:04:05,540 --> 00:04:09,140
So my feet collider equals get component.

89
00:04:09,140 --> 00:04:10,130
What type of component?

90
00:04:10,130 --> 00:04:15,320
It's a box collider two dx excellent de parentheses semicolon.

91
00:04:15,350 --> 00:04:17,390
Now scroll down, have a look where this is relevant.

92
00:04:17,390 --> 00:04:21,140
Currently it's in the jump and in what else?

93
00:04:21,140 --> 00:04:24,320
The climb ladder where we need to know are you touching these things?

94
00:04:24,320 --> 00:04:27,350
So within on jump I'm just going to change from my body.

95
00:04:27,350 --> 00:04:29,630
Collider To my feet.

96
00:04:29,630 --> 00:04:32,000
Collider That's what we're interested in.

97
00:04:32,000 --> 00:04:34,250
Same thing down here and climb ladder instead of my body.

98
00:04:34,250 --> 00:04:36,320
Collider Be my feet.

99
00:04:36,410 --> 00:04:38,060
Collider Save.

100
00:04:38,060 --> 00:04:39,050
That should have changed it.

101
00:04:39,050 --> 00:04:45,470
Now we should be assessing, jumping and climbing based upon whether this particular box collider is

102
00:04:45,470 --> 00:04:48,920
touching as opposed to whether our capsule collider is touching.

103
00:04:48,920 --> 00:04:53,680
Scroll out a little bit, jump out of the prefab, click on play.

104
00:04:54,980 --> 00:04:57,200
First test is can we actually run around and move?

105
00:04:57,200 --> 00:04:57,800
We can.

106
00:04:57,800 --> 00:04:59,300
Can I jump?

107
00:04:59,300 --> 00:04:59,870
Double jump.

108
00:04:59,870 --> 00:05:01,160
I'm tapping on the spacebar.

109
00:05:01,160 --> 00:05:02,120
I cannot double jump.

110
00:05:02,120 --> 00:05:02,540
Perfect.

111
00:05:02,540 --> 00:05:04,190
So we stopped the double jump.

112
00:05:04,190 --> 00:05:05,780
Can I still do my bouncy bounce?

113
00:05:05,780 --> 00:05:06,500
Yes, I can.

114
00:05:06,500 --> 00:05:07,700
And can I climb a ladder?

115
00:05:07,700 --> 00:05:08,240
Yes, I can.

116
00:05:08,240 --> 00:05:12,590
So I've got all the functionality in there that we needed and we've stopped the wall jump, we've stopped

117
00:05:12,590 --> 00:05:15,030
the grittiness in the last lecture and we've got some bounce.

118
00:05:15,050 --> 00:05:15,390
There we go.

119
00:05:15,410 --> 00:05:16,520
Pretty happy with the character.

120
00:05:16,520 --> 00:05:18,830
And as I said at the start, I've tuned it a little bit.

121
00:05:18,830 --> 00:05:20,810
So make sure you take time to tune your character.

122
00:05:20,810 --> 00:05:21,680
So it feels good.

123
00:05:21,680 --> 00:05:25,100
But I think for now we've got most of our character movement functionality.

124
00:05:25,100 --> 00:05:25,910
Feeling good.

125
00:05:25,910 --> 00:05:27,320
Okay, I'll see you in the next lecture.

