﻿1
00:00:04,400 --> 00:00:05,510
‫Hello and welcome.

2
00:00:05,510 --> 00:00:11,210
‫In this lecture, we're going to be setting up our own little obstacle assault course, and we're going

3
00:00:11,210 --> 00:00:16,340
‫to be implementing these little pusher platforms here that will push our character off.

4
00:00:16,340 --> 00:00:22,250
‫We're going to have to implement a few little fixes to our character class in order to do this.

5
00:00:22,250 --> 00:00:24,650
‫So let's dive in and see what they are.

6
00:00:25,340 --> 00:00:32,390
‫So another type of puzzle I'd like to include using this basic moving platform component is to have

7
00:00:32,390 --> 00:00:35,690
‫a pusher that will basically push us off of a ledge.

8
00:00:35,870 --> 00:00:39,470
‫Now, the way that I want to do this is take this cube here.

9
00:00:39,470 --> 00:00:45,770
‫I think it's called Puzzle Cube A, and that can be the cube that is essentially the pusher.

10
00:00:45,770 --> 00:00:50,360
‫And we're going to configure it slightly differently from the moving platform.

11
00:00:50,360 --> 00:00:57,230
‫So let's go ahead and navigate back to our platform so I can right click and actually go click go here,

12
00:00:57,230 --> 00:01:00,380
‫which takes my camera kind of to focus on it.

13
00:01:00,800 --> 00:01:08,360
‫And then what we can do is go to our content, draw to the C++ classes, click my search, go to Obstacle

14
00:01:08,360 --> 00:01:12,410
‫Salt, right click on the moving platform and create a new blueprint class based on it.

15
00:01:12,410 --> 00:01:18,110
‫This time I'm going to call it the BP underscore pushing cube like.

16
00:01:18,110 --> 00:01:22,580
‫So I'm going to put it in the route of content and click Create Blueprint Class.

17
00:01:22,790 --> 00:01:24,140
‫Now I can close my content browser.

18
00:01:24,140 --> 00:01:29,510
‫I'm not sure why it keeps wanting to bring that one up and I'm going to go to the content draw, go

19
00:01:29,510 --> 00:01:36,170
‫to the root of content, and search for the puzzle cube or one word, and we're looking for the puzzle

20
00:01:36,170 --> 00:01:36,500
‫cube.

21
00:01:36,530 --> 00:01:38,390
‫Ay so that's this one here, the mesh.

22
00:01:38,390 --> 00:01:44,900
‫I'm going to drag in to our blueprint class and then close the content, draw close my compile results

23
00:01:44,900 --> 00:01:46,640
‫so I can see the viewport a little bit better.

24
00:01:46,760 --> 00:01:50,690
‫And I actually want to scale this cube up because by default it's actually quite small.

25
00:01:50,690 --> 00:01:54,230
‫I'm going to make it at least ten times bigger in every dimension.

26
00:01:54,230 --> 00:02:00,620
‫So I'm going to hit a little padlock next to the scale property so that each of these basically scales

27
00:02:00,620 --> 00:02:01,220
‫the same.

28
00:02:01,220 --> 00:02:05,930
‫And I'm going to change one of them to ten, and then the other two will scale up to ten as well.

29
00:02:06,320 --> 00:02:10,220
‫And then what I'm going to do is I'm going to change the direction of movement.

30
00:02:10,220 --> 00:02:12,830
‫So it's currently moving in the X direction.

31
00:02:12,830 --> 00:02:16,100
‫And if we look in our scene, you can see that that's basically the forward direction.

32
00:02:16,100 --> 00:02:17,540
‫I want to move it side to side.

33
00:02:17,540 --> 00:02:22,160
‫Obviously, we could rotate it once we put it in the scene and it wouldn't matter so much, but I'm

34
00:02:22,160 --> 00:02:29,660
‫going to change it to zero in the X and it needs to be reasonably fast for it to be an obstacle that

35
00:02:29,660 --> 00:02:30,440
‫we need to avoid.

36
00:02:30,440 --> 00:02:35,450
‫So I'm going to make it 300 and I'm going to make the move distance fairly large too.

37
00:02:35,450 --> 00:02:38,000
‫So going to make it at least 500 to start with.

38
00:02:38,000 --> 00:02:42,620
‫And obviously this can be then configured again once we place this in the level.

39
00:02:42,620 --> 00:02:47,630
‫So let's save that, go into our level and try and place this cube.

40
00:02:47,630 --> 00:02:53,150
‫I'm going to cancel out my search in the content draw, go to the root of content and drag in a pushing

41
00:02:53,150 --> 00:02:53,720
‫cube.

42
00:02:53,720 --> 00:02:55,010
‫It's absolutely massive.

