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,310
We still haven't implemented what should happen if the player is defeated, right?
2
00:00:04,310 --> 00:00:07,610
So we take damage now we take damage and all of these things.
3
00:00:07,610 --> 00:00:13,160
If we take enough damage now, our player is just being despawned and we get this weird screen where
4
00:00:13,160 --> 00:00:15,740
we just don't see anything because we're not possessing any pawn.
5
00:00:15,740 --> 00:00:17,960
And also if we exit out, we get an error message.
6
00:00:17,960 --> 00:00:23,060
So let's start taking care of these problems and actually respawn the player in here.
7
00:00:23,060 --> 00:00:28,130
Just dismiss this, and we can just close all of the windows to the right and just start from fresh
8
00:00:28,130 --> 00:00:28,670
here.
9
00:00:29,490 --> 00:00:34,980
The first thing we want to do is that if the player is destroyed, we just want to respawn a new player
10
00:00:34,980 --> 00:00:40,080
in this player, start location and change the pawn that we're possessing from the old one to the new
11
00:00:40,080 --> 00:00:40,500
one.
12
00:00:40,500 --> 00:00:43,650
When it comes to respawning, there's usually two options.
13
00:00:43,650 --> 00:00:49,770
Either we destroy the old character, spawn a new character and possess it, or we just teleport the
14
00:00:49,770 --> 00:00:54,900
current character to the spawn position and reset the health and all of the other states.
15
00:00:54,900 --> 00:00:59,820
Both of these methods have their own pros and cons and things you need to look out for, but generally
16
00:00:59,820 --> 00:01:04,170
speaking, destroying the old actor and spawning a new one is the easier method.
17
00:01:04,170 --> 00:01:10,440
There is no risk of forgetting to reset the health or other states and the bugs that come with that.
18
00:01:10,890 --> 00:01:14,640
For testing, we just want to set the player health very low now.
19
00:01:14,640 --> 00:01:23,010
So in the BP player, uh, we just look for the, uh, sorry here, the BPC vitality, and we just set
20
00:01:23,010 --> 00:01:24,300
the max health to one.
21
00:01:24,300 --> 00:01:30,870
And this is just so we can easily test just being destroyed and can test the respawning much easier
22
00:01:30,870 --> 00:01:32,790
than just having to get hit ten times.
23
00:01:33,150 --> 00:01:37,650
Next up, we want to create a function that spawns a new player.
24
00:01:37,650 --> 00:01:41,970
And we don't want to put this on the player of course, because the player is being destroyed.
25
00:01:41,970 --> 00:01:48,120
And this is kind of an overarching gameplay thing that the game mode should be taken care of.
26
00:01:48,120 --> 00:01:53,550
So in the content drawer we go to blueprints and we created this GM action in the beginning, open it
27
00:01:53,550 --> 00:01:54,060
up.
28
00:01:54,060 --> 00:01:58,770
And we mostly created this so we can set the default pawn class.
29
00:01:58,770 --> 00:02:01,200
But actually this is a full blueprint.
30
00:02:01,200 --> 00:02:02,490
So we can add logic here.
31
00:02:02,490 --> 00:02:03,480
We can add functions.
32
00:02:03,480 --> 00:02:08,310
We can add variables that can be called from other places and from other actors.
33
00:02:08,310 --> 00:02:11,910
So this is the perfect place for something like a respawn here.
34
00:02:11,910 --> 00:02:16,200
Let's just create a new function and it's called the respawn player.
35
00:02:17,440 --> 00:02:18,700
And what can we do here?
36
00:02:18,700 --> 00:02:22,300
Well, we just spawn actor from class.
37
00:02:23,980 --> 00:02:29,740
And here, well, we could just select the player class, but actually we can also just get the default
38
00:02:29,740 --> 00:02:31,000
pawn class right.
39
00:02:31,000 --> 00:02:35,440
Because the default pawn class exists inside of this game mode.
40
00:02:35,440 --> 00:02:35,980
Right.
41
00:02:35,980 --> 00:02:40,540
So instead of having to manually pick this well we can just use the same one that is in here.
42
00:02:40,960 --> 00:02:46,090
And now we just can split the spawn transform um split struct pin.
43
00:02:46,090 --> 00:02:49,330
So these are separate nouns that of having to pass a transform.
44
00:02:49,330 --> 00:02:53,980
And for the collision handling override we want to make sure to always spawn ignore collision because
45
00:02:53,980 --> 00:02:57,970
we don't want it to stop spawning the player just because it's being blocked by something.
46
00:02:57,970 --> 00:03:01,750
And in the end we then want to get player controller.
47
00:03:03,310 --> 00:03:04,240
Get player controller.
48
00:03:04,240 --> 00:03:07,090
And again this is a built in thing with Unreal Engine.
49
00:03:07,090 --> 00:03:09,400
And here we can then say possess.
50
00:03:10,200 --> 00:03:13,650
And pass it, this new character that we are going to spawn.
51
00:03:13,650 --> 00:03:17,100
And yes, so this spawns a new player in this location.
52
00:03:17,100 --> 00:03:22,170
We got to give it a better location later on, and then it just tells the player controller, hey,
53
00:03:22,170 --> 00:03:25,800
you are supposed to be controlling this character now, not the old one.
54
00:03:26,250 --> 00:03:28,590
And yeah, I'm just rearranging some notes here.
55
00:03:29,660 --> 00:03:32,570
But we still need to have a place where we can call this from.
56
00:03:32,570 --> 00:03:35,660
So if we look back on the other parts of our code.
57
00:03:35,660 --> 00:03:44,210
So in the content drawer, blueprints, characters, action, char base, and in here we have the,
58
00:03:44,210 --> 00:03:45,800
um, any damage, right?
59
00:03:45,800 --> 00:03:50,750
We take damage, we check if we are defeated and then we destroy the actor.
60
00:03:50,750 --> 00:03:56,690
So now a problem we have here is that, well, we do want to destroy the actor in case that it is an
61
00:03:56,690 --> 00:03:57,260
enemy.
62
00:03:57,260 --> 00:04:01,130
But we don't want to only destroy the actor if it's a player.
63
00:04:01,130 --> 00:04:03,830
We want to call this respawn function that we just created.
64
00:04:03,830 --> 00:04:08,480
We also want to later put in some camera fade and like all of those kind of things, have a little delay
65
00:04:08,480 --> 00:04:10,400
before we destroy the actor.
66
00:04:10,400 --> 00:04:15,380
So actually we need to add some branching logic here for the player and for the enemy.
67
00:04:15,380 --> 00:04:17,899
And there are multiple ways we could go about this.
68
00:04:17,899 --> 00:04:19,790
The most obvious one, which I don't recommend.
69
00:04:19,790 --> 00:04:23,930
It works, but it's a little bit dirty, is to just get self.
70
00:04:24,440 --> 00:04:27,770
And then self cast to be player.
71
00:04:28,040 --> 00:04:29,600
And then we can decide here.
72
00:04:29,600 --> 00:04:32,660
So if it's not a player right cast failed would be an enemy.
73
00:04:32,660 --> 00:04:33,890
We could then just destroy.
74
00:04:33,890 --> 00:04:36,170
And if it's true then we do something else.
75
00:04:36,170 --> 00:04:37,670
But this works.
76
00:04:37,760 --> 00:04:42,500
Um, it's not the best way though, because in this way we put all of the logic we want to use in the
77
00:04:42,500 --> 00:04:44,780
player inside of the action char base.
78
00:04:44,780 --> 00:04:49,940
I think we just want to use an event dispatcher, which you can see here, and basically just tell the
79
00:04:49,940 --> 00:04:52,280
child, hey, you got destroyed.
80
00:04:52,280 --> 00:04:56,750
Decide by yourself what you want to do with this information so we can just get rid of this here.
81
00:04:56,780 --> 00:04:57,680
Don't use this.
82
00:04:57,680 --> 00:05:00,590
And we're going to create a new event dispatcher.
83
00:05:01,010 --> 00:05:04,700
Click on the plus and just call it defeated.
84
00:05:05,980 --> 00:05:06,550
Like this.
85
00:05:06,550 --> 00:05:12,610
And we can then drag this out here and call the feed it and get rid of this destroy actor.
86
00:05:12,610 --> 00:05:15,160
Only connect the call defeated.
87
00:05:15,160 --> 00:05:15,700
Right.
88
00:05:15,700 --> 00:05:21,550
So this is an event that other blueprints not just children, but pretty much anybody who has a reference
89
00:05:21,550 --> 00:05:23,500
to this blueprint can subscribe to.
90
00:05:23,500 --> 00:05:25,720
But we're going to use it in the children.
91
00:05:25,720 --> 00:05:31,720
So when we open up the content drawer, we go to enemies and we want to have the BP enemy base.
92
00:05:32,380 --> 00:05:38,080
And here on Begin Play because you subscribe to an event like this on Begin Play well, we can just
93
00:05:38,080 --> 00:05:46,030
look for bind defeated write bind event to defeated which is again this defeated event dispatcher which
94
00:05:46,030 --> 00:05:46,960
we created.
95
00:05:48,950 --> 00:05:51,440
So in here we just want to connect this here.
96
00:05:51,770 --> 00:05:54,260
And here we drag off and.
97
00:05:55,550 --> 00:05:57,560
And add custom event.
98
00:05:57,980 --> 00:06:00,590
And we just want to call this on defeated.
99
00:06:01,230 --> 00:06:01,950
Like this.
100
00:06:01,950 --> 00:06:04,860
And yeah, so if the feed it happens we call this undefeated.
101
00:06:04,860 --> 00:06:09,090
And here we just destroy the actor for an enemy, right.
102
00:06:09,090 --> 00:06:11,040
For a player, we're going to do something else.
103
00:06:11,040 --> 00:06:13,260
But if the enemy gets the message he got defeated.
104
00:06:13,260 --> 00:06:14,670
Well, just destroy yourself.
105
00:06:14,670 --> 00:06:16,770
It's all fine just to show how this works, right?
106
00:06:16,770 --> 00:06:20,070
I can compile, save, I go here, I shoot the enemy.
107
00:06:21,070 --> 00:06:23,110
The enemy gets defeated, it's all fine.
108
00:06:23,110 --> 00:06:26,380
But the player actually nothing happens, right?
109
00:06:26,380 --> 00:06:28,510
Because we didn't listen to the event.
110
00:06:28,510 --> 00:06:30,670
Dispatcher so nothing happens.
111
00:06:30,670 --> 00:06:33,310
So we can implement this now in the player as well.
112
00:06:33,730 --> 00:06:39,310
So for the player, open up the blueprints characters, player by player.
113
00:06:39,310 --> 00:06:45,940
And on the event graph we want to look for Beginplay and we can just type it in Beginplay.
114
00:06:45,940 --> 00:06:49,930
It's going to teleport us up here and we want to add yet another row.
115
00:06:49,930 --> 00:06:53,470
So maybe open up some space here and here.
116
00:06:53,470 --> 00:06:56,110
We want to bind the defeated.
117
00:06:57,570 --> 00:06:59,880
Just like we did there and here.
118
00:06:59,880 --> 00:07:05,010
We can also just drag off, add custom event on the feed it.
119
00:07:07,720 --> 00:07:08,080
Here.
120
00:07:08,080 --> 00:07:11,500
We want to call this function on the game mode, which we created.
121
00:07:11,500 --> 00:07:15,580
But the problem is that right now we don't have a reference to the game mode.
122
00:07:15,580 --> 00:07:18,700
So we can actually just open up some space here.
123
00:07:19,910 --> 00:07:22,400
And get game mode.
124
00:07:22,430 --> 00:07:25,070
This is something you can call from every blueprint.
125
00:07:26,570 --> 00:07:29,450
And it's usually customary to do this on begin play.
126
00:07:29,450 --> 00:07:35,810
And here we can just cast two GM action, which is our instance of the game mode, and connect this
127
00:07:35,810 --> 00:07:38,690
here and then save a reference right.
128
00:07:38,690 --> 00:07:41,780
So promote the variable and just call it.
129
00:07:42,360 --> 00:07:45,120
And just call it GM action.
130
00:07:46,320 --> 00:07:49,410
Like this and connect this here as well.
131
00:07:51,020 --> 00:07:56,540
And one risk you have with this now is that if we cannot find a game mode that is GM action, the cast
132
00:07:56,540 --> 00:07:59,420
is going to fail and nothing after that is going to execute.
133
00:07:59,420 --> 00:07:59,630
Right?
134
00:07:59,630 --> 00:08:02,330
So we're not going to set up the player control and all of these things.
135
00:08:02,330 --> 00:08:04,580
So we could put this on a separate line.
136
00:08:04,580 --> 00:08:08,960
But the real truth is that if we cannot find our game mode, the entire game is broken anyway.
137
00:08:08,960 --> 00:08:12,650
So I don't see a problem with having this lined up in this fashion.
138
00:08:12,650 --> 00:08:13,130
Right?
139
00:08:13,130 --> 00:08:17,780
But now we have the game mode, we get it at the begin play, and we can then access it in our entire
140
00:08:17,780 --> 00:08:19,250
blueprint whenever we need it.
141
00:08:19,250 --> 00:08:21,170
And well, here we do need it.
142
00:08:21,170 --> 00:08:22,580
So bind undefeated.
143
00:08:22,610 --> 00:08:24,740
We can just get the GM action.
144
00:08:26,070 --> 00:08:30,720
And call respawn player on this and connect this here.
145
00:08:31,080 --> 00:08:31,500
Right.
146
00:08:31,500 --> 00:08:34,799
So on the enemy we decided we just destroy the enemy here.
147
00:08:34,799 --> 00:08:35,429
For now.
148
00:08:35,429 --> 00:08:39,360
We just decided we're just going to respawn the player and we're not going to destroy anything yet.
149
00:08:39,360 --> 00:08:41,700
And let's just have a look at how this works.
150
00:08:42,179 --> 00:08:46,650
And what we can do now is that if we jump in here, you're going to see some very weird behavior.
151
00:08:46,650 --> 00:08:51,210
We're just going to keep on spawning, um, new players as we take damage.
152
00:08:51,450 --> 00:08:55,650
Uh, first of all, we need to make sure that we can only be defeated a single time, so this doesn't
153
00:08:55,650 --> 00:08:56,400
happen.
154
00:08:56,400 --> 00:09:03,690
So in the GM action char base here, where we do the whole thing with, uh, receive damage and is defeated.
155
00:09:03,690 --> 00:09:06,600
Well, we just want to drag off here to the side.
156
00:09:07,330 --> 00:09:12,190
And go like this and just add a branch here.
157
00:09:13,570 --> 00:09:14,890
You add a branch.
158
00:09:16,840 --> 00:09:18,580
And check for BPC.
159
00:09:18,580 --> 00:09:21,190
Vitality is defeated.
160
00:09:21,490 --> 00:09:22,750
Not boolean.
161
00:09:24,460 --> 00:09:25,180
Like this.
162
00:09:26,370 --> 00:09:27,720
And connect this here.
163
00:09:28,440 --> 00:09:30,120
Need to open up some more space.
164
00:09:32,430 --> 00:09:32,850
Right.
165
00:09:32,850 --> 00:09:35,850
So we're not gonna do any damage calculations.
166
00:09:35,850 --> 00:09:39,840
Anything related to that if we are already defeated, right?
167
00:09:39,840 --> 00:09:43,110
We're not supposed to be able to take damage if we are defeated.
168
00:09:43,110 --> 00:09:48,540
And this will also prevent this whole issue with respawning the character multiple times.
169
00:09:48,540 --> 00:09:48,750
Right?
170
00:09:48,750 --> 00:09:49,560
So like this.
171
00:09:49,560 --> 00:09:50,970
We only spawn one.
172
00:09:51,800 --> 00:09:54,140
And here we're going to keep on taking damage, right?
173
00:09:54,140 --> 00:09:56,810
But we don't respawn more players.
174
00:09:56,810 --> 00:09:59,690
But this is also a small issue we got to take care of.
175
00:09:59,690 --> 00:10:05,450
So in the BP player where we have our any damage event.
176
00:10:06,290 --> 00:10:07,220
Any damage.
177
00:10:07,220 --> 00:10:07,670
Right.
178
00:10:07,670 --> 00:10:08,960
We have the cancel slide.
179
00:10:08,960 --> 00:10:09,770
We have this.
180
00:10:09,800 --> 00:10:10,910
Was hit during charge.
181
00:10:10,910 --> 00:10:13,430
We have the trigger invincibility and knockback.
182
00:10:14,860 --> 00:10:19,600
So both of these things we actually only want to do if we aren't defeated either, right?
183
00:10:19,600 --> 00:10:22,960
So because we run a logic here, this is still going to happen.
184
00:10:22,960 --> 00:10:28,540
So on the BPC vitality we can drag out here and again check for is defeated.
185
00:10:29,330 --> 00:10:31,010
And not boolean.
186
00:10:32,290 --> 00:10:34,690
And add a branch here.
187
00:10:37,150 --> 00:10:38,650
Open up some more space here.
188
00:10:39,670 --> 00:10:45,580
And yet we're not gonna trigger the invincibility if we are already defeated, because there is no point
189
00:10:45,580 --> 00:10:45,850
to this.
190
00:10:45,850 --> 00:10:49,270
And we just get this kind of weird behavior, which we already had.
191
00:10:49,270 --> 00:10:49,750
Right?
192
00:10:49,750 --> 00:10:50,440
So now.
193
00:10:51,390 --> 00:10:51,810
Yeah.
194
00:10:51,810 --> 00:10:53,400
So this is already better, right?
195
00:10:53,400 --> 00:10:55,380
But the character just gets stuck here.
196
00:10:55,440 --> 00:10:59,730
Um, and this looks very funny, but this is already better, right?
197
00:10:59,730 --> 00:11:04,470
Because now we're just gonna despawn the player and take care of those things, and this is going to
198
00:11:04,470 --> 00:11:05,730
fix the problem.
199
00:11:05,730 --> 00:11:08,250
So for now, just go back to the BP player.
200
00:11:08,250 --> 00:11:08,940
Right.
201
00:11:08,940 --> 00:11:14,730
And if we go back to our begin play on the event graph, just look for Beginplay.
202
00:11:14,940 --> 00:11:21,420
And after the on defeated event after respawn player later on we want to have a delay, but for now
203
00:11:21,420 --> 00:11:22,770
just destroy the actor.
204
00:11:22,770 --> 00:11:27,870
So we spawn the new actor and we destroy the old actor, the old player and just have a look at this.
205
00:11:27,870 --> 00:11:28,200
Right?
206
00:11:28,200 --> 00:11:29,940
So now this looks a lot better, right?
207
00:11:29,940 --> 00:11:32,130
So this is the function that we want.
208
00:11:32,130 --> 00:11:33,330
Um, but it is instant.
209
00:11:33,330 --> 00:11:34,560
So we want to have a delay.
210
00:11:34,560 --> 00:11:38,520
We want to make it very clear to the player, um, that they got defeated.
211
00:11:38,520 --> 00:11:43,260
And also the spawn location is not correct yet because you can see we are just kind of in the foreground
212
00:11:43,260 --> 00:11:45,150
in front of the crab.
213
00:11:45,150 --> 00:11:46,590
So we also have to do that.
214
00:11:46,590 --> 00:11:51,000
But you can see we get all of these error messages now because we delete the player at a critical time
215
00:11:51,000 --> 00:11:52,500
when it's still being processed.
216
00:11:52,500 --> 00:11:57,690
But this is going to fix itself, because we're actually going to implement a delay between getting
217
00:11:57,690 --> 00:12:00,210
the last hit and actually deleting the actor.
218
00:12:00,930 --> 00:12:03,540
We can just close this and in the beep.
219
00:12:03,540 --> 00:12:03,990
Player.
220
00:12:03,990 --> 00:12:04,320
Right.
221
00:12:04,320 --> 00:12:06,810
We can just put all of this to the right side for now.
222
00:12:06,810 --> 00:12:13,200
And we want to just take care of all of these overlap issues, the errors we got here and just turn
223
00:12:13,200 --> 00:12:17,370
all of these things off, have a delay, and then after that respawn the player.
224
00:12:18,100 --> 00:12:26,140
The first thing you want to do is to just get the capsule component, and we set collision enabled to
225
00:12:26,140 --> 00:12:31,900
no collision because we don't want anything to be able to still collide with our character after it
226
00:12:31,900 --> 00:12:32,860
is defeated.
227
00:12:33,470 --> 00:12:35,480
And for now, just have a look at what this looks like.
228
00:12:35,480 --> 00:12:35,690
Right.
229
00:12:35,690 --> 00:12:36,470
So we can do this.
230
00:12:36,470 --> 00:12:40,040
And I jump into the enemy and I just fall through the floor.
231
00:12:40,040 --> 00:12:44,840
And in 3D levels this looks kind of weird, but in 2D levels, this has a really nice effect that is
232
00:12:44,840 --> 00:12:46,340
often used in retro games.
233
00:12:46,340 --> 00:12:49,970
However, we don't want the camera to keep following.
234
00:12:49,970 --> 00:12:51,860
We just kind of want to detach the camera.
235
00:12:51,860 --> 00:12:56,630
You kind of see the character fall out of the map, and this makes it very clear that you got defeated,
236
00:12:56,630 --> 00:12:58,880
and detaching the camera is very easy.
237
00:12:58,880 --> 00:13:00,410
Just create some more space here.
238
00:13:00,410 --> 00:13:01,040
For now.
239
00:13:01,040 --> 00:13:07,940
We can get the spring arm and we just call detach from component.
240
00:13:07,940 --> 00:13:12,140
And this is going to detach the spring arm from the capsule component.
241
00:13:12,140 --> 00:13:13,730
And just put this in here.
242
00:13:14,300 --> 00:13:20,780
And for all of these rules, we just want to say keep world, keep world, keep world, because we want
243
00:13:20,780 --> 00:13:23,630
to completely detach everything from the parent.
244
00:13:25,460 --> 00:13:26,960
Let's have a look at this again now.
245
00:13:26,960 --> 00:13:27,260
Right.
246
00:13:27,260 --> 00:13:33,260
So I jump into the enemy and you see this kind of nice effect of falling through the floor, but actually
247
00:13:33,260 --> 00:13:37,880
to have this nice effect that you see in the games, we don't just want to fall through the map, we
248
00:13:37,880 --> 00:13:40,790
actually want to trigger the knockback one time.
249
00:13:40,880 --> 00:13:42,290
After all, if we get hit.
250
00:13:42,290 --> 00:13:49,700
So in here in the BP player on the any damage event we set that the is defeated.
251
00:13:49,700 --> 00:13:50,180
Not true.
252
00:13:50,180 --> 00:13:52,340
Only in that case do we trigger the invincibility.
253
00:13:52,340 --> 00:13:56,510
This is fine, but we do want to trigger the knockback either way.
254
00:13:56,510 --> 00:14:01,970
So here we can just shortcut through from the false here and go like this.
255
00:14:01,970 --> 00:14:03,800
Double click like this.
256
00:14:04,720 --> 00:14:10,120
And in this case, if we use the false, we just skip over this trigger invincibility and go into the
257
00:14:10,120 --> 00:14:10,780
knockback.
258
00:14:10,780 --> 00:14:15,760
We could also drag the knockback over here, but it is a little bit complicated with these collapsed
259
00:14:15,760 --> 00:14:22,420
nodes because we would have to create an output and we have multiple lanes that we go along here.
260
00:14:22,420 --> 00:14:24,700
So this makes it a little bit complicated.
261
00:14:24,700 --> 00:14:27,790
And this is just an easy way that we can do it.
262
00:14:27,790 --> 00:14:31,600
Still just by tunnelling around this trigger invincibility.
263
00:14:31,600 --> 00:14:33,820
And this is just a little blueprint trick.
264
00:14:33,820 --> 00:14:36,610
And now if we do it it looks a lot nicer right?
265
00:14:36,610 --> 00:14:41,260
We get knocked back, the camera stays in place, and the player just kind of falls out of the map.
266
00:14:41,260 --> 00:14:43,990
This is a very comedic effect you see in many games.
267
00:14:43,990 --> 00:14:46,780
And now let's also input the respawn again.
268
00:14:46,780 --> 00:14:47,110
Right?
269
00:14:47,110 --> 00:14:55,840
So in the BP player, if we go to our begin play event on top right, the undefeated, we do this thing
270
00:14:55,840 --> 00:14:58,600
with the collision and the detaching the camera.
271
00:14:58,600 --> 00:15:00,910
And now let's just put in a delay here.
272
00:15:00,910 --> 00:15:06,700
So delay and let's just start with a two seconds and connect here.
273
00:15:07,090 --> 00:15:07,900
Go like this.
274
00:15:07,900 --> 00:15:09,220
And now let's just try it right.
275
00:15:09,220 --> 00:15:14,830
So I get hit I fly out of the map, I wait two seconds and the next character spawns in and I can play
276
00:15:14,830 --> 00:15:16,630
normally there's no errors.
277
00:15:16,630 --> 00:15:20,380
And this is how we prevented the errors from the overlap that we got before.
278
00:15:20,380 --> 00:15:23,290
And we also made getting defeated look a lot nicer.
279
00:15:23,290 --> 00:15:26,830
However, there still are a couple of things we can do to make this even smoother.
280
00:15:27,380 --> 00:15:33,980
Let's just turn the delay into a variable now and promote the variable and just call the respawn delay.
281
00:15:34,840 --> 00:15:37,480
This and open up some space.
282
00:15:38,390 --> 00:15:41,090
And we want to now add a camera fade.
283
00:15:41,090 --> 00:15:47,150
So before we just respawn and switch positions, we want to fade the camera out to black and then fade
284
00:15:47,150 --> 00:15:47,930
in again.
285
00:15:48,680 --> 00:15:55,340
To do this, we can just get camera Manager, which again is something built in with Unreal Engine like
286
00:15:55,340 --> 00:15:55,940
this.
287
00:15:56,670 --> 00:16:00,300
And we can say start camera fade.
288
00:16:01,290 --> 00:16:02,760
And put this up here.
289
00:16:04,300 --> 00:16:05,650
Connect all of these.
290
00:16:08,270 --> 00:16:08,840
This.
291
00:16:10,270 --> 00:16:10,960
And yes.
292
00:16:10,960 --> 00:16:12,430
So what do we want to do?
293
00:16:12,460 --> 00:16:19,000
We want to start from alpha zero, which means transparent to alpha one, which is the full color.
294
00:16:19,000 --> 00:16:21,280
And you can actually pick the color here.
295
00:16:21,280 --> 00:16:25,720
So we can pick black if we want to fade to black or white or whatever color you want.
296
00:16:25,720 --> 00:16:29,230
And we want to use the same amount of time as the respawn delay.
297
00:16:29,230 --> 00:16:32,950
So we can just copy paste this here and use this for the duration.
298
00:16:34,160 --> 00:16:34,970
And hold one.
299
00:16:34,970 --> 00:16:35,390
Finished.
300
00:16:35,390 --> 00:16:35,600
Yeah.
301
00:16:35,600 --> 00:16:37,190
So it doesn't just snap back to zero.
302
00:16:37,190 --> 00:16:38,090
Just hold when finished.
303
00:16:38,090 --> 00:16:41,840
So we stay at one and now we can just look at this right.
304
00:16:41,840 --> 00:16:47,300
We do this and we jump here and you see the camera fade out but it never fades back in.
305
00:16:47,300 --> 00:16:48,890
So we need to take care of this.
306
00:16:48,890 --> 00:16:50,690
And we can just copy paste all of this.
307
00:16:50,690 --> 00:16:56,810
And after the delay, after responding to character and between the straw actor, we can just put this
308
00:16:56,810 --> 00:16:57,260
in here.
309
00:16:57,260 --> 00:16:58,670
Wedge this in here.
310
00:16:59,990 --> 00:17:02,540
And we want to do the opposite.
311
00:17:02,540 --> 00:17:08,660
So we want to go from Alpha one, which is the color, to alpha zero which is transparent.
312
00:17:09,109 --> 00:17:12,050
And here we hit the other nodes.
313
00:17:12,050 --> 00:17:15,740
And now we can just look at this I jump in here, we fade out.
314
00:17:16,710 --> 00:17:18,450
And we fade back in with a new character.
315
00:17:18,450 --> 00:17:21,150
So this is how you do a basic respawn.
316
00:17:21,740 --> 00:17:25,160
Now in here and now we just want to make this a little bit more modular.
317
00:17:25,160 --> 00:17:28,700
So make sure to select this and select all of these.
318
00:17:28,730 --> 00:17:31,610
The ones at the bottom here hold control like this.
319
00:17:31,610 --> 00:17:33,380
Make sure this one is not included.
320
00:17:33,380 --> 00:17:34,400
This one is not included.
321
00:17:34,400 --> 00:17:37,460
Just all of the logic that happens after the undefeated.
322
00:17:37,460 --> 00:17:38,540
Also the lower ones.
323
00:17:38,540 --> 00:17:42,500
Otherwise you get an error and we just right click and collapse nodes.
324
00:17:42,500 --> 00:17:44,810
And we can now drag this over here.
325
00:17:45,850 --> 00:17:49,480
And just call this respawn sequence.
326
00:17:53,730 --> 00:17:58,350
And one last thing we still want to do in this video is that again, if we get defeated, we just kind
327
00:17:58,350 --> 00:18:00,150
of respond this random position, right?
328
00:18:00,150 --> 00:18:01,860
We aren't in our lane anymore.
329
00:18:01,860 --> 00:18:03,450
We kind of move forward.
330
00:18:03,450 --> 00:18:04,620
We are off our lane.
331
00:18:04,620 --> 00:18:12,180
So we just want to get the position of this player start and want to use this for our spawn position.
332
00:18:12,180 --> 00:18:19,020
And where we do this is in the GM action right here in the respawn player function, we just have the
333
00:18:19,020 --> 00:18:21,060
zero, zero, zero and the rotation.
334
00:18:21,060 --> 00:18:26,010
We actually want to use the location and rotation of this player start.
335
00:18:26,010 --> 00:18:27,300
And how do we do this?
336
00:18:27,300 --> 00:18:33,330
Well, on begin play we first want to get a reference to this player start.
337
00:18:33,330 --> 00:18:41,580
So here on Beginplay we can just get actor of class get actor of class like this and look for the player
338
00:18:41,580 --> 00:18:42,270
start.
339
00:18:43,980 --> 00:18:44,940
Players start like this.
340
00:18:44,940 --> 00:18:45,270
Right.
341
00:18:45,270 --> 00:18:50,010
And it's just going to look for this in the map and it's going to return the first one it finds.
342
00:18:50,010 --> 00:18:52,590
And generally we should only have one player start.
343
00:18:52,590 --> 00:18:54,480
So it's going to return a the player start.
344
00:18:54,480 --> 00:18:56,520
And this is already being casted.
345
00:18:56,520 --> 00:19:02,100
So we just have to save it, promote the variable and just say player start like this.
346
00:19:03,170 --> 00:19:07,400
And we can then use this in the respawn player function.
347
00:19:07,400 --> 00:19:07,580
Right.
348
00:19:07,580 --> 00:19:11,030
So here we can just get player start.
349
00:19:13,260 --> 00:19:20,070
And we can get Actor Transform like this and split the struct pin.
350
00:19:20,070 --> 00:19:22,920
And we're only going to use the location and the rotation.
351
00:19:22,920 --> 00:19:28,530
Again, scale is weird because if we change the scale here, our character is going to be huge, so
352
00:19:28,530 --> 00:19:29,790
we don't want to mess with that.
353
00:19:29,790 --> 00:19:31,200
It should always be one.
354
00:19:31,200 --> 00:19:33,690
And now we just get the player start right.
355
00:19:33,690 --> 00:19:35,910
If we get defeated, let's try this out.
356
00:19:35,910 --> 00:19:40,500
I jump in here, we get defeated and we are spawning in the correct position.
357
00:19:40,500 --> 00:19:40,650
Right?
358
00:19:40,650 --> 00:19:45,300
You can see that we are now in the middle of this cube instead of being at the beginning, right?
359
00:19:45,870 --> 00:19:48,060
And this kind of fixes our issue.
360
00:19:48,060 --> 00:19:52,950
Of course, if the game continues, we also want to have checkpoints and spawn in later locations if
361
00:19:52,950 --> 00:19:55,200
we pass a certain point in the game.
362
00:19:55,200 --> 00:19:57,210
So that's what we're going to do in the next video.
32795
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.