Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,080 --> 00:00:04,939
In this video I want to create a checkpoint system so we don't always spawn at the start location.
2
00:00:04,939 --> 00:00:09,980
But let's say if we walk all the way here and we get defeated after that, we then want to spawn in
3
00:00:09,980 --> 00:00:10,730
this location.
4
00:00:10,730 --> 00:00:12,230
And this is something very essential.
5
00:00:12,230 --> 00:00:14,090
And it's actually quite easy to do this.
6
00:00:14,090 --> 00:00:20,600
Just go to the content drawer and blueprints, and we want to create a new folder first for new folder
7
00:00:20,600 --> 00:00:21,890
and just called props.
8
00:00:22,630 --> 00:00:24,580
For props for the level and stage.
9
00:00:24,580 --> 00:00:30,010
And in here we want to create a new blueprint class of type actor, because it's just going to be a
10
00:00:30,010 --> 00:00:32,770
very simple actor with a box collision.
11
00:00:32,770 --> 00:00:36,670
And if we walk into the box collision, this is going to be our active checkpoint.
12
00:00:36,670 --> 00:00:41,320
So create an actor and I'm going to call BP checkpoint.
13
00:00:41,320 --> 00:00:42,490
Open this up.
14
00:00:42,490 --> 00:00:46,540
And just for visualization I first want to add a cube.
15
00:00:46,540 --> 00:00:48,940
This is not going to be the collision right.
16
00:00:48,940 --> 00:00:52,720
This is just for visualization I want to make it small though.
17
00:00:52,720 --> 00:00:58,180
So here on the scale on the Z just make it a 0.1.
18
00:00:58,180 --> 00:01:00,130
So it's going to be a very small cube.
19
00:01:00,130 --> 00:01:01,810
And this is just for visualization.
20
00:01:01,810 --> 00:01:06,580
This is not going to have any effect on the actual collision that we're going to use.
21
00:01:06,580 --> 00:01:12,880
What we want to use for this is to again select the default scene route and not the cube and look for.
22
00:01:13,680 --> 00:01:14,640
Collision.
23
00:01:14,910 --> 00:01:17,280
And we're going to use a box collision.
24
00:01:17,280 --> 00:01:17,970
Right.
25
00:01:17,970 --> 00:01:19,350
And this is going to be our trigger.
26
00:01:19,350 --> 00:01:21,780
So we can just call it trigger to make it very clear.
27
00:01:21,780 --> 00:01:25,230
And we want to make sure that it is the same size.
28
00:01:25,230 --> 00:01:30,810
So we can use this box extend and just drag to make it around the same size as the platform.
29
00:01:30,810 --> 00:01:33,600
And also here make it the same size.
30
00:01:33,600 --> 00:01:39,510
And we can then make it a little bit higher because we don't want the player to be able to just jump
31
00:01:39,510 --> 00:01:42,990
over the trigger and be able to skip a checkpoint.
32
00:01:44,560 --> 00:01:48,310
Maybe in some games you would want to do this, but we don't want to do this for this game, so just
33
00:01:48,310 --> 00:01:50,140
make it quite tall.
34
00:01:51,980 --> 00:01:53,390
Around 200.
35
00:01:53,390 --> 00:01:58,700
And we then want to drag this upward, because we don't want to have this extend in the floor of the
36
00:01:58,700 --> 00:01:59,390
map.
37
00:01:59,390 --> 00:02:00,290
And just like this.
38
00:02:00,290 --> 00:02:02,360
So this is a very tall checkpoint.
39
00:02:02,360 --> 00:02:04,490
They're not going to be able to jump over it.
40
00:02:04,610 --> 00:02:06,560
And we just prevent issues like this.
41
00:02:06,560 --> 00:02:08,150
And now for the collision settings.
42
00:02:08,150 --> 00:02:13,310
We just want to go in here and drag down to collision collision preset.
43
00:02:13,310 --> 00:02:17,390
And I want to set this to custom because we're not going to use this anywhere else.
44
00:02:17,390 --> 00:02:18,920
We can just set this up in custom.
45
00:02:18,920 --> 00:02:22,760
There's no need to make a preset in the project settings.
46
00:02:22,760 --> 00:02:26,990
And here we just want to ignore everything except for the pawn.
47
00:02:26,990 --> 00:02:31,190
And the pawn should overlap because we want to check if the player walks into this.
48
00:02:31,830 --> 00:02:38,700
And then we simply want to scroll down and go to the on component begin overlap, which we've used a
49
00:02:38,700 --> 00:02:40,890
couple of times throughout this course already.
50
00:02:40,890 --> 00:02:42,060
And here, what do we do?
51
00:02:42,060 --> 00:02:46,890
Well, other actors cast to be player like this.
52
00:02:47,930 --> 00:02:50,690
And for now we just want to print string.
53
00:02:51,910 --> 00:02:53,740
Right and say checkpoint.
54
00:02:54,920 --> 00:02:58,970
And we go back to the map and we now just want to add a checkpoint somewhere here.
55
00:02:58,970 --> 00:02:59,480
Right.
56
00:02:59,480 --> 00:03:02,090
So I can just drag out the BP checkpoint.
57
00:03:02,090 --> 00:03:05,120
And I want to make sure it is on -50.
58
00:03:05,900 --> 00:03:10,490
Because that's the same as the player and as the crab, and we can just drag it over here a little bit
59
00:03:10,490 --> 00:03:11,960
to be on the yellow.
60
00:03:12,500 --> 00:03:15,530
And now I can go in here and I can defeat the crab.
61
00:03:15,530 --> 00:03:19,520
I go here and I step on the checkpoint and you can say it says checkpoint.
62
00:03:20,260 --> 00:03:23,560
It says checkpoint multiple times, though every time I enter it.
63
00:03:23,560 --> 00:03:27,670
And a problem with this is if we have multiple checkpoints, we walk back.
64
00:03:27,670 --> 00:03:33,430
We don't want an old checkpoint to be reactivated, so we actually want to make sure that we can only
65
00:03:33,430 --> 00:03:35,830
activate a checkpoint a single time.
66
00:03:35,830 --> 00:03:41,800
So here we can use a do once node, not the multi-input, just the do once.
67
00:03:41,800 --> 00:03:47,800
And now you can see that if we compile and save I go here I do the same thing.
68
00:03:47,890 --> 00:03:49,810
It's only going to happen one time.
69
00:03:49,810 --> 00:03:55,030
I can't reactivate the same checkpoint again and again, and this is what we want to do.
70
00:03:55,270 --> 00:04:00,700
And since the checkpoint system is a kind of overarching system that is dependent on our game's rules,
71
00:04:00,700 --> 00:04:05,200
this is also something we want to implement in the GM action, the game mode.
72
00:04:05,200 --> 00:04:06,580
So what can we do here?
73
00:04:06,580 --> 00:04:11,470
We can have a variable for active checkpoint.
74
00:04:12,690 --> 00:04:17,070
Like this and just turn this into a BP checkpoint.
75
00:04:17,370 --> 00:04:20,010
And here we use a object reference.
76
00:04:20,010 --> 00:04:20,700
Right.
77
00:04:20,700 --> 00:04:21,750
And compile and save.
78
00:04:21,750 --> 00:04:23,790
By default it is nothing.
79
00:04:23,790 --> 00:04:23,940
Right.
80
00:04:23,940 --> 00:04:29,070
So if I click here, um, the active checkpoint, it is none by default.
81
00:04:29,070 --> 00:04:30,180
So this is fine.
82
00:04:30,180 --> 00:04:36,420
Then in the BP checkpoint we can get a reference to the game mode like we did in the player before,
83
00:04:36,420 --> 00:04:36,900
right.
84
00:04:36,900 --> 00:04:39,750
So in the action char base actually I think.
85
00:04:40,340 --> 00:04:42,020
Now just in the player.
86
00:04:42,020 --> 00:04:44,360
So in the BP player on begin play.
87
00:04:44,360 --> 00:04:44,690
Right.
88
00:04:44,690 --> 00:04:48,980
We do this with the get game mode, cast to game action and set it right.
89
00:04:48,980 --> 00:04:55,190
So the first two parts we can just copy control C, go into the checkpoint on Begin Play control V to
90
00:04:55,190 --> 00:04:56,120
paste this in.
91
00:04:56,120 --> 00:05:00,440
We just get the game mode and we cast it to the GM action here and here.
92
00:05:00,440 --> 00:05:03,830
We also want to save this as GM action.
93
00:05:04,220 --> 00:05:05,030
Like this.
94
00:05:07,060 --> 00:05:10,870
And we can then again access this everywhere in our blueprint.
95
00:05:12,280 --> 00:05:13,420
And what do we do here?
96
00:05:13,420 --> 00:05:18,460
Well, on the overlap event, we don't just print checkpoint, but on completed.
97
00:05:18,580 --> 00:05:19,690
Uh, after the do once.
98
00:05:19,690 --> 00:05:26,530
Well, we want to get the GM action here and set active uh, checkpoint here.
99
00:05:26,530 --> 00:05:27,130
Default set.
100
00:05:27,130 --> 00:05:28,240
Active checkpoint.
101
00:05:28,830 --> 00:05:31,590
And we just pass a reference of our selves.
102
00:05:31,590 --> 00:05:34,890
So just self get a reference to self.
103
00:05:35,400 --> 00:05:37,800
So yeah we're just going to talk to the GM action.
104
00:05:37,800 --> 00:05:39,960
Tell it hey I am the active checkpoint.
105
00:05:39,990 --> 00:05:41,910
Now please save me in here.
106
00:05:42,150 --> 00:05:46,500
And just for now, for the sake of clarity in the BP checkpoint, after we do this, we can just get
107
00:05:46,500 --> 00:05:50,880
the cube, which is just for visibility and just set material.
108
00:05:51,720 --> 00:05:58,650
Uh, here and material element index zero because, yeah, we only have one material here and here.
109
00:05:58,650 --> 00:06:00,240
Just select anything that looks different.
110
00:06:00,240 --> 00:06:00,690
Right.
111
00:06:00,690 --> 00:06:03,720
Um, maybe something green so we can just type in green.
112
00:06:03,720 --> 00:06:04,410
Green.
113
00:06:04,410 --> 00:06:09,120
And if there's nothing here, well you can just click here and show engine content, show plugin content
114
00:06:09,120 --> 00:06:11,670
and just pick any random material.
115
00:06:11,670 --> 00:06:12,420
It doesn't really matter.
116
00:06:12,420 --> 00:06:13,920
This is just for testing now.
117
00:06:13,920 --> 00:06:15,570
So we can compile and save.
118
00:06:15,570 --> 00:06:21,240
And I go in here and touch the checkpoint and you can see it turns green.
119
00:06:21,240 --> 00:06:23,580
And we also know that this worked now.
120
00:06:23,580 --> 00:06:27,030
And in the GM action it now set the active checkpoint.
121
00:06:27,030 --> 00:06:32,400
So now in the function where we respawn the player we need to decide if we have an active checkpoint.
122
00:06:32,400 --> 00:06:34,590
We want to use the active checkpoint.
123
00:06:34,590 --> 00:06:38,100
Otherwise we want to use the player start as the location.
124
00:06:38,100 --> 00:06:44,190
So in here for respawn player, we can just open up some space and we can get active checkpoint.
125
00:06:45,370 --> 00:06:51,040
And we can then drag off here and check for is valid and use the one with the question mark.
126
00:06:52,080 --> 00:06:52,980
So here.
127
00:06:52,980 --> 00:06:58,800
If it is not valid, well, we just execute what we are doing here at the bottom right like this.
128
00:07:00,000 --> 00:07:01,530
And we use the player start.
129
00:07:01,530 --> 00:07:05,310
But if we have an active checkpoint, we can just copy paste all of this.
130
00:07:06,140 --> 00:07:07,160
Except for the player.
131
00:07:07,160 --> 00:07:09,050
Start and put it in here.
132
00:07:11,310 --> 00:07:13,020
And connect this up here.
133
00:07:13,050 --> 00:07:14,130
Like this.
134
00:07:15,290 --> 00:07:17,360
And just open up some more space.
135
00:07:19,330 --> 00:07:22,690
And now here we just want to use the active checkpoint.
136
00:07:22,690 --> 00:07:27,010
So copy paste this put this in here for the transform.
137
00:07:29,160 --> 00:07:29,700
Right?
138
00:07:29,700 --> 00:07:34,080
So if we have a valid active checkpoint, we use the valid active checkpoint.
139
00:07:34,080 --> 00:07:38,700
And you might be wondering that this is maybe not the best way of doing it, because we are kind of
140
00:07:38,700 --> 00:07:40,620
duplicating these nodes.
141
00:07:40,620 --> 00:07:43,980
And one thing I tried doing is to just use a select here, right.
142
00:07:43,980 --> 00:07:49,500
So we can just use a select here and use the active checkpoint is valid.
143
00:07:50,130 --> 00:07:51,810
Uh, and you don't have to do this.
144
00:07:51,810 --> 00:07:57,090
I just want to show you we can use this is valid and then decide here if we use the active checkpoint
145
00:07:57,090 --> 00:07:58,830
or the player start.
146
00:07:58,830 --> 00:08:05,760
But actually using an is valid check or an invalid thing here is not a good idea because for a select
147
00:08:05,760 --> 00:08:08,670
it actually evaluates both options first.
148
00:08:08,670 --> 00:08:11,940
So this is actually going to cause bugs and null errors.
149
00:08:11,940 --> 00:08:14,670
And in this case this is not a good solution.
150
00:08:14,670 --> 00:08:16,470
So I can just get rid of this.
151
00:08:16,470 --> 00:08:19,680
And yeah we're just going to stick with our active checkpoint here.
152
00:08:20,960 --> 00:08:23,450
And at the bottom we're going to stick with our player start.
153
00:08:23,450 --> 00:08:27,380
It's a little bit verbose, but this is not going to cause any null errors.
154
00:08:28,010 --> 00:08:29,450
Now let's just try this out.
155
00:08:29,450 --> 00:08:31,850
So first I don't have a checkpoint.
156
00:08:31,850 --> 00:08:33,049
I just get defeated.
157
00:08:33,140 --> 00:08:35,870
And I start back at the beginning here.
158
00:08:35,870 --> 00:08:36,919
So this is fine.
159
00:08:36,919 --> 00:08:42,049
And now to test the checkpoint actually can't defeat the enemy because I need the enemy to attack me.
160
00:08:42,049 --> 00:08:46,820
So we just skip over it, touch the checkpoint, and now we get defeated by the enemy.
161
00:08:47,370 --> 00:08:49,440
And now I respawn at the checkpoint.
162
00:08:49,440 --> 00:08:51,660
But as you can see, there is one problem.
163
00:08:51,660 --> 00:08:56,130
We actually respawn in the middle of the checkpoint, but it is working.
164
00:08:56,130 --> 00:09:02,070
We just got to adjust the position a little bit, and to do this we can go to the BP checkpoint and
165
00:09:02,070 --> 00:09:07,560
to the viewport and we can on the default scene route, add a scene component.
166
00:09:08,380 --> 00:09:13,930
And just like this, and we can drag it up a little bit to make sure that we spawn in the air.
167
00:09:13,930 --> 00:09:18,730
We don't spawn in here because this is going to be the middle of our character, right?
168
00:09:18,730 --> 00:09:21,070
This is not going to be the feet of our character here.
169
00:09:21,070 --> 00:09:24,940
So this is, uh, some leeway we need to have here.
170
00:09:26,220 --> 00:09:27,870
And it's a little bit hard to see this, right?
171
00:09:27,870 --> 00:09:29,880
Because if we don't click it, we don't know where it is.
172
00:09:29,880 --> 00:09:35,130
And just the thing you can do for this is to, on the scene, add a billboard.
173
00:09:36,720 --> 00:09:37,860
A billboard.
174
00:09:38,040 --> 00:09:39,750
And now the position isn't correct.
175
00:09:39,750 --> 00:09:42,090
So we can just reset here on the location.
176
00:09:42,090 --> 00:09:47,610
And now it's going to be in the same position as our scene, and now we can just see where we drag it.
177
00:09:47,610 --> 00:09:49,530
This just makes it more visually appealing.
178
00:09:49,530 --> 00:09:51,960
We're not going to use the billboard in any gameplay fashion.
179
00:09:51,960 --> 00:09:55,260
This is just to make it easier for us to see where the scene is located.
180
00:09:55,260 --> 00:10:00,840
And yeah, I just put it at about 135, but I think if it's higher than 100, it should be fine.
181
00:10:00,840 --> 00:10:08,940
And now in the, uh, GM action, if we check for the active checkpoint and here for the Get Actor transform,
182
00:10:08,940 --> 00:10:12,150
we actually want to get from the active checkpoint.
183
00:10:12,750 --> 00:10:14,400
We want to get this seen.
184
00:10:14,400 --> 00:10:15,720
So get seen.
185
00:10:16,900 --> 00:10:24,160
Here, get the scene and we then want to get World Transform from this.
186
00:10:25,190 --> 00:10:29,390
Here and split this up and use this instead.
187
00:10:29,390 --> 00:10:31,970
And the rotation, not the scale.
188
00:10:32,090 --> 00:10:33,470
And delete this.
189
00:10:35,000 --> 00:10:36,770
Can use all of this here.
190
00:10:37,870 --> 00:10:40,030
And just open up some space.
191
00:10:41,590 --> 00:10:42,040
And yeah.
192
00:10:42,040 --> 00:10:46,180
So this way we just used the scene component.
193
00:10:46,700 --> 00:10:49,640
In the checkpoint to just make sure we spawn a little bit on top.
194
00:10:49,640 --> 00:10:50,900
So let's try this out.
195
00:10:50,900 --> 00:10:52,700
And actually we get an error here.
196
00:10:52,700 --> 00:10:54,920
So let's check this out in the GM action.
197
00:10:56,090 --> 00:10:59,150
Uh, yeah, it was just we didn't compile, so we just compile and save.
198
00:10:59,730 --> 00:11:02,100
And now I skip the enemy.
199
00:11:02,800 --> 00:11:05,950
I take the checkpoint, I get defeated by the enemy.
200
00:11:06,630 --> 00:11:09,810
And now we nicely spawn above the checkpoint.
201
00:11:09,810 --> 00:11:14,010
And this is a very common way of implementing checkpoints that you can use in all of your games.
202
00:11:14,010 --> 00:11:19,860
And now that we're done testing this system, we can just go to the BP player and set our health back.
203
00:11:19,860 --> 00:11:25,110
So in the BPC vitality, we can set our health back to ten, which should be our default value.
204
00:11:25,140 --> 00:11:27,330
Don't forget this compound safe.
205
00:11:27,330 --> 00:11:28,770
Make sure to save all.
206
00:11:28,770 --> 00:11:32,100
And now we can just, uh, close all the tabs to the right.
207
00:11:32,100 --> 00:11:34,710
And yeah, we are done with the response system.
208
00:11:34,710 --> 00:11:37,230
In the next video, we're going to take care of respawning.
209
00:11:37,230 --> 00:11:41,610
If we fall off the map, which is a different thing we need to implement separately.
18929
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.