43
00:02:55,010 --> 00:02:56,930
‫I definitely got the scale way off.

44
00:02:56,930 --> 00:03:00,530
‫So let's go back to the Blueprint class for the push in Cube.

45
00:03:00,560 --> 00:03:06,080
‫Go look at the scale property and maybe we just want to make it four times larger and note that I'm

46
00:03:06,080 --> 00:03:07,940
‫doing this with this scale lock on.

47
00:03:07,940 --> 00:03:13,430
‫So I'm making it four times larger in every dimension and go back into the level.

48
00:03:13,430 --> 00:03:15,560
‫And this is looking a lot more reasonable now.

49
00:03:15,560 --> 00:03:18,530
‫So you can see that it's actually clipping into the ground a little bit.

50
00:03:18,560 --> 00:03:25,910
‫So what we can do is we could either solve this by lifting up the cube in the world, or we could do

51
00:03:25,910 --> 00:03:31,010
‫it once and for all and actually lift it up in the Pushing Cube class instead.

52
00:03:31,010 --> 00:03:34,490
‫So I think we're going to need to lift it up by about.

53
00:03:34,490 --> 00:03:37,040
‫Let's start dragging up and see what looks sane.

54
00:03:37,040 --> 00:03:40,610
‫I think about 200 puts it on the ground plane.

55
00:03:41,090 --> 00:03:44,000
‫So save that and go back into our scene.

56
00:03:44,000 --> 00:03:44,600
‫And there you go.

57
00:03:44,600 --> 00:03:46,340
‫It looks like it is correct.

58
00:03:46,340 --> 00:03:49,520
‫Now I'm just going to move it so that it's going to overlap with our player.

59
00:03:49,850 --> 00:03:52,840
‫Let's go ahead and hit play and you can see it's moving backwards and forwards.

60
00:03:52,840 --> 00:03:55,100
‫It's not moving very far backwards and forwards.

61
00:03:55,100 --> 00:03:56,750
‫So I think we do need to change that.

62
00:03:56,750 --> 00:04:02,270
‫Let's go back to the class, go to the class, defaults and make the move distance.

63
00:04:02,270 --> 00:04:06,680
‫I think it's going to need to be at least 1500 like so.

64
00:04:06,680 --> 00:04:11,720
‫And we might want to set the move direction in the opposite direction, although that could just be

65
00:04:11,720 --> 00:04:12,980
‫a matter of preference.

66
00:04:12,980 --> 00:04:17,870
‫So let's go back to our main window and drag the cube over to the left instead, because that's the

67
00:04:17,870 --> 00:04:19,520
‫direction it's going to be moving in.

68
00:04:19,940 --> 00:04:20,720
‫Let's hit play.

69
00:04:20,720 --> 00:04:21,560
‫And there we go.

70
00:04:21,560 --> 00:04:24,290
‫It's going past very slowly.

71
00:04:24,290 --> 00:04:26,240
‫So I'm not happy with the speed.

72
00:04:26,270 --> 00:04:28,220
‫Let's change that speed.

73
00:04:28,220 --> 00:04:29,990
‫I think it needs to be at least three times fast.

74
00:04:30,000 --> 00:04:32,060
‫So let's make it 900 hit play.

75
00:04:32,060 --> 00:04:32,780
‫And there you go.

76
00:04:32,780 --> 00:04:35,120
‫We've got a bit more of a challenge.

77
00:04:35,120 --> 00:04:37,790
‫However, we've also got a bug.

78
00:04:37,800 --> 00:04:43,730
‫Our character doesn't really get pushed in a very sensible or nice way by this pushing cube.

79
00:04:43,730 --> 00:04:45,080
‫You can see it glitches.

80
00:04:45,080 --> 00:04:46,790
‫It's not smooth.

81
00:04:46,820 --> 00:04:50,180
‫However, I would like to draw your attention to a little workaround.

82
00:04:50,180 --> 00:04:56,780
‫If I'm trying to move while it hits me, you notice that it actually does it all very smoothly, and

83
00:04:56,780 --> 00:05:03,650
‫that is because the character code doesn't actually check for collisions unless you are trying to move.

84
00:05:03,870 --> 00:05:07,460
‫So there's a little bit of a workaround for us to do this.

85
00:05:07,470 --> 00:05:11,930
‫We're going to go to our BP third person character that we've created.

86
00:05:11,940 --> 00:05:17,220
‫Now, the way you can get to this is either via the content draw or you can select the character in

87
00:05:17,220 --> 00:05:22,680
‫the scene, go to the details pane, go to the Blueprint button and hit Open Blueprint Editor.

