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,820
In this video, we're going to implement something very exciting, which is the character's main projectile.
2
00:00:04,820 --> 00:00:07,130
In the end, we're going to have different types of projectiles.
3
00:00:07,130 --> 00:00:10,280
So we have to think ahead a little bit and we're going to set up the projectile.
4
00:00:10,280 --> 00:00:15,920
Keeping that in mind, in this video, in the lesson where we imported our assets, we also imported
5
00:00:15,920 --> 00:00:19,790
the Flipbooks for our shots so we can go to paper assets FPS.
6
00:00:20,330 --> 00:00:24,800
And here we have the player shot which is the regular player shot.
7
00:00:24,800 --> 00:00:28,370
We have the player shot charge which is a charge shot.
8
00:00:28,370 --> 00:00:33,710
And we have the player shot hit, which is the animation that plays if we hit a wall or an enemy, just
9
00:00:33,710 --> 00:00:35,750
to show that the projectile explodes.
10
00:00:36,080 --> 00:00:38,420
We didn't set up the frames per second for this.
11
00:00:38,420 --> 00:00:40,550
So let's just take care of this right now.
12
00:00:41,080 --> 00:00:43,150
Let's start on the right side with player shot.
13
00:00:43,150 --> 00:00:43,780
Hit.
14
00:00:43,900 --> 00:00:45,430
Open up the flipbook.
15
00:00:45,430 --> 00:00:46,840
And this looks kind of fine.
16
00:00:46,840 --> 00:00:47,950
It should just be an explosion.
17
00:00:47,950 --> 00:00:49,720
But I want to make it a little bit slower.
18
00:00:49,720 --> 00:00:53,410
So 13 fps is the value that I like.
19
00:00:53,990 --> 00:00:56,210
And we can skip this and then go back to.
20
00:00:57,680 --> 00:00:59,720
Next up is the player shot charge.
21
00:00:59,720 --> 00:01:02,480
Just open this up and it looks a little bit fast.
22
00:01:02,480 --> 00:01:03,590
So maybe this one as well.
23
00:01:03,590 --> 00:01:05,000
We can go to 13.
24
00:01:05,000 --> 00:01:07,790
Make it a little bit slower and a little bit smoother.
25
00:01:08,630 --> 00:01:10,400
Then on to the next.
26
00:01:10,430 --> 00:01:11,720
The player shot.
27
00:01:12,310 --> 00:01:14,740
Which is a regular shot that we will use most.
28
00:01:14,740 --> 00:01:19,750
And again, this one looks very fast, so this 1st May be around nine fps.
29
00:01:19,780 --> 00:01:22,960
I think you can see switching between the frames better.
30
00:01:22,960 --> 00:01:24,190
It looks more interesting.
31
00:01:26,040 --> 00:01:28,710
And onto the next one, which is the fireball.
32
00:01:28,710 --> 00:01:33,120
This is the projectile that the lizard will use, and it is the same as the player.
33
00:01:33,120 --> 00:01:36,960
So we can just set it to nine as well to give it a uniform look.
34
00:01:38,840 --> 00:01:41,210
And lastly we have the explosion.
35
00:01:41,210 --> 00:01:42,530
This is what we're going to play.
36
00:01:42,530 --> 00:01:43,910
If an enemy dies.
37
00:01:44,390 --> 00:01:46,310
And this one again it looks a little bit fast.
38
00:01:46,310 --> 00:01:48,530
So again here we can go to 13.
39
00:01:48,530 --> 00:01:49,880
It should be kind of snappy.
40
00:01:49,880 --> 00:01:52,670
And I think this looks about right and safe.
41
00:01:53,170 --> 00:01:57,220
Okay, so this is all we need for setting up the settings on our flipbooks.
42
00:01:57,610 --> 00:02:00,340
Now let's get into making the actual projectile.
43
00:02:00,340 --> 00:02:05,530
And like I said before, we want to think ahead with this and make sure that we create a system that
44
00:02:05,530 --> 00:02:10,300
allows for multiple projectile types so we can reuse functions and variables without having to make
45
00:02:10,300 --> 00:02:12,280
every single projectile from scratch.
46
00:02:12,400 --> 00:02:17,020
And again, our friend inheritance, which we already used for the character, the player and the enemies
47
00:02:17,020 --> 00:02:22,630
comes in handy here because again, this allows us to set some basic variables, some basic functions
48
00:02:22,630 --> 00:02:29,350
on the projectile base and pass everything down to the player projectiles to the enemy projectiles,
49
00:02:29,350 --> 00:02:34,150
and then also have different types of player projectiles without having to code everything from scratch
50
00:02:34,150 --> 00:02:35,140
every single time.
51
00:02:35,140 --> 00:02:39,910
And again, this is something that is a little bit hard to plan out if you're a beginner, but it is
52
00:02:39,910 --> 00:02:42,580
very important and you're going to get used to this over time.
53
00:02:42,580 --> 00:02:48,670
First, we want to create the BP projectile base, and this simply inherits from the base actor, which
54
00:02:48,670 --> 00:02:51,580
is the simplest type of object that can be placed in the world.
55
00:02:51,580 --> 00:02:55,300
And we want to share parameters settings like the flipbook settings and things like that.
56
00:02:55,300 --> 00:03:00,610
Downward, the base will also have collisions and events because we need to understand what our projectile
57
00:03:00,610 --> 00:03:03,730
hits something and then have the projectile explode, apply damage.
58
00:03:03,730 --> 00:03:06,730
And this is the same for all of our different projectiles.
59
00:03:06,730 --> 00:03:09,280
We're going to have a flipbook in the projectile.
60
00:03:09,280 --> 00:03:12,670
And most importantly we're going to have the projectile movement component.
61
00:03:12,670 --> 00:03:17,050
And this is kind of similar to the character movement component we had with the character that handles
62
00:03:17,050 --> 00:03:17,650
character movement.
63
00:03:17,650 --> 00:03:20,080
But this is specifically for projectiles.
64
00:03:20,080 --> 00:03:23,620
So we don't just have to go into the actor and code all of this from scratch.
65
00:03:23,620 --> 00:03:28,060
The projectile movement already gives us a system that works, and we can just reuse that from Unreal
66
00:03:28,060 --> 00:03:28,690
Engine.
67
00:03:28,690 --> 00:03:33,340
Again, we also want to have a variable for faction, so we can make sure that a projectile that an
68
00:03:33,340 --> 00:03:36,850
enemy shoots doesn't hurt other enemies, but only hurts the player.
69
00:03:36,850 --> 00:03:42,130
We're also going to have a variable for projectile damage, and we're going to have a visual effect
70
00:03:42,130 --> 00:03:43,990
when the projectile hits the wall and explodes.
71
00:03:43,990 --> 00:03:45,760
The one we looked at before the flipbook.
72
00:03:45,760 --> 00:03:47,950
And later on we're also going to add a sound effect.
73
00:03:47,950 --> 00:03:51,460
And these are all things we're going to add over time as we need them.
74
00:03:51,460 --> 00:03:55,120
And we're then going to split into two different projectile types.
75
00:03:55,120 --> 00:03:56,860
So again these are only parents.
76
00:03:56,860 --> 00:03:58,120
That's why I called them base.
77
00:03:58,120 --> 00:03:59,920
We're not going to actually use them in the game.
78
00:03:59,920 --> 00:04:02,860
These are just going to be used to manage our different children.
79
00:04:02,860 --> 00:04:10,000
So in the player projectile things that are unique to the player that the enemy doesn't need is a system
80
00:04:10,000 --> 00:04:12,970
that makes the projectiles disappear when leaving the screen.
81
00:04:13,060 --> 00:04:18,850
In these Mega man type of games, usually you can only have three active projectiles at a time, so
82
00:04:18,850 --> 00:04:20,860
you cannot keep on mashing the shoot button.
83
00:04:20,860 --> 00:04:24,610
But the closer you are to the edge of the screen, the faster you can actually shoot.
84
00:04:24,610 --> 00:04:27,430
So this system is nice for managing risk and reward.
85
00:04:27,580 --> 00:04:31,930
And the way we're going to implement this is through a shot energy management system.
86
00:04:31,930 --> 00:04:34,510
We're going to start out with a shot energy of three.
87
00:04:34,510 --> 00:04:40,060
This means we can shoot three times and recover one energy every time a projectile is destroyed.
88
00:04:40,060 --> 00:04:42,490
And that is a nice way of managing this.
89
00:04:43,330 --> 00:04:47,410
And we're then going to have three different types of projectiles on the player.
90
00:04:47,410 --> 00:04:51,550
And they all inherit these properties that we set here and here, of course.
91
00:04:51,550 --> 00:04:54,190
And for the regular projectile, we don't have to change anything.
92
00:04:54,190 --> 00:05:00,100
It's just going to be the default damage of one and just have this flipbook playing.
93
00:05:00,100 --> 00:05:02,380
We have a partially charged shot.
94
00:05:02,380 --> 00:05:06,940
This is if you hold the button and you let go before you get the full charge.
95
00:05:06,940 --> 00:05:08,800
Here, we could change the damage.
96
00:05:08,800 --> 00:05:12,850
I think some Megaman games have it where it does two damage, but I don't think it's necessary.
97
00:05:12,850 --> 00:05:16,420
This should just look a little bit different so we can actually just change the tint.
98
00:05:16,420 --> 00:05:20,140
We're still going to use the same flipbook, but in the settings we're just going to change the tint
99
00:05:20,140 --> 00:05:22,180
to just show this as the partial charge shot.
100
00:05:22,180 --> 00:05:27,100
And lastly, and most importantly, we're going to implement the fully charged projectile.
101
00:05:27,100 --> 00:05:28,930
And here we're going to use a different flipbook.
102
00:05:28,930 --> 00:05:31,660
So we can just overwrite the flipbook setting on the parent.
103
00:05:31,660 --> 00:05:34,780
And we're also going to change the damage from 1 to 3.
104
00:05:35,380 --> 00:05:38,560
And again we don't have to redo any of this from scratch.
105
00:05:38,560 --> 00:05:38,890
Right.
106
00:05:38,890 --> 00:05:39,970
We just have everything in here.
107
00:05:39,970 --> 00:05:40,570
We pass it on.
108
00:05:40,570 --> 00:05:41,410
We pass it down.
109
00:05:41,410 --> 00:05:46,120
Instead of making three completely different projectiles and having to redo the same thing over and
110
00:05:46,120 --> 00:05:47,080
over again.
111
00:05:47,320 --> 00:05:52,450
And for the enemy, the projectile enemy base actually doesn't have anything in it that is different
112
00:05:52,450 --> 00:05:53,170
from this one.
113
00:05:53,170 --> 00:05:55,510
So this is literally just for management.
114
00:05:55,510 --> 00:06:00,460
And later on we might decide that we have other projectiles again, and maybe we want to have something
115
00:06:00,460 --> 00:06:00,940
in here.
116
00:06:00,940 --> 00:06:05,320
And even though we don't really make use of the enemy projectile, it is good practice to have it here
117
00:06:05,320 --> 00:06:09,580
because there's a high chance we're going to split off later on and make multiple other projectiles.
118
00:06:09,580 --> 00:06:14,680
And again, for the enemy projectile lizard, we're just going to change the flipbook to this red one.
119
00:06:14,680 --> 00:06:19,420
And we might have to change the damage depending on how much damage we want the lizard to deal.
120
00:06:19,420 --> 00:06:22,720
And this is the overview of the projectiles.
121
00:06:22,720 --> 00:06:24,700
And I hope this wasn't overwhelming.
122
00:06:24,700 --> 00:06:29,380
Of course, these are things you kind of figure out as you make the game, but it is nice to kind of
123
00:06:29,380 --> 00:06:34,720
think about it beforehand and plan ahead so you don't drive yourself into a corner and have to redo
124
00:06:34,720 --> 00:06:36,070
code again and again.
125
00:06:36,070 --> 00:06:39,520
In this video, though, we're only going to create the projectile base.
126
00:06:39,520 --> 00:06:45,190
We're going to create a the player projectile base and the BP player projectile regular.
127
00:06:45,190 --> 00:06:47,950
All of the other ones are going to come in later chapters.
128
00:06:48,160 --> 00:06:48,520
Okay.
129
00:06:48,520 --> 00:06:53,650
Let's now create the base projectile so we can go to Content blueprints.
130
00:06:53,650 --> 00:06:57,130
Make a new folder called projectiles.
131
00:06:58,200 --> 00:07:04,770
In here, we again want to have another folder called player and another one called enemy.
132
00:07:05,160 --> 00:07:10,530
But here in the projectiles folder right click create a new blueprint class of type actor.
133
00:07:10,530 --> 00:07:14,190
As we discussed, because it's the simplest type that you can have.
134
00:07:14,730 --> 00:07:17,910
Click here and call it Bpy.
135
00:07:17,910 --> 00:07:18,720
Underscore.
136
00:07:18,720 --> 00:07:19,980
Projectile.
137
00:07:20,280 --> 00:07:21,270
Underscore.
138
00:07:21,270 --> 00:07:22,710
Base and caps.
139
00:07:26,190 --> 00:07:27,180
And hit enter.
140
00:07:27,740 --> 00:07:31,100
And from this, let's create all of the children we need for this video.
141
00:07:31,100 --> 00:07:34,580
So here we can just right click Create Child Blueprint class.
142
00:07:34,580 --> 00:07:38,900
And we're going to create the BP player projectile.
143
00:07:39,500 --> 00:07:40,370
Base.
144
00:07:42,500 --> 00:07:44,840
And we can drag this into the player folder.
145
00:07:44,840 --> 00:07:46,070
Move here.
146
00:07:46,370 --> 00:07:47,480
Go in here as well.
147
00:07:47,480 --> 00:07:50,990
And from this one right click again Create Child Blueprint class.
148
00:07:50,990 --> 00:07:56,420
And here we'll have the BP player projectile regular.
149
00:07:57,900 --> 00:08:03,780
And if we look back at our graph, right, we just created the BP projectile base, the BP player projectile
150
00:08:03,810 --> 00:08:06,990
base and the BP player projectile regular.
151
00:08:06,990 --> 00:08:12,930
And now when we implement something we need to be careful in the end decide which one we need to pick.
152
00:08:13,260 --> 00:08:15,870
So first we want to work on the general base.
153
00:08:15,870 --> 00:08:21,750
So back in the projectiles open up the BP projectile base which is the highest layer in our inheritance.
154
00:08:21,750 --> 00:08:23,100
Double click to open it up.
155
00:08:24,140 --> 00:08:25,760
And we can just drag this here.
156
00:08:26,350 --> 00:08:28,660
And again, this is just a regular blueprint.
157
00:08:28,660 --> 00:08:29,500
We have the viewport.
158
00:08:29,500 --> 00:08:30,670
We have the event graph.
159
00:08:30,670 --> 00:08:32,350
There's nothing fancy going on here.
160
00:08:32,350 --> 00:08:36,460
And now we're just going to implement the functionality we want all projectiles to have, no matter
161
00:08:36,460 --> 00:08:38,890
if it's player projectiles or enemy projectiles.
162
00:08:38,890 --> 00:08:44,140
The first thing we want to have for a projectile is at the projectile.
163
00:08:44,690 --> 00:08:47,930
Movement component and just put it here.
164
00:08:47,930 --> 00:08:52,820
And this is what is going to make our projectile move forward, which is going to affect gravity and
165
00:08:52,820 --> 00:08:53,810
do all of these things.
166
00:08:53,840 --> 00:08:59,180
Again, this is something that Unreal Engine or Epic Games made for us, because this is a very common
167
00:08:59,180 --> 00:09:01,070
thing in most games that people need.
168
00:09:01,070 --> 00:09:05,000
So there's no point in just making this again and again from scratch by yourself.
169
00:09:05,540 --> 00:09:09,020
In a later step, we're going to look at all of the details and the things we can set here.
170
00:09:09,380 --> 00:09:14,480
The projectile movement component needs a collision to work though, so we can go to add.
171
00:09:14,480 --> 00:09:17,780
And in our case we want to use a sphere collision.
172
00:09:17,780 --> 00:09:21,860
You could also use a box collision and others but it depends on your use case.
173
00:09:21,860 --> 00:09:24,200
But in this case sphere collision is the best.
174
00:09:25,080 --> 00:09:26,460
And very important.
175
00:09:26,460 --> 00:09:28,050
This needs to be the root.
176
00:09:28,080 --> 00:09:33,630
Now it is a child of the default scene root, but the projectile movement component will use the root
177
00:09:33,630 --> 00:09:34,380
for the collision.
178
00:09:34,380 --> 00:09:35,790
So we have to drag it here.
179
00:09:35,790 --> 00:09:38,640
And now you see the default root disappeared.
180
00:09:38,640 --> 00:09:41,280
And this is now the highest in our hierarchy.
181
00:09:41,280 --> 00:09:45,960
And this is what we need to have for the projectile movement to work, because it only accounts for
182
00:09:45,960 --> 00:09:47,640
the most upper level of collision.
183
00:09:47,940 --> 00:09:50,610
But this still doesn't look like a projectile for us.
184
00:09:50,610 --> 00:09:58,260
So if we select a sphere, we want to add a flip book, a paper flip book, right?
185
00:09:58,260 --> 00:10:03,600
And if we have the selected on the right side for source flip books, now we can just look for shot
186
00:10:04,020 --> 00:10:05,040
or shoot.
187
00:10:05,370 --> 00:10:09,450
And we want to use the player shoot loop.
188
00:10:09,690 --> 00:10:12,360
And this is our most basic projectile.
189
00:10:12,660 --> 00:10:17,520
And since the sphere will handle all of our collision, we don't want the paper flip book to have any
190
00:10:17,520 --> 00:10:18,090
collision.
191
00:10:18,090 --> 00:10:19,770
So we can just go to the details.
192
00:10:19,770 --> 00:10:27,390
And on the right side we set it from block all dynamic to no collision, because we don't want the actual
193
00:10:27,390 --> 00:10:28,590
flip book to collide with things.
194
00:10:28,590 --> 00:10:30,960
And this could lead to bugs and weird behavior.
195
00:10:31,350 --> 00:10:36,780
And now we also want to talk about the material settings on this paper flip book, because you remember
196
00:10:36,780 --> 00:10:43,170
that on the player to make things look more real, if we start the game, we have the shadow on the
197
00:10:43,170 --> 00:10:45,510
player and we have the player cast shadows.
198
00:10:45,810 --> 00:10:48,540
And here you have to decide what your personal preference is.
199
00:10:48,540 --> 00:10:55,680
But since these projectiles are energy or some plasma, I don't think we should set them to masked lit
200
00:10:55,680 --> 00:10:59,310
sprite material because it would be weird for them to receive shadows, in my opinion.
201
00:10:59,310 --> 00:11:03,990
And I also don't want them to cast shadows, so I don't think we have to change anything here.
202
00:11:03,990 --> 00:11:07,260
We can just leave it at masked unlit and we don't want it to cast shadows.
203
00:11:07,260 --> 00:11:14,100
Next, we want to think about the size of the sphere so you can see that the sphere is bigger than the
204
00:11:14,100 --> 00:11:18,150
paper flipbook, and we can just go to sphere and drag here to make it smaller.
205
00:11:18,150 --> 00:11:20,580
And we could make it match perfectly.
206
00:11:20,580 --> 00:11:23,820
But actually that is usually not what you want to do.
207
00:11:23,820 --> 00:11:26,520
And this is a little bit of game design knowledge.
208
00:11:26,520 --> 00:11:31,770
And I set it back to 32, usually for projectiles or things that the player uses.
209
00:11:31,770 --> 00:11:36,810
Because you want to make the player feel good, you should usually make the collision a little bit bigger
210
00:11:36,810 --> 00:11:38,250
than what it looks like.
211
00:11:38,250 --> 00:11:42,750
So even if the player misses a little bit, it would still hit and the player feels rewarded.
212
00:11:42,750 --> 00:11:47,850
What is a really bad practice for a player would be to make it smaller, so that even though it looks
213
00:11:47,850 --> 00:11:49,710
like it should have hit, it didn't hit.
214
00:11:49,710 --> 00:11:53,640
And that is something that makes players angry and makes them feel like your game isn't fair.
215
00:11:53,640 --> 00:11:59,940
So for this again, again, I think 32 is the best value because we are a little bit bigger than the
216
00:11:59,940 --> 00:12:00,810
paper flipbook.
217
00:12:00,810 --> 00:12:05,820
And on the flip side, for enemies, you usually want to make the collision a little bit smaller than
218
00:12:05,820 --> 00:12:08,760
what it should look like to give the player a little bit of leeway.
219
00:12:08,880 --> 00:12:13,050
Now let's drag this projectile into the world and see how it behaves.
220
00:12:13,050 --> 00:12:14,820
So we can just drag it in here.
221
00:12:15,570 --> 00:12:19,140
And if you want to test something like this, we don't care about the player right now.
222
00:12:19,140 --> 00:12:22,620
So instead of just going in here and worrying about the player.
223
00:12:22,650 --> 00:12:26,910
A simpler way to test this is to just click here and go to simulate.
224
00:12:27,490 --> 00:12:27,880
Right?
225
00:12:27,880 --> 00:12:30,610
So now we can just start the game without spawning a player.
226
00:12:30,610 --> 00:12:32,920
It's easier for us to test and see what happens here.
227
00:12:32,920 --> 00:12:38,440
And what happens here now is that there is gravity on the projectile and it just falls downward, which
228
00:12:38,440 --> 00:12:41,530
is not what we want, but we can easily set this up.
229
00:12:41,530 --> 00:12:48,820
So in the projectile base on the projectile movement component, we can just look for gravity and set
230
00:12:48,820 --> 00:12:52,660
this to zero because we don't want gravity to affect our projectile.
231
00:12:52,660 --> 00:12:57,430
So now if we just simulate it's just staying in place which is already good.
232
00:12:57,430 --> 00:13:00,130
But we of course want the projectile to fly forward.
233
00:13:00,130 --> 00:13:02,170
And for this we have two variables here.
234
00:13:02,170 --> 00:13:04,240
We have the initial speed and the max speed.
235
00:13:04,240 --> 00:13:06,820
And again I was playing around with these values a little bit.
236
00:13:06,820 --> 00:13:09,970
And I found that 1000 feels about right.
237
00:13:09,970 --> 00:13:12,640
And for both of these we want to use 1000.
238
00:13:12,880 --> 00:13:15,430
And you can then see how the projectile flies.
239
00:13:16,360 --> 00:13:17,170
Forward.
240
00:13:17,170 --> 00:13:19,000
And yeah, this is how it works.
241
00:13:19,000 --> 00:13:22,960
So the projectile movement component makes the projectile fly forward.
242
00:13:23,080 --> 00:13:26,320
And this is it very simple, very easy to set up.
243
00:13:26,320 --> 00:13:30,880
Now we want to set it up so that if the projectile hits a wall it's going to be destroyed.
244
00:13:31,600 --> 00:13:34,840
To do this, we can simply select the floor.
245
00:13:35,420 --> 00:13:37,370
So yeah, make sure you have the floor selected.
246
00:13:37,370 --> 00:13:43,070
We can hold alt on the keyboard, and we can drag here to create a copy of the floor.
247
00:13:43,190 --> 00:13:48,020
We can then go into rotation mode and rotate it up like this 90 degrees.
248
00:13:48,020 --> 00:13:51,380
And this just gives us a nice wall we can use for testing.
249
00:13:51,380 --> 00:13:56,090
And if I simulate now you're going to see that the projectile just passes through.
250
00:13:56,090 --> 00:13:57,650
It ignores the wall.
251
00:13:57,650 --> 00:14:01,400
And this is where collision channels come into play.
252
00:14:01,640 --> 00:14:06,770
And this is also a somewhat complicated topic, which I'll try to sum up in simple terms for you.
253
00:14:06,770 --> 00:14:11,060
There is actually a great blog post which I'm going to attach to the lecture, which you can check out
254
00:14:11,060 --> 00:14:15,590
if you want to get some more in-depth knowledge about this, but we're just gonna go over it quickly.
255
00:14:15,590 --> 00:14:21,740
So basically we can set a collision response to either ignore overlap or block.
256
00:14:22,190 --> 00:14:25,790
And we have different types of world static, which is the walls, the floor.
257
00:14:25,790 --> 00:14:30,530
We have a world dynamic which would be our projectile by default, which are other things that just
258
00:14:30,530 --> 00:14:31,580
move in the world.
259
00:14:31,580 --> 00:14:37,010
We have pawn, which is our character, but actually we can also create our own channels here, which
260
00:14:37,010 --> 00:14:38,630
we're going to do for the projectile.
261
00:14:38,630 --> 00:14:44,270
So we can define which items should overlap with the projectile, which items should block the projectile
262
00:14:44,270 --> 00:14:46,340
and which items should just ignore it.
263
00:14:46,340 --> 00:14:49,940
And what does ignore, overlap and block even mean?
264
00:14:49,940 --> 00:14:56,000
Let's just imagine that this character is the projectile in this sense, and if the projectile hits
265
00:14:56,000 --> 00:14:58,850
this bush, an overlap event will be triggered.
266
00:14:58,850 --> 00:15:04,280
And if we set the projectile to overlap with bushes and the bush to overlap with projectiles, if the
267
00:15:04,280 --> 00:15:07,280
projectile flies in here and overlap event will be triggered.
268
00:15:07,280 --> 00:15:09,410
And we can then decide what we're going to do here.
269
00:15:09,410 --> 00:15:14,270
You could, for example, just have the projectile keep on flying and maybe just have the bush start
270
00:15:14,270 --> 00:15:15,860
burning, for example.
271
00:15:15,860 --> 00:15:18,830
And this would be a perfect case for an overlap event.
272
00:15:18,950 --> 00:15:24,170
But you could also just say that the projectile hits the bush, and the bush maybe doesn't do anything,
273
00:15:24,170 --> 00:15:26,600
but the projectile is supposed to disappear.
274
00:15:26,600 --> 00:15:29,660
And again, this is also something we can do with an overlap event.
275
00:15:29,660 --> 00:15:34,970
A hit event, on the other hand, means that if two hard objects collide with each other, even if we
276
00:15:34,970 --> 00:15:39,260
don't do anything on the event, both of the objects will block each other anyway.
277
00:15:39,260 --> 00:15:43,670
This means that even though the projectile can pass through the bush, if it hits the wall which is
278
00:15:43,670 --> 00:15:48,020
blocking, it is just going to either stick to the wall or like hit the wall and fall down.
279
00:15:48,020 --> 00:15:50,000
In this case, we will also trigger an event.
280
00:15:50,000 --> 00:15:54,830
So we could then, for example, use the information in the event to see where did the bullet hit and
281
00:15:54,830 --> 00:15:57,140
maybe spawn like a bullet hole in the wall.
282
00:15:57,140 --> 00:16:00,200
So there are good use cases for both overlap and hit.
283
00:16:00,200 --> 00:16:05,570
And the way I want to set it up for this game is that our projectile will hit the wall so they will
284
00:16:05,570 --> 00:16:06,560
block each other.
285
00:16:06,560 --> 00:16:09,470
But let's say this bush is an enemy for the enemies.
286
00:16:09,470 --> 00:16:14,270
I just want to use an overlap event so the projectile hits the enemies and we can then decide are we
287
00:16:14,300 --> 00:16:17,150
going to let the projectile pass through, or are we going to destroy it?
288
00:16:17,150 --> 00:16:18,200
Like, what are we going to do?
289
00:16:18,200 --> 00:16:21,200
And I believe this is the cleanest setup for our game.
290
00:16:21,200 --> 00:16:25,640
So what can we do now to make sure that this projectile will be blocked by the wall?
291
00:16:25,640 --> 00:16:30,470
We can first of all check the floor or wall and look to the collision settings.
292
00:16:31,260 --> 00:16:34,050
And in here we see block all dynamic.
293
00:16:34,050 --> 00:16:38,580
And if we open this up, you see that it blocks pretty much everything, which is cool.
294
00:16:39,540 --> 00:16:43,080
And this itself, the object type is also world dynamic.
295
00:16:43,080 --> 00:16:44,880
So this is not world static.
296
00:16:44,880 --> 00:16:46,320
This is also world dynamics.
297
00:16:46,320 --> 00:16:50,160
So we need to make sure that the projectile also blocks world dynamic.
298
00:16:50,160 --> 00:16:55,710
Because even if the wall tries to block the projectile but the projectile ignores the wall, the ignore
299
00:16:55,710 --> 00:16:56,730
state will win.
300
00:16:56,730 --> 00:16:59,580
They both have to block each other for the blocking to take effect.
301
00:16:59,580 --> 00:17:06,390
So in the projectile base, we can go to the sphere here and scroll down to the collision settings.
302
00:17:06,390 --> 00:17:10,020
And here you can see overlap all dynamic right.
303
00:17:10,020 --> 00:17:14,880
So here we see well the wall was a world dynamic.
304
00:17:14,880 --> 00:17:17,369
And here we only overlap the world dynamic.
305
00:17:17,369 --> 00:17:20,550
But in our case we actually want to block the world dynamics.
306
00:17:20,550 --> 00:17:21,750
So what could we do here.
307
00:17:21,750 --> 00:17:26,730
Well we could go here and for example select block all dynamic.
308
00:17:26,730 --> 00:17:32,040
And now also here we just block everything and we can go back here and simulate.
309
00:17:32,670 --> 00:17:35,040
And you can see that we get stuck in the wall.
310
00:17:35,040 --> 00:17:37,950
So this is the behavior we want to have in this case.
311
00:17:38,280 --> 00:17:41,580
And we achieved this simply by changing the collision preset.
312
00:17:42,480 --> 00:17:46,740
We could then take this one step further and again, while you have the sphere selected on the right
313
00:17:46,740 --> 00:17:51,750
side, keep on scrolling down to the on component hit event.
314
00:17:51,750 --> 00:17:56,490
So this is the event that triggers if two blocking objects hit each other.
315
00:17:56,490 --> 00:17:59,670
On the other hand, we have the on component begin overlap.
316
00:17:59,670 --> 00:18:05,640
This triggers if two overlapping objects pass through each other and we have the end overlap.
317
00:18:05,640 --> 00:18:08,190
And this is if you leave the overlap area.
318
00:18:08,190 --> 00:18:12,660
But in this case, again because they are both blocking each other, we can use the on component hit
319
00:18:12,660 --> 00:18:14,820
event here and just click on plus.
320
00:18:15,390 --> 00:18:19,080
And we could then, for example, just print.
321
00:18:19,350 --> 00:18:22,830
Print string here and get the other actor.
322
00:18:23,910 --> 00:18:28,020
And this is just going to show the name of the actor that the bullet hits.
323
00:18:28,020 --> 00:18:29,280
And we can just start here.
324
00:18:30,190 --> 00:18:33,160
And on the top left you see floor two, which is correct, right?
325
00:18:33,160 --> 00:18:34,870
This floor two is what we hit.
326
00:18:34,870 --> 00:18:36,790
So we can get some information here.
327
00:18:36,790 --> 00:18:38,890
And we could then we'll exit out here.
328
00:18:38,890 --> 00:18:40,690
And we could then use this information.
329
00:18:40,690 --> 00:18:40,870
Right.
330
00:18:40,870 --> 00:18:42,610
So we get the hit event which is huge.
331
00:18:42,610 --> 00:18:44,920
So we can break this for example.
332
00:18:44,920 --> 00:18:45,280
Right.
333
00:18:45,280 --> 00:18:48,730
So we can get the blocking at the time distance location.
334
00:18:48,730 --> 00:18:50,500
So many things you can do with this.
335
00:18:50,500 --> 00:18:51,880
But our game is very simple.
336
00:18:51,880 --> 00:18:53,770
So we aren't going to use this.
337
00:18:53,770 --> 00:18:55,960
We're also not going to use the other actor.
338
00:18:55,960 --> 00:19:01,750
Well everything we have to do is that if we understand that we as the projectile got blocked, we simply
339
00:19:01,750 --> 00:19:04,300
have to destroy the projectile at this point in time.
340
00:19:04,300 --> 00:19:06,610
So just destroy actor.
341
00:19:08,220 --> 00:19:10,440
Compile, save and let's do this.
342
00:19:10,440 --> 00:19:14,190
So the bullet comes flying, it hits the wall and it disappears.
343
00:19:14,190 --> 00:19:17,160
So this is the first step of what we want to achieve.
344
00:19:17,580 --> 00:19:21,300
And later on we of course want to again on the sphere.
345
00:19:21,300 --> 00:19:27,270
We want to set it so that we don't block all dynamic, but we only overlap with the pawn with the other
346
00:19:27,270 --> 00:19:30,270
enemies, so we can then apply damage to them into other things.
347
00:19:30,270 --> 00:19:32,700
But that is a topic for a different video.
348
00:19:32,700 --> 00:19:34,410
So what we did here, we achieved that.
349
00:19:34,410 --> 00:19:37,320
A projectile flies, it hits the wall and it disappears.
350
00:19:37,320 --> 00:19:42,360
And in the next lesson we want to show a particle effect that shows the bullet exploding before we destroy
351
00:19:42,360 --> 00:19:42,750
it.
34542
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.