Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,050 --> 00:00:04,670
Now that the damage and invincibility is working, we want to add a little bit of knockback if the player
2
00:00:04,670 --> 00:00:05,750
takes damage.
3
00:00:06,460 --> 00:00:09,550
A very easy way of doing this is to go to the BP player.
4
00:00:09,550 --> 00:00:15,490
And here in the any damage event, after we trigger the invincibility, we can simply use the launch
5
00:00:15,490 --> 00:00:17,140
character node.
6
00:00:18,050 --> 00:00:21,920
And here you can specify a vector which we want to be launched into.
7
00:00:21,920 --> 00:00:26,570
And if we just want to test it with going upward we can just put in 2000.
8
00:00:26,570 --> 00:00:29,930
And this is just going to shoot us straight up if we take any damage.
9
00:00:29,930 --> 00:00:31,550
So I can just test this out.
10
00:00:31,550 --> 00:00:34,280
And yeah, you can see we just get flung in the air.
11
00:00:34,280 --> 00:00:37,430
And this is a very easy way of implementing damage.
12
00:00:37,430 --> 00:00:39,110
But we don't just want to go upward.
13
00:00:39,110 --> 00:00:43,580
We also want to be knocked to the left if the character is on the right side, and if the enemy is on
14
00:00:43,580 --> 00:00:46,490
the left side, we want to be knocked to the right direction as well.
15
00:00:46,490 --> 00:00:48,260
So let's try doing this.
16
00:00:48,720 --> 00:00:52,920
The first thing we need to do is detect if the enemy is on a right or left side.
17
00:00:52,950 --> 00:01:02,250
So in here, before we call the launch character, I want to use the look at rotation node find look
18
00:01:02,250 --> 00:01:03,300
at rotation.
19
00:01:03,300 --> 00:01:07,740
And this is a very handy node that we can give a start position and a target position.
20
00:01:07,740 --> 00:01:11,220
In this case the start position is our character our player.
21
00:01:11,220 --> 00:01:13,230
So we can just get actor location.
22
00:01:13,730 --> 00:01:20,780
And it's gonna look into a certain direction, and the target is going to be the projectile or the enemy
23
00:01:20,780 --> 00:01:22,340
that applied damage to us.
24
00:01:22,340 --> 00:01:23,840
So the damage causer.
25
00:01:25,070 --> 00:01:30,500
However, for this to work properly, we need to make sure that the apply damage event is properly being
26
00:01:30,500 --> 00:01:30,890
passed.
27
00:01:30,890 --> 00:01:36,980
A damage causer and what we are doing here in the player is when we begin overlap, like we are checking
28
00:01:36,980 --> 00:01:41,180
if we are hitting an enemy, right and we apply damage to ourselves.
29
00:01:41,180 --> 00:01:46,190
So we need to actually pass the damage causer in here as the enemy.
30
00:01:46,190 --> 00:01:49,550
So right here we check which enemy are we overlapping with.
31
00:01:49,550 --> 00:01:52,610
So this enemy should be the damage causer.
32
00:01:52,610 --> 00:01:54,230
So we just need to connect this here.
33
00:01:55,430 --> 00:01:56,210
Go like this.
34
00:01:56,210 --> 00:02:00,560
And yeah, if you don't know where this is, this is the on component began overlap event on the capsule
35
00:02:00,560 --> 00:02:06,890
component where we apply damage to ourselves and just double click to create some reroute nodes.
36
00:02:06,890 --> 00:02:13,160
And now if we do this, the damage causer is going to be properly passed through here.
37
00:02:13,160 --> 00:02:15,470
And now we can just get actor location.
38
00:02:17,720 --> 00:02:24,110
Of the damage caused, and this gives us a proper look at rotation from ourselves to whoever.
39
00:02:24,260 --> 00:02:25,580
Caused the damage to us.
40
00:02:25,580 --> 00:02:27,800
And this should also work with projectiles and everything.
41
00:02:27,800 --> 00:02:32,450
So if we get hit by a projectile that is on the right side, it can also knock us to the left side.
42
00:02:32,900 --> 00:02:36,140
And the rotation we get here is actually kind of hard to use.
43
00:02:36,140 --> 00:02:41,330
We don't really want to use the rotation, we only care about the forward vector so we can get forward
44
00:02:41,330 --> 00:02:41,720
vector.
45
00:02:41,720 --> 00:02:44,450
And this gives us a directional vector.
46
00:02:44,450 --> 00:02:50,690
And this makes it very easy to tell if we are looking to the right or to the left in order to find who
47
00:02:50,690 --> 00:02:53,870
caused damage to us, and we can just print string here.
48
00:02:55,920 --> 00:02:59,670
Like this and print the vector out.
49
00:02:59,670 --> 00:03:01,140
And let's try this out now.
50
00:03:03,060 --> 00:03:03,900
I'm on the left side.
51
00:03:03,900 --> 00:03:07,980
I walk into the crab and you can see the X is positive.
52
00:03:07,980 --> 00:03:10,440
It said 0.98, right?
53
00:03:10,440 --> 00:03:11,490
It's positive.
54
00:03:11,850 --> 00:03:14,550
We don't really care about the Y and the Z here.
55
00:03:14,910 --> 00:03:18,300
And if I go on the other side you can see that it is negative.
56
00:03:18,300 --> 00:03:20,220
It is -0.9.
57
00:03:20,220 --> 00:03:20,760
Right.
58
00:03:20,760 --> 00:03:21,960
And here it is plus right.
59
00:03:21,960 --> 00:03:23,910
So we just care about the plus and the minus.
60
00:03:23,910 --> 00:03:25,980
Again we don't really care about the value here.
61
00:03:26,070 --> 00:03:28,200
And we only care about the x.
62
00:03:28,200 --> 00:03:29,580
So we can get rid of the printstring.
63
00:03:29,580 --> 00:03:32,520
Now we can split the vector split the struct pin.
64
00:03:32,520 --> 00:03:34,350
And we only care about the x.
65
00:03:34,350 --> 00:03:36,540
And well what do we have to check for.
66
00:03:36,540 --> 00:03:42,810
So we want to throw away this 0.98 and make it a round plus one or a round minus one.
67
00:03:42,810 --> 00:03:44,820
So here we can just select.
68
00:03:45,590 --> 00:03:46,400
Float.
69
00:03:47,460 --> 00:03:48,390
Like this.
70
00:03:50,020 --> 00:03:56,890
And we simply check for if this is bigger or greater than zero and put this in here.
71
00:03:56,890 --> 00:04:01,270
And if this is greater than zero, we pick a and A, then should just be a one.
72
00:04:01,270 --> 00:04:04,630
And if this is not the case, then it should be a zero.
73
00:04:04,630 --> 00:04:10,390
And this is just an easy way for us to kind of shortcut this and get rid of the 0.98 and get a round
74
00:04:10,390 --> 00:04:11,860
1 or -1.
75
00:04:11,860 --> 00:04:15,310
And this is going to be our directional vector.
76
00:04:15,310 --> 00:04:21,399
And now that we have this direction we want to multiply this by the value we want to use here.
77
00:04:21,399 --> 00:04:21,579
Right.
78
00:04:21,579 --> 00:04:23,620
So we can split the struct pin here.
79
00:04:23,620 --> 00:04:24,940
So we can put in a value here.
80
00:04:24,940 --> 00:04:26,590
And we want to multiply.
81
00:04:27,220 --> 00:04:32,440
Multiply and let's just say also 2000, 2000 and yeah.
82
00:04:32,470 --> 00:04:36,910
Now we have the direction which is either to the right side or the left side, and multiply this by
83
00:04:36,910 --> 00:04:39,160
our horizontal launch velocity.
84
00:04:39,160 --> 00:04:40,420
And we can just connect this here.
85
00:04:40,450 --> 00:04:40,990
Now.
86
00:04:41,940 --> 00:04:43,290
And let's try this out.
87
00:04:44,170 --> 00:04:46,510
And it actually doesn't look that great.
88
00:04:46,510 --> 00:04:50,800
Like you can see we get nudged over to the side a little bit if you pay close attention.
89
00:04:50,800 --> 00:04:55,840
But the reason why this is happening is actually related to our jump setting.
90
00:04:55,840 --> 00:05:02,560
So on the character movement component, if we look for our lateral jump friction, this is what we
91
00:05:02,560 --> 00:05:05,500
set up so we can get a lot more control in the air.
92
00:05:05,500 --> 00:05:09,310
However, this actually also prevents us from building up momentum in the air.
93
00:05:09,310 --> 00:05:14,620
So this makes the launch character node not work properly and we need to work around that a little bit.
94
00:05:14,620 --> 00:05:18,970
So before we launch the character we just want to set falling.
95
00:05:18,970 --> 00:05:24,100
Actually we have to drag off this character movement component and just look for lateral.
96
00:05:24,100 --> 00:05:26,890
So set falling lateral friction.
97
00:05:28,610 --> 00:05:29,870
Connect this year.
98
00:05:30,630 --> 00:05:34,020
And we just want to set this to zero before we launch the character.
99
00:05:34,020 --> 00:05:36,810
And then after we're done, we go out of our stunned state.
100
00:05:36,810 --> 00:05:40,200
We later set this back to the value that we need when we jump.
101
00:05:40,560 --> 00:05:41,910
Now let's try this again.
102
00:05:41,910 --> 00:05:44,220
And now the result should be quite different.
103
00:05:44,220 --> 00:05:48,630
And you can see we walk into the character, we get tossed to the right, we walk into the character,
104
00:05:48,630 --> 00:05:49,770
we get tossed to the left.
105
00:05:49,770 --> 00:05:56,490
So actually the direction is inverted right now, because what we are doing here is we just take the
106
00:05:56,490 --> 00:06:02,430
direction we already have and we just round it to a one or a minus one, but we actually want to invert
107
00:06:02,430 --> 00:06:02,850
this.
108
00:06:02,850 --> 00:06:05,640
So I can just use pick a minus one.
109
00:06:05,640 --> 00:06:07,620
And for B use one.
110
00:06:07,860 --> 00:06:09,120
And this turns it around.
111
00:06:09,120 --> 00:06:11,790
So we actually get knocked back not forward.
112
00:06:11,910 --> 00:06:14,880
Let's try this out like this I get knocked back.
113
00:06:14,880 --> 00:06:15,870
It's all good.
114
00:06:15,990 --> 00:06:18,210
And from this side also get knocked back.
115
00:06:18,210 --> 00:06:18,750
It's all good.
116
00:06:18,750 --> 00:06:20,220
So this is the knockback we want.
117
00:06:20,220 --> 00:06:22,260
Of course it's a little bit too high, too far.
118
00:06:22,260 --> 00:06:24,900
We don't want to be knocked back quite that far.
119
00:06:24,900 --> 00:06:27,810
And I just think this using this pick A is a simple solution.
120
00:06:27,810 --> 00:06:33,720
But you could of course also like just round this and then multiply it by 1 or -1.
121
00:06:33,720 --> 00:06:35,640
So there's there's other ways you could do this.
122
00:06:35,640 --> 00:06:39,390
But I think this is a simple easy solution that I want to use.
123
00:06:39,870 --> 00:06:42,360
And now of course we want to turn this into a variable.
124
00:06:42,360 --> 00:06:49,530
So drag off here promote the variable and just call it knockback power horror for horizontal.
125
00:06:50,550 --> 00:06:57,780
And compile and save, and I played around with these values a little bit to find a good value and compound
126
00:06:57,780 --> 00:06:58,050
save.
127
00:06:58,050 --> 00:07:00,270
And then we have the default value.
128
00:07:00,270 --> 00:07:03,150
And I want to use 1200 here.
129
00:07:03,670 --> 00:07:07,780
And we want to do the same thing for our vertical velocity.
130
00:07:07,780 --> 00:07:14,920
So here also drag off and call it knock back power vert for vertical.
131
00:07:15,070 --> 00:07:17,650
And here we can compile and save.
132
00:07:20,080 --> 00:07:22,840
And I want to use only 800 here.
133
00:07:22,840 --> 00:07:25,600
And again, I just found this value through trial and error.
134
00:07:25,600 --> 00:07:29,860
But you can use a different value if you want to and just compile and save.
135
00:07:30,480 --> 00:07:32,400
And let's try this again.
136
00:07:32,790 --> 00:07:34,740
And I think this is a lot more reasonable.
137
00:07:34,740 --> 00:07:39,930
But one more thing is that we can actually kind of like steer against it right away, which is something
138
00:07:39,930 --> 00:07:40,620
we don't want.
139
00:07:40,620 --> 00:07:46,980
And to make sure the launch is always the same, we want to overwrite the x and Y and also overwrite
140
00:07:46,980 --> 00:07:52,350
the Z, because otherwise this launch will get weaker or stronger depending on what momentum you already
141
00:07:52,350 --> 00:07:52,770
have.
142
00:07:52,770 --> 00:07:56,430
And we always want this to be the same so we can combine save.
143
00:07:56,430 --> 00:07:58,050
And now try this.
144
00:07:58,050 --> 00:08:00,660
And yeah so this is a lot more consistent now.
145
00:08:00,660 --> 00:08:02,970
Like it doesn't matter what momentum we have at first.
146
00:08:02,970 --> 00:08:05,520
It always is the same direction.
147
00:08:05,520 --> 00:08:06,900
It's always the same height.
148
00:08:07,380 --> 00:08:11,670
But since we changed the lateral falling friction like now we have control over our jump.
149
00:08:11,670 --> 00:08:12,120
It's all good.
150
00:08:12,120 --> 00:08:18,090
But we take damage once and the value is completely different now, so we cannot control our jump anymore.
151
00:08:18,090 --> 00:08:25,110
We lost our unique jump, so after the invincibility duration is over, we actually want to set this
152
00:08:25,110 --> 00:08:25,710
back.
153
00:08:25,710 --> 00:08:27,870
So we have to launch character right.
154
00:08:27,870 --> 00:08:29,880
And we want to have a delay here.
155
00:08:29,880 --> 00:08:33,030
So we can have a retrigger double delay.
156
00:08:33,539 --> 00:08:37,140
And this should be the same as our invincibility duration.
157
00:08:37,140 --> 00:08:41,909
So we can just reuse this because it should be the same amount of time we can compile and save.
158
00:08:41,909 --> 00:08:46,020
And here we want to just set back our following lateral friction.
159
00:08:46,020 --> 00:08:51,330
Copy and paste this here to the same value we already have in the character movement component.
160
00:08:51,330 --> 00:08:54,720
So here we can just look for lateral and it's 50.
161
00:08:56,320 --> 00:08:59,980
So you can just type in 50 here and this is going to work.
162
00:09:01,120 --> 00:09:02,050
Like this.
163
00:09:02,950 --> 00:09:05,320
And right now we have control again over the jump.
164
00:09:08,100 --> 00:09:14,040
But one problem with this approach is that what if later on we want to tweak this value here, then
165
00:09:14,040 --> 00:09:15,660
we might forget about this value.
166
00:09:15,660 --> 00:09:19,560
And then the values are different and we run into issues and bugs like that.
167
00:09:19,560 --> 00:09:26,700
So a better way is to not just hard code the 50in here, but what we want to do is to take this value
168
00:09:26,700 --> 00:09:31,410
on begin play, save it in a variable, and then just apply the default value back here.
169
00:09:31,980 --> 00:09:35,190
So on begin play we just want to go up here.
170
00:09:35,190 --> 00:09:37,470
It should probably be here on Begin Play right.
171
00:09:37,470 --> 00:09:39,570
But there's already a lot of stuff going on here.
172
00:09:39,570 --> 00:09:42,870
We could just daisy chain uh on here.
173
00:09:42,870 --> 00:09:45,720
But it's it's a different kind of logic we want to use.
174
00:09:45,720 --> 00:09:48,540
So we can just let this stand by its own.
175
00:09:48,540 --> 00:09:50,970
And we can use a sequence.
176
00:09:50,970 --> 00:09:53,550
And a sequence node is again, just for flow control.
177
00:09:53,550 --> 00:09:58,260
It basically just executes this first and the line to the next line.
178
00:09:58,260 --> 00:10:00,330
The next line you can just add more and more lines.
179
00:10:00,330 --> 00:10:04,260
And sometimes if you use delays and other things you have to be careful with this.
180
00:10:04,260 --> 00:10:08,520
But if the order doesn't really matter, you can use this without any issues.
181
00:10:08,520 --> 00:10:10,890
And in this case the order doesn't matter.
182
00:10:10,890 --> 00:10:17,340
So here what we want to do is we get the character movement component and get lateral falling friction.
183
00:10:18,820 --> 00:10:21,220
And here we can just promote this to a variable.
184
00:10:21,220 --> 00:10:25,150
So just drag off, promote the variable and just call the base.
185
00:10:25,920 --> 00:10:29,610
Lateral friction like this.
186
00:10:30,280 --> 00:10:31,480
And connect it to the.
187
00:10:31,510 --> 00:10:34,090
Then double click to create a reroute.
188
00:10:35,260 --> 00:10:37,540
And we can then use this value instead.
189
00:10:37,540 --> 00:10:45,370
So down here where we reset our jumping the ladder following prediction instead of writing 50, we just
190
00:10:45,370 --> 00:10:48,970
get the the base lateral falling friction.
191
00:10:48,970 --> 00:10:53,800
And now if we just update it here in the character movement, we're like oh, maybe I want to change
192
00:10:53,800 --> 00:10:54,250
the value.
193
00:10:54,250 --> 00:10:58,870
Just change it here only and you don't have to worry about this because we're just going to reuse the
194
00:10:58,870 --> 00:11:00,430
same value on Beginplay.
195
00:11:00,430 --> 00:11:02,350
And this solves this kind of issue.
196
00:11:02,350 --> 00:11:04,390
And this is a pattern we're going to use even more.
197
00:11:04,390 --> 00:11:06,790
And it's a very important pattern you should remember.
198
00:11:07,670 --> 00:11:11,150
We want to now implement the standard getting hit animation.
199
00:11:11,300 --> 00:11:14,930
To do that, we want to open up the papers the animation blueprint.
200
00:11:14,930 --> 00:11:19,550
So in here under blueprints characters players, we have the ABP player.
201
00:11:19,550 --> 00:11:25,340
And before in the as the animation sequence we already registered our getting hurt animation.
202
00:11:25,340 --> 00:11:25,580
Right.
203
00:11:25,580 --> 00:11:28,430
So this one we are going to use this animation.
204
00:11:28,430 --> 00:11:29,990
So just open up the ABP.
205
00:11:30,020 --> 00:11:34,610
We can close the as and we want to create a new state.
206
00:11:34,610 --> 00:11:38,450
If you don't see this just click on Anim Graph and go to locomotion.
207
00:11:38,450 --> 00:11:40,670
We want to create a new stunt state here.
208
00:11:40,670 --> 00:11:42,440
So like we have the run idle fall.
209
00:11:42,440 --> 00:11:47,870
We also want to right click and create an animation state and just call it done.
210
00:11:49,680 --> 00:11:50,130
In here.
211
00:11:50,130 --> 00:11:51,180
We want to double click it.
212
00:11:51,180 --> 00:11:53,250
And here play hurt.
213
00:11:53,550 --> 00:11:55,830
So this is the hurt animation we want to play.
214
00:11:56,560 --> 00:12:02,320
And now one problem we have here is that, well, we can pretty much get hurt in any situation, right?
215
00:12:02,320 --> 00:12:05,230
We can get hurt while being idle, running, falling, jump, rise.
216
00:12:05,230 --> 00:12:07,120
And we would then have to connect.
217
00:12:07,120 --> 00:12:08,470
And please don't do this.
218
00:12:08,470 --> 00:12:09,700
This is just for demonstration.
219
00:12:09,700 --> 00:12:15,280
We would have to connect this and we would have to connect this and all of these.
220
00:12:15,280 --> 00:12:19,600
And uh, also put in the conditions and things get very nasty.
221
00:12:19,600 --> 00:12:22,150
And we also have to go back from the stun back to the idle.
222
00:12:22,150 --> 00:12:25,300
And I'm just gonna hit control Z to go back on this.
223
00:12:25,810 --> 00:12:27,670
And this is not a great way.
224
00:12:27,670 --> 00:12:28,660
It's manageable.
225
00:12:28,660 --> 00:12:32,260
It is doable, but your entire animation graph just becomes very complicated.
226
00:12:32,260 --> 00:12:37,090
And to solve this problem, Paper XRD implemented something called animation Jumps.
227
00:12:37,630 --> 00:12:42,820
And we can create a jump by right clicking and adding a jump here.
228
00:12:42,820 --> 00:12:46,360
And I'm just going to call this jump stun.
229
00:12:46,360 --> 00:12:49,840
And this name is very important because we're going to have to reuse this name.
230
00:12:49,840 --> 00:12:54,730
So make sure it's an easy to remember name that you're not going to have any issues typing out.
231
00:12:54,730 --> 00:12:57,580
And then we just connect to the stun from the jump.
232
00:12:57,580 --> 00:12:57,790
Stun.
233
00:12:57,790 --> 00:12:59,260
There's no condition, nothing.
234
00:12:59,260 --> 00:13:02,080
We can call this jump stun from the blueprint.
235
00:13:02,080 --> 00:13:05,080
So we can basically shortcut into this animation.
236
00:13:05,500 --> 00:13:13,180
So now back in the player before we call the Retrigger delay here where we take damage, right?
237
00:13:13,180 --> 00:13:14,500
We take any damage.
238
00:13:15,120 --> 00:13:17,550
And we can just do a reroute node here.
239
00:13:17,670 --> 00:13:18,180
Um, right.
240
00:13:18,180 --> 00:13:19,620
So we set the lateral friction.
241
00:13:19,620 --> 00:13:20,700
We launched the character.
242
00:13:20,700 --> 00:13:28,080
And before we reset here we want to call this, uh, hurt animation the stun state.
243
00:13:28,080 --> 00:13:32,430
So here we can then simply grab the animation component.
244
00:13:32,430 --> 00:13:32,910
Right.
245
00:13:32,910 --> 00:13:37,650
Because this animation component is basically controlling this animation blueprint.
246
00:13:37,650 --> 00:13:39,750
And this is something we get from paper XDD.
247
00:13:39,870 --> 00:13:42,270
And here we can get anim instance.
248
00:13:42,270 --> 00:13:46,350
And this just gives you the currently active instance of this.
249
00:13:46,350 --> 00:13:49,470
And here we can call jump to node.
250
00:13:50,020 --> 00:13:51,520
Jump to node.
251
00:13:53,670 --> 00:13:57,390
And this simply has a jump name and a state machine name.
252
00:13:57,390 --> 00:13:59,730
So the jump name is this jump stun.
253
00:13:59,730 --> 00:14:05,580
So the best way is to just really just copy it ctrl C to copy it and ctrl V to paste.
254
00:14:05,580 --> 00:14:07,170
So you don't have any typos.
255
00:14:07,170 --> 00:14:09,120
You can be sure you didn't mistype anything.
256
00:14:09,120 --> 00:14:13,770
And the state machine name, we actually don't have to write because what we have the state machine,
257
00:14:13,770 --> 00:14:15,000
it's called locomotion.
258
00:14:15,000 --> 00:14:16,710
But we only have one state machine.
259
00:14:16,710 --> 00:14:19,050
It's going to know that we want to use this one.
260
00:14:19,050 --> 00:14:24,210
If you have multiple state machines and multiple jumps that have the same name, then you should write
261
00:14:24,210 --> 00:14:25,260
the state machine name.
262
00:14:25,260 --> 00:14:29,100
But for our case, we don't have to and we can just create some more space here.
263
00:14:29,670 --> 00:14:30,780
Drag this over.
264
00:14:31,780 --> 00:14:32,860
And put this here.
265
00:14:33,760 --> 00:14:39,010
And this is just gonna tell our animation blueprint to just instantly jump to this animation.
266
00:14:40,000 --> 00:14:40,870
And less than.
267
00:14:40,870 --> 00:14:41,800
Try this out.
268
00:14:41,800 --> 00:14:45,130
So compile and save and start out I take damage.
269
00:14:45,820 --> 00:14:47,710
And you can see the animation is playing.
270
00:14:47,710 --> 00:14:48,670
This is working.
271
00:14:48,670 --> 00:14:51,910
The jump is correct, but we are not stuck in this animation.
272
00:14:51,910 --> 00:14:57,040
And also the animation is replaying again and again, but we actually just want to have the animation
273
00:14:57,040 --> 00:15:03,490
play out one time and then be stuck on the last frame, because this is a kind of common for these animations.
274
00:15:03,850 --> 00:15:08,740
So the first thing we can do is in the app player, we go back to locomotion to our stun.
275
00:15:08,740 --> 00:15:14,050
And here if we select the play hurt we can simply set it to loop animation.
276
00:15:14,050 --> 00:15:15,490
Not false right?
277
00:15:15,490 --> 00:15:17,200
Don't loop the animation.
278
00:15:17,320 --> 00:15:18,520
And this.
279
00:15:19,180 --> 00:15:19,570
Right.
280
00:15:19,570 --> 00:15:21,670
You get the nice one frame.
281
00:15:21,670 --> 00:15:27,040
So we play this frame once and then we just get stuck in this animation, which I believe is a better
282
00:15:27,040 --> 00:15:30,940
way of doing this, instead of just replaying the animation again because it looks really weird.
283
00:15:30,940 --> 00:15:34,330
It is not made to be used with looping.
284
00:15:35,650 --> 00:15:36,220
And next.
285
00:15:36,220 --> 00:15:41,500
We just want to make sure that we can go back out of the heard state, out of the stun state, go back
286
00:15:41,500 --> 00:15:46,090
to the idle or whatever we are doing so we can just drag off here and go back to the idle.
287
00:15:47,430 --> 00:15:49,890
And we just want to go back to the idol.
288
00:15:49,890 --> 00:15:53,550
If the stun is done playing the animation, we want the animation to play out.
289
00:15:53,550 --> 00:15:57,480
Once it's not looping, play it out once and then we go back to the idle.
290
00:15:58,450 --> 00:16:01,150
And how can we check for the length of an animation?
291
00:16:01,180 --> 00:16:07,270
Well, we can just go in here and we can just look for stun actually for hurt, because that's the name
292
00:16:07,270 --> 00:16:10,690
and we can look for time remaining hurt.
293
00:16:10,690 --> 00:16:14,770
So this will tell us if the animation is playing, how much time is left.
294
00:16:14,770 --> 00:16:18,400
And here we simply have to check for smaller equal than zero.
295
00:16:18,980 --> 00:16:23,540
So it's just going to play once and it's going to transition us back into the idle state.
296
00:16:23,540 --> 00:16:24,740
So compile and save.
297
00:16:24,740 --> 00:16:25,670
Like this.
298
00:16:26,830 --> 00:16:30,640
And it plays out once you can see it play out once and then we just go back to the idle.
299
00:16:31,520 --> 00:16:36,620
And even if we go back to the running because there's actually a shortcut built into this animation
300
00:16:36,620 --> 00:16:41,960
blueprint, to my understanding, if we try to go from stand to idle, it will then also try to go,
301
00:16:41,960 --> 00:16:47,210
to run, to fall, to jump right in the same frame so we don't have to worry about, like going from
302
00:16:47,210 --> 00:16:49,370
stand to run or fall or jump, right?
303
00:16:49,400 --> 00:16:54,200
It will then automatically know if it can transition from idle into the other ones during the same frame.
304
00:16:54,200 --> 00:16:59,390
One problem we still have, though, is that if we go here and even while we're stunt, we can still
305
00:16:59,390 --> 00:17:03,410
shoot while we are being stunt and being knocked back, which is not ideal.
306
00:17:03,410 --> 00:17:08,480
To do this, we need to go to the DB player and create a new variable and just call.
307
00:17:08,480 --> 00:17:12,170
It is stunt and this should be a boolean.
308
00:17:12,170 --> 00:17:13,099
So this is fine.
309
00:17:13,099 --> 00:17:14,329
So what do we do here.
310
00:17:14,329 --> 00:17:16,460
So again like we we get launched.
311
00:17:16,460 --> 00:17:19,010
We play the hurt and stun animation.
312
00:17:19,010 --> 00:17:23,510
So here we just want to set this stunt to true.
313
00:17:24,079 --> 00:17:25,790
And open up some space here.
314
00:17:28,640 --> 00:17:29,540
Like this.
315
00:17:29,780 --> 00:17:30,920
Set it to true.
316
00:17:32,530 --> 00:17:37,210
And then we want to make sure that if we are stunned, we are not allowed to shoot.
317
00:17:37,450 --> 00:17:40,510
So we can go to our IA shoot.
318
00:17:40,510 --> 00:17:41,560
Where is it?
319
00:17:41,560 --> 00:17:42,040
Here.
320
00:17:42,040 --> 00:17:43,210
IA shoot right.
321
00:17:43,210 --> 00:17:47,410
And we can then just drag this off to the side to create some more space.
322
00:17:48,980 --> 00:17:50,540
And add another branch here.
323
00:17:50,570 --> 00:17:50,840
Right.
324
00:17:50,840 --> 00:17:52,370
So started branch.
325
00:17:54,020 --> 00:17:54,830
Like this.
326
00:17:56,530 --> 00:17:58,180
And we can get the stand.
327
00:17:58,760 --> 00:18:01,130
And we don't want to be able to do this if we are stunned.
328
00:18:01,160 --> 00:18:03,350
We want to be able to do this if we are not stunned.
329
00:18:03,350 --> 00:18:05,090
So we can get not boolean.
330
00:18:06,220 --> 00:18:07,120
And connect this here.
331
00:18:07,120 --> 00:18:10,210
So if we are not stunned, we are allowed to shoot.
332
00:18:11,140 --> 00:18:12,700
To clean this up a little bit.
333
00:18:12,820 --> 00:18:15,910
And we also want to use the same pattern for our moving.
334
00:18:15,910 --> 00:18:16,300
Right.
335
00:18:16,300 --> 00:18:19,720
So we also don't want to be allowed to move while we are stunned.
336
00:18:19,720 --> 00:18:22,570
So we can just use the I move right on triggered.
337
00:18:23,300 --> 00:18:24,110
Going here.
338
00:18:25,300 --> 00:18:26,440
And on through.
339
00:18:28,120 --> 00:18:31,240
And now we just want to reroute this a little bit here.
340
00:18:32,840 --> 00:18:35,150
Can actually double click here to create a new node.
341
00:18:35,150 --> 00:18:39,350
Put it in here, select all, press Q, and now this looks a lot better.
342
00:18:39,350 --> 00:18:40,790
So let's compile and save.
343
00:18:41,580 --> 00:18:43,800
And here I get stunned.
344
00:18:43,830 --> 00:18:45,870
I try to shoot, I cannot shoot.
345
00:18:46,170 --> 00:18:50,280
And now I also cannot move anymore because we need to reset the stun state.
346
00:18:50,280 --> 00:18:51,480
But actually, yeah, it's working.
347
00:18:51,480 --> 00:18:55,740
I can move, I can shoot, I get stunned, I cannot shoot, I cannot move, but now we just need to
348
00:18:55,740 --> 00:18:57,360
take care of resetting this.
349
00:18:57,360 --> 00:19:01,110
So back in the player we want to go back down where we take damage.
350
00:19:01,110 --> 00:19:01,350
Right.
351
00:19:01,350 --> 00:19:05,550
Take any damage here we set is stunned to true.
352
00:19:05,550 --> 00:19:09,120
And here we then want to remove the stun state.
353
00:19:09,890 --> 00:19:14,030
And we don't want to be stunned for the entire duration of the invincibility, because this is too long.
354
00:19:14,030 --> 00:19:19,010
And also the invincibility should allow the player to reposition and get in a better position.
355
00:19:19,010 --> 00:19:23,420
So we actually want to use a sequence here again, which we did also on Beginplay.
356
00:19:23,420 --> 00:19:29,720
So we do this as a separate thing, and then we can also execute another logic after this that is unrelated.
357
00:19:30,140 --> 00:19:32,840
So here we can also use a retrigger delay.
358
00:19:33,570 --> 00:19:39,780
But here we want to then set a stand back to false.
359
00:19:41,560 --> 00:19:46,840
And for now, let's just try out 0.4, maybe like this and compile and save.
360
00:19:47,900 --> 00:19:49,010
And go in here.
361
00:19:50,030 --> 00:19:51,800
Right, I cannot shoot, it's fine.
362
00:19:51,800 --> 00:19:53,990
But then I wait a little bit and I can shoot again.
363
00:19:53,990 --> 00:20:00,140
After 0.4, we properly touch the ground and we can shoot again, so this feels like the right value.
364
00:20:00,140 --> 00:20:06,020
So let's turn this into a variable and promote the variable stun duration.
365
00:20:09,370 --> 00:20:11,320
And this is how it works.
366
00:20:11,320 --> 00:20:14,170
So there is one thing we could improve upon.
367
00:20:14,170 --> 00:20:15,820
We can just compile and save that.
368
00:20:15,820 --> 00:20:22,900
We are now kind of manually matching the duration of the stun duration, and we are matching it to the
369
00:20:22,900 --> 00:20:25,840
duration of the actual animation itself.
370
00:20:26,320 --> 00:20:31,090
So instead of just using the animation length, I think it actually is better if we just get the owning
371
00:20:31,090 --> 00:20:37,510
player and we look for is stunned, get is stunned, and not boolean.
372
00:20:39,190 --> 00:20:40,720
Not bullying like this.
373
00:20:41,110 --> 00:20:44,950
So we transition back into the idle animation if we're not stunned anymore.
374
00:20:44,980 --> 00:20:50,710
So there could be no disconnect between our instance state in the player blueprint and the actual animation
375
00:20:50,710 --> 00:20:51,310
length.
376
00:20:52,850 --> 00:20:54,320
So now if we compile save.
377
00:20:54,320 --> 00:20:55,580
Let's try this out.
378
00:21:00,360 --> 00:21:00,810
Right.
379
00:21:00,810 --> 00:21:01,680
So this is better.
380
00:21:01,680 --> 00:21:02,880
Now these are synced.
381
00:21:03,650 --> 00:21:05,570
And this animation is a little bit longer.
382
00:21:05,570 --> 00:21:10,880
And now if we want to adjust the stand duration for gameplay purposes, we don't have to worry about
383
00:21:10,880 --> 00:21:13,190
the animation because it's going to follow along.
384
00:21:13,190 --> 00:21:13,610
Right?
385
00:21:13,610 --> 00:21:19,250
So we could, for example, just put stand duration to two seconds just to show how this works.
386
00:21:19,250 --> 00:21:19,760
Right?
387
00:21:19,760 --> 00:21:23,510
And now the animation keeps on playing as long as the stand duration.
388
00:21:23,510 --> 00:21:26,270
And this is just a better solution in this case.
389
00:21:26,270 --> 00:21:30,080
But let's set it back to 0.4 which is a nice value.
390
00:21:30,080 --> 00:21:35,630
But this gives us a lot more flexibility instead of just waiting for the animation to play out.
391
00:21:36,840 --> 00:21:38,790
And congratulations if you made it this far.
392
00:21:38,790 --> 00:21:44,250
This was a bit of a complicated lesson, but a stand system like this and invincibility are things you're
393
00:21:44,250 --> 00:21:46,050
going to use in pretty much all of your games.
394
00:21:46,050 --> 00:21:51,000
So I hope you got a basic understanding of how these things work, and can also replicate this in your
395
00:21:51,000 --> 00:21:52,650
own games with some more practice.
35983
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.