88
00:05:23,130 --> 00:05:29,760
‫And what we want to do is essentially every single tick, we want to move the character a little bit

89
00:05:29,760 --> 00:05:33,090
‫to the left and then a little bit back to the right.

90
00:05:33,090 --> 00:05:38,640
‫Now, the way we're going to do this is using a component on the character called the character movement

91
00:05:38,640 --> 00:05:39,150
‫component.

92
00:05:39,150 --> 00:05:45,360
‫So select that in the components pane, then right click in your Blueprint Event graph and then search

93
00:05:45,360 --> 00:05:49,290
‫for move updated component.

94
00:05:50,220 --> 00:05:53,580
‫Essentially what this function does is it tells.

95
00:05:54,360 --> 00:06:01,350
‫The movement component that it should use its character movement rules to move the character around.

96
00:06:01,800 --> 00:06:08,640
‫So you can see that it takes a delta which basically says, this is how far you should move.

97
00:06:08,790 --> 00:06:16,350
‫And it has a sweep, which tells us that it should look out for any collisions along the way.

98
00:06:16,530 --> 00:06:23,610
‫So we can make it do a very straightforward movement of basically one centimetre in the X and Y.

99
00:06:23,640 --> 00:06:27,690
‫It doesn't so much matter whether it moves in the Z because we're not looking for those collisions,

100
00:06:27,690 --> 00:06:28,320
‫really.

101
00:06:28,650 --> 00:06:34,050
‫Then we can take the tick and drag the execution pin into our move.

102
00:06:34,050 --> 00:06:35,370
‫Updated components.

103
00:06:35,700 --> 00:06:41,480
‫And if we left it like this, it would be problematic because gradually our character would be drifting.

104
00:06:41,490 --> 00:06:43,410
‫Let me show you if I hit play.

105
00:06:43,860 --> 00:06:49,470
‫You can see that the character is gradually one centimetre at a frame at a time, is drifting his way

106
00:06:49,470 --> 00:06:50,450
‫across the scene.

107
00:06:50,460 --> 00:06:53,660
‫So what we need to do is also move back.

108
00:06:53,670 --> 00:06:59,490
‫So dragging a character movement component down here, I'm going to drag off of this pin again and look

109
00:06:59,490 --> 00:07:00,840
‫again for the move.

110
00:07:00,840 --> 00:07:02,430
‫Updated components.

111
00:07:02,580 --> 00:07:08,520
‫I'm going to thread in the execution pin so that it gets called after the first move updated component.

112
00:07:08,520 --> 00:07:14,880
‫And then I'm going to make the delta minus one in the X and minus one in the Y.

113
00:07:14,910 --> 00:07:21,330
‫So the end result will be that nothing seems to have happened, however, because we've forced the movement

114
00:07:21,330 --> 00:07:28,250
‫component to look for these collisions with the sweep, it's going to react smoothly to the pusher.

115
00:07:28,260 --> 00:07:33,840
‫So let's go ahead and hit play and go and stand in the path of our pusher.

116
00:07:34,020 --> 00:07:39,440
‫And you can see we very smoothly get nudged just out of the way, like so.

117
00:07:39,450 --> 00:07:46,110
‫So I'd like to challenge you to make an obstacle course of your own using this pusher and moving platform

118
00:07:46,110 --> 00:07:47,790
‫components that we've put together here.

119
00:07:47,820 --> 00:07:52,350
‫So here's the example of the obstacle course that I've made in my prototype.

120
00:07:52,350 --> 00:07:57,300
‫You can see I've got some moving platforms to raise me up onto a little island so you can use one of

121
00:07:57,300 --> 00:07:59,970
‫these islands and scale it down as a platform.

122
00:07:59,970 --> 00:08:04,610
‫And then I've got the pushers moving backwards and forwards that I have to make my way through.

123
00:08:04,620 --> 00:08:07,350
‫And then there's rotating platforms, but we're going to get to that later.

124
00:08:07,350 --> 00:08:08,190
‫So don't worry.

125
00:08:08,190 --> 00:08:12,060
‫But we've got these pushers and we've got the moving platforms, so have a go.

126
00:08:12,060 --> 00:08:16,680
‫You can try and replicate this, or if you're feeling creative and want to try something different,

127
00:08:16,680 --> 00:08:22,260
‫then please go ahead and create your own obstacle course because that's always really exciting to see.

128
00:08:22,260 --> 00:08:27,390
‫And if you do create something unique, please share it in the discussions so that we can all have a

129
00:08:27,390 --> 00:08:28,920
‫look and get inspired.

130
00:08:28,920 --> 00:08:30,870
‫So pause the video and have a go.

131
00:08:33,820 --> 00:08:34,450
‫Okay.

132
00:08:34,450 --> 00:08:35,260
‫Welcome back.

133
00:08:35,260 --> 00:08:40,730
‫So now that we've got our pushers working, let's make something a bit interesting, shall we?

134
00:08:40,750 --> 00:08:44,080
‫So I'm going to take this platform and actually rotate it around.

135
00:08:44,080 --> 00:08:50,710
‫So we've got a bit more length to our to our setup, and I'm going to drag it along.

136
00:08:50,710 --> 00:08:57,160
‫So the character is right at the end of the platform, and then I'm going to take these two moving platforms

137
00:08:57,160 --> 00:08:59,560
‫and position them one after the other.

138
00:08:59,560 --> 00:09:09,280
‫And one of them, I'm going to add 1000 to its Z axis and I'm going to send it moving in the opposite

139
00:09:09,280 --> 00:09:10,180
‫direction.

140
00:09:10,180 --> 00:09:13,990
‫So these two platforms should meet somewhere around the middle.

141
00:09:14,050 --> 00:09:17,890
‫Then I'm going to duplicate the floating island that we're standing on.

142
00:09:17,890 --> 00:09:24,670
‫So by alt clicking and dragging, I'm going to rotate it just so it doesn't immediately look obviously

143
00:09:24,670 --> 00:09:32,410
‫the same platform and I drag it out and I'm going to rescale it a little bit so that we can fit it on

144
00:09:32,410 --> 00:09:34,030
‫top of the other platform.

145
00:09:34,030 --> 00:09:40,210
‫Because ultimately what I want to happen is that once we get on top of this upper platform, we get

146
00:09:40,210 --> 00:09:42,760
‫pushed down so we don't die.

147
00:09:42,760 --> 00:09:45,190
‫But it gives us a bit of a setback.

148
00:09:45,280 --> 00:09:47,110
‫Now, I'm going to take these pusher cubes.

149
00:09:47,110 --> 00:09:52,630
‫I'm going to actually just drag them in on to the upper platform.

150
00:09:52,840 --> 00:09:54,190
‫I'm going to put a few of them in.

151
00:09:54,190 --> 00:09:58,810
‫So I think three is enough for the time being, and I'm going to drag one of them over to the other

152
00:09:58,810 --> 00:10:03,190
‫side and flip its velocity like so.

153
00:10:03,190 --> 00:10:07,870
‫So instead of being nine, it's going to be -900 and we're going to go in the opposite direction.

154
00:10:08,080 --> 00:10:12,400
‫Let's try this out so I can get up onto these moving platforms.

155
00:10:12,400 --> 00:10:19,750
‫They allow me to have a bit of a ladder up here and now I have to try and get past these guys.

156
00:10:19,750 --> 00:10:25,390
‫And interestingly, I just noticed a little bit of a bug with the way that we're forcing our character

157
00:10:25,390 --> 00:10:27,670
‫to move and will cover that in just a second.

158
00:10:27,880 --> 00:10:30,640
‫But yeah, it's a little bit challenging, but it is doable.

159
00:10:30,640 --> 00:10:31,840
‫We could definitely get through those.

160
00:10:31,840 --> 00:10:35,680
‫I'm not doing it very well at the moment, but we could definitely get through those cubes if we wanted

161
00:10:35,680 --> 00:10:36,190
‫to.

162
00:10:36,190 --> 00:10:39,310
‫So the next thing to do is fix that little bug.

163
00:10:39,670 --> 00:10:47,170
‫Now the issue here is that when we called move updated component, we're setting a rotation in here

164
00:10:47,170 --> 00:10:52,330
‫that is not our character's rotation, which means that it's always going to put us facing forwards.

165
00:10:52,510 --> 00:11:02,620
‫So the easy way to fix this is to right click and do get actor rotation and simply pass the actor rotation

166
00:11:02,620 --> 00:11:05,950
‫in to the new rotation four Move Updated Component.

167
00:11:05,950 --> 00:11:09,970
‫You can pass it in to both of them, but the one that really matters is that we'd be doing it for the

168
00:11:09,970 --> 00:11:16,360
‫last one so we can go ahead and play now and we should be able to see that we can indeed now rotate

169
00:11:16,360 --> 00:11:18,670
‫our character as appropriate.

170
00:11:18,880 --> 00:11:19,900
‫Well, great stuff.

171
00:11:19,900 --> 00:11:26,770
‫In this lecture we have fixed a little bit of a collision bug with our character and we've set up a

172
00:11:26,770 --> 00:11:31,270
‫little bit of an obstacle assault course for us to get started.

173
00:11:31,270 --> 00:11:33,850
‫I hope you've had fun and I'll see you in the next lecture.

