Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:00,140 --> 00:00:04,670
In this video, we're just going to create a simple flying enemy that just flies between point A and
2
00:00:04,670 --> 00:00:10,130
point B, and this is going to be the BP enemy bat which has a fly patrol system.
3
00:00:10,130 --> 00:00:14,450
And again, it's based on the enemy base which is based on the action chart base.
4
00:00:14,780 --> 00:00:20,300
First, we can just clean this up again and close all the tabs and open the content drawer.
5
00:00:20,330 --> 00:00:28,700
Go to blueprints, characters, enemies, and on the BP enemy base, right click and create Child Blueprint
6
00:00:28,700 --> 00:00:31,940
class and call BP underscore enemy.
7
00:00:32,659 --> 00:00:33,380
Underscore.
8
00:00:33,380 --> 00:00:34,160
Bat.
9
00:00:34,640 --> 00:00:39,830
Again the first thing in here we just open it up and we set the sprite to look for bat.
10
00:00:39,830 --> 00:00:42,050
And the bat only has an idle animation.
11
00:00:42,050 --> 00:00:42,890
Nothing else.
12
00:00:42,890 --> 00:00:45,140
We don't have to worry about setting up paper XDD.
13
00:00:45,170 --> 00:00:49,040
We also don't have to worry about switching animations in paper 2D as well.
14
00:00:49,370 --> 00:00:51,950
Now first we can just put this into the map.
15
00:00:51,950 --> 00:00:56,480
So just open up the map and just drag out the BP enemy bat.
16
00:00:56,480 --> 00:00:59,180
And again we want to make sure that it's on the same lane.
17
00:00:59,180 --> 00:01:01,850
So put the y two -50.
18
00:01:02,470 --> 00:01:05,050
And we can just drag it up in the air.
19
00:01:05,920 --> 00:01:13,750
And also rotate it around like here at 180 on the Z to have it look to the left side.
20
00:01:14,850 --> 00:01:15,660
Towards the player.
21
00:01:15,660 --> 00:01:16,170
And yeah.
22
00:01:16,170 --> 00:01:18,240
So now if we go to simulate.
23
00:01:18,770 --> 00:01:21,110
You can see that it just falls down.
24
00:01:21,110 --> 00:01:25,760
Because of course, we have to tell Unreal Engine that we want this character to fly.
25
00:01:26,270 --> 00:01:28,220
And this is actually very easy.
26
00:01:28,220 --> 00:01:32,120
So in the bpn we bet on the character movement component.
27
00:01:32,120 --> 00:01:37,070
We can just look for movement mode, which is a setting on here.
28
00:01:37,070 --> 00:01:42,200
And we can just set the default land movement mode to flying.
29
00:01:42,950 --> 00:01:45,740
And now I just compile and save and I check it out again.
30
00:01:45,740 --> 00:01:48,440
And hey, this already solved the problem.
31
00:01:48,440 --> 00:01:50,300
The bat is now not falling down anymore.
32
00:01:50,300 --> 00:01:53,090
It's ignoring gravity and it is flying.
33
00:01:54,110 --> 00:01:59,570
And now we just want to make the bed move between point A and point B, and for this, we actually don't
34
00:01:59,570 --> 00:02:00,800
even need an AI controller.
35
00:02:00,800 --> 00:02:04,130
We can just do this right in the blueprint because it's that simple.
36
00:02:04,130 --> 00:02:08,419
And it doesn't really fit the pattern of the brain telling the body to do something.
37
00:02:09,220 --> 00:02:10,810
Back in the enemy bat.
38
00:02:10,810 --> 00:02:16,900
We now click on the capsule component and we just want to add a scene component again.
39
00:02:16,900 --> 00:02:18,220
And the scene again.
40
00:02:18,220 --> 00:02:22,600
It's just a very simple object that can have a position, a rotation and so on.
41
00:02:22,600 --> 00:02:26,740
And we're just going to call this one top pose like this.
42
00:02:26,740 --> 00:02:28,300
And we can click out of this.
43
00:02:28,300 --> 00:02:32,050
And again we want to make sure to just attach a billboard here.
44
00:02:32,140 --> 00:02:34,180
And this just makes it easier to see.
45
00:02:34,210 --> 00:02:34,870
Right.
46
00:02:34,870 --> 00:02:40,180
And then we can select this top pose and zoom out a little bit and just drag this up here.
47
00:02:40,600 --> 00:02:44,290
And then in the end the bat is going to try to fly towards this position.
48
00:02:44,290 --> 00:02:46,750
And we actually want to have a second position.
49
00:02:46,750 --> 00:02:49,390
So here we can just duplicate.
50
00:02:49,390 --> 00:02:51,880
And it's called bottom pass.
51
00:02:52,360 --> 00:02:55,780
And for this one we also want to add a billboard.
52
00:02:57,560 --> 00:02:58,340
Like this.
53
00:02:58,980 --> 00:03:03,540
And drag it down, but now the billboard is actually in a weird position.
54
00:03:03,540 --> 00:03:06,840
So we can go to the Billboard one and just click here to reset.
55
00:03:07,760 --> 00:03:10,010
And then you have the bottom pass.
56
00:03:10,010 --> 00:03:12,650
And again we can adjust this in the map.
57
00:03:12,650 --> 00:03:15,710
But for now it should just have a little bit of a range here.
58
00:03:16,510 --> 00:03:18,520
And now I just want you to think for a second.
59
00:03:18,520 --> 00:03:21,370
How do you think we're going to be able to achieve this?
60
00:03:21,400 --> 00:03:24,970
There's a couple of different methods, but I want to go for the simplest one.
61
00:03:26,090 --> 00:03:29,990
And if your answer was timeline, then you are correct.
62
00:03:30,350 --> 00:03:32,600
And we've used timelines before for a couple of things.
63
00:03:32,600 --> 00:03:35,450
And this is just another instance where we use timelines.
64
00:03:36,190 --> 00:03:39,100
So on the event graph, we can just right click here.
65
00:03:39,220 --> 00:03:40,990
Make a custom event.
66
00:03:44,660 --> 00:03:47,300
And just call it move.
67
00:03:48,420 --> 00:03:51,330
And from this we want to make a new timeline.
68
00:03:51,690 --> 00:03:55,500
So just add timeline and just call it move anim.
69
00:03:56,410 --> 00:03:57,250
Like this.
70
00:03:59,730 --> 00:04:03,810
And we want to not use play, but hold control and use play from start.
71
00:04:03,810 --> 00:04:06,690
And this way you can just make sure it always starts from zero.
72
00:04:07,290 --> 00:04:08,430
And on update.
73
00:04:08,430 --> 00:04:13,920
We then want to set actor location so we're not going to use physics.
74
00:04:13,920 --> 00:04:20,250
We are forcefully setting where the bat is going to be, and we're going to update this on every tick
75
00:04:20,250 --> 00:04:22,350
when this timeline is active.
76
00:04:22,800 --> 00:04:25,530
So how do we get the location now though?
77
00:04:26,320 --> 00:04:33,130
Again, we can use the timeline to give us a value between 0 and 1, and we can then use a lerp vector.
78
00:04:33,680 --> 00:04:39,350
Which is going to use this alpha and show either the A value or the B value, or something in between.
79
00:04:39,770 --> 00:04:43,640
And for the A value, well, we can just use our top pass.
80
00:04:43,760 --> 00:04:47,660
And here just get world location like this.
81
00:04:48,740 --> 00:04:51,110
And for the bottom bus the same thing.
82
00:04:51,110 --> 00:04:55,580
Get world location and just put this in here.
83
00:04:56,160 --> 00:05:01,020
There is going to be a small bug with this method, which we're going to talk about, but for now,
84
00:05:01,020 --> 00:05:04,200
this is the way you would go about this most of the time.
85
00:05:04,200 --> 00:05:06,810
And now let's just worry about the alpha.
86
00:05:06,810 --> 00:05:08,190
So just double click this here.
87
00:05:08,190 --> 00:05:13,830
And again I always like to set a length of one and then change this later with the play rate.
88
00:05:14,470 --> 00:05:20,800
Just click on Plus Track and add a float track because we just want a number and just call it Alpha.
89
00:05:21,250 --> 00:05:22,690
Again right click here.
90
00:05:22,690 --> 00:05:25,450
Add a key start at zero.
91
00:05:26,200 --> 00:05:30,400
Time and also start at zero value and then add another key.
92
00:05:30,430 --> 00:05:33,550
Go at time one and value one.
93
00:05:33,550 --> 00:05:35,590
And we want to make this a little bit smoother.
94
00:05:35,590 --> 00:05:40,120
So just select both of them with left click right click one of them and go to auto.
95
00:05:40,120 --> 00:05:44,950
So we get this ease in and ease out here, which is just going to make it look more natural.
96
00:05:47,800 --> 00:05:49,450
Now back in the event graph right.
97
00:05:49,450 --> 00:05:50,500
We get this alpha.
98
00:05:50,500 --> 00:05:52,000
We can just put it in here.
99
00:05:52,770 --> 00:05:54,540
And just go like this.
100
00:05:55,620 --> 00:05:56,520
Double click.
101
00:05:58,650 --> 00:06:01,800
And we still need to call this timeline.
102
00:06:01,800 --> 00:06:03,900
And for now we just want to play it once.
103
00:06:03,900 --> 00:06:05,130
So for now, this is fine.
104
00:06:05,130 --> 00:06:08,010
We just want to call the move on begin play.
105
00:06:08,010 --> 00:06:09,300
So let's call move.
106
00:06:11,410 --> 00:06:12,130
Like this.
107
00:06:12,690 --> 00:06:18,090
And if I click on stimulate now we can look at the problem and you can see that the character just zaps
108
00:06:18,090 --> 00:06:19,680
around like crazy.
109
00:06:19,680 --> 00:06:26,130
And the reason this happens is that on the enemy bat, the top position and bottom position are actually
110
00:06:26,130 --> 00:06:31,710
attached to the capsule component, so they will move together with the character.
111
00:06:31,710 --> 00:06:35,610
So the character is trying to follow this position, but the position moves with the character.
112
00:06:35,610 --> 00:06:38,760
So this is kind of the problem of having a carrot on a stick.
113
00:06:38,760 --> 00:06:43,110
And the carrot just moves with you and you keep on chasing the carrot, and then it just goes all over
114
00:06:43,110 --> 00:06:43,860
the place.
115
00:06:43,860 --> 00:06:49,830
Just going to the top position and setting the transform to world also doesn't work, because we have
116
00:06:49,830 --> 00:06:54,990
the absolute location, and it's going to try to go into the map, then into a different position,
117
00:06:54,990 --> 00:06:57,930
because then it's going to find this position in the world.
118
00:06:57,930 --> 00:06:59,400
So this also doesn't work.
119
00:06:59,400 --> 00:07:01,170
Just set this back to relative.
120
00:07:01,260 --> 00:07:04,470
So we have to use a little bit of a different approach.
121
00:07:04,800 --> 00:07:08,760
We now simply want to save the initial position of the top pose and bottom pass.
122
00:07:08,760 --> 00:07:10,710
And we're going to use that as a reference.
123
00:07:10,710 --> 00:07:15,300
So then we don't care if the position is actually dynamically move with the character.
124
00:07:15,300 --> 00:07:24,480
So in the event graph before we use the move function, we just want to get the top pass here get world
125
00:07:24,480 --> 00:07:25,500
location.
126
00:07:26,320 --> 00:07:29,170
And we can then just promote this to a variable.
127
00:07:30,110 --> 00:07:33,110
And just call it World Top Plus.
128
00:07:34,410 --> 00:07:36,780
And save this here in the variable.
129
00:07:37,760 --> 00:07:40,130
And then do the same thing for the bottom canister.
130
00:07:40,130 --> 00:07:40,880
Drag off here.
131
00:07:40,910 --> 00:07:43,100
Get world location.
132
00:07:44,220 --> 00:07:49,200
And promote the variable world bottom pos.
133
00:07:50,060 --> 00:07:50,870
Like this.
134
00:07:54,570 --> 00:07:56,970
And after this we want to call the move.
135
00:07:56,970 --> 00:08:02,280
And now we need to use these variables here instead of the dynamic ones.
136
00:08:02,280 --> 00:08:09,270
So we can just get rid of these and just drag in the world top bars and drag in the world bottom pass.
137
00:08:09,660 --> 00:08:14,040
And so this basically just uses the position we set.
138
00:08:14,760 --> 00:08:20,040
In begin play and we just save it, and then we don't really care if this changes later on because we
139
00:08:20,040 --> 00:08:20,700
already saved it.
140
00:08:20,700 --> 00:08:23,610
And we're just going to use the saved variable for this.
141
00:08:23,610 --> 00:08:24,570
So let's check this out.
142
00:08:24,570 --> 00:08:26,940
Now I go here simulate.
143
00:08:28,450 --> 00:08:32,350
And you can see that we make a full loop from top to bottom.
144
00:08:33,130 --> 00:08:35,110
So this is working out fine.
145
00:08:36,500 --> 00:08:39,590
Of course, you also want to go back up again and keep on looping this.
146
00:08:41,000 --> 00:08:44,600
And one thing we can do is to just create another custom event.
147
00:08:44,600 --> 00:08:46,340
So here custom event.
148
00:08:47,840 --> 00:08:50,000
And it's called Move Forward.
149
00:08:51,990 --> 00:09:00,810
This and play from start and after we are finished we can just call move forward for example.
150
00:09:01,740 --> 00:09:04,200
And now it's just going to keep on looping like this.
151
00:09:04,200 --> 00:09:06,090
And this is still not a perfect.
152
00:09:06,090 --> 00:09:09,540
But this just shows you how we can use multiple custom events.
153
00:09:09,540 --> 00:09:12,480
But we actually also want to have a move backward.
154
00:09:12,480 --> 00:09:15,060
So here we can have a custom event.
155
00:09:15,730 --> 00:09:18,340
And going to call it move backward.
156
00:09:18,940 --> 00:09:21,520
And this we use reverse from.
157
00:09:21,520 --> 00:09:24,130
And so here we play from the end again.
158
00:09:24,730 --> 00:09:27,790
And this regular move custom event we can just get rid of now.
159
00:09:27,880 --> 00:09:30,040
And we just use the move forward move backward.
160
00:09:30,040 --> 00:09:37,270
So now at the top we actually have to call not move but move forward instead.
161
00:09:37,690 --> 00:09:39,790
And we just change the name basically.
162
00:09:39,790 --> 00:09:46,330
And one problem we have now is that we actually don't know after finished did we just finish the move
163
00:09:46,330 --> 00:09:49,000
forward or did we finish the move backward.
164
00:09:49,000 --> 00:09:51,100
But we know it's always going to alternate.
165
00:09:51,100 --> 00:09:54,250
So here we can simply use a flip flop.
166
00:09:55,720 --> 00:10:01,750
And flip flop is a flow control node that is going to play A on the first time, and the second time
167
00:10:01,750 --> 00:10:02,830
it's going to play B.
168
00:10:02,920 --> 00:10:07,060
So the first time we know we start from move forward, we want to move backward.
169
00:10:07,060 --> 00:10:10,510
So here we can just move backward like this.
170
00:10:10,510 --> 00:10:12,790
And we got to open up some more space here.
171
00:10:16,130 --> 00:10:17,480
This and yeah.
172
00:10:17,480 --> 00:10:19,040
So first time move backward.
173
00:10:19,040 --> 00:10:21,230
Second time move forward.
174
00:10:23,810 --> 00:10:24,590
Like this.
175
00:10:25,660 --> 00:10:27,040
And yeah, this is it.
176
00:10:27,040 --> 00:10:29,440
So first time we go here we play it again.
177
00:10:29,440 --> 00:10:30,760
And then we played from this.
178
00:10:30,760 --> 00:10:33,850
And we just keep on looping back and forth and back and forth.
179
00:10:33,850 --> 00:10:36,760
All without having to use the tick event.
180
00:10:37,000 --> 00:10:38,050
Let's try it out.
181
00:10:38,050 --> 00:10:40,930
So we go up and down and up and down.
182
00:10:40,930 --> 00:10:44,920
And you can see the smoothing at the top and bottom where it becomes a little bit slower.
183
00:10:45,280 --> 00:10:48,400
And this is because we implemented it that way in our timeline.
184
00:10:48,700 --> 00:10:54,730
One improvement we can make to this is that actually right now we don't have control over how fast this
185
00:10:54,730 --> 00:10:55,540
is playing.
186
00:10:55,540 --> 00:10:57,550
So we can go to the enemy bat.
187
00:10:57,850 --> 00:11:01,630
And for the move anim we can actually set the play rate.
188
00:11:02,450 --> 00:11:05,810
So we can just get the mov anim.
189
00:11:05,930 --> 00:11:07,010
Type it in.
190
00:11:07,980 --> 00:11:11,280
Getmove enum and set the play rate.
191
00:11:13,510 --> 00:11:13,960
Like this.
192
00:11:13,960 --> 00:11:16,810
And again, if we set it to two, it's going to be twice as fast.
193
00:11:16,810 --> 00:11:19,480
If we set it 0.5, it's going to be half as fast.
194
00:11:21,300 --> 00:11:26,340
And we just want to promote this to a variable and just called move play rate.
195
00:11:27,860 --> 00:11:29,300
And compile and save.
196
00:11:29,300 --> 00:11:35,270
And let's just have a value of 0.8 as the default.
197
00:11:36,010 --> 00:11:37,030
And compile and save.
198
00:11:37,030 --> 00:11:41,020
And now we actually want to call this before the move forward.
199
00:11:41,750 --> 00:11:42,560
On begin play.
200
00:11:42,560 --> 00:11:43,190
Right.
201
00:11:43,190 --> 00:11:44,450
We call this once.
202
00:11:46,920 --> 00:11:48,630
And let's just try this out now.
203
00:11:50,400 --> 00:11:55,560
And you can see the movement is a little bit slower, and we can actually also go through the move play
204
00:11:55,560 --> 00:11:58,380
rate and make it instance editable.
205
00:11:58,710 --> 00:12:04,080
So we can compile and save now and let's just copy this bat hold alt and drag off here.
206
00:12:04,860 --> 00:12:08,730
And we can say that, well, this bat is supposed to be slower.
207
00:12:08,730 --> 00:12:12,150
So here, if it's selected, we can go here to the right.
208
00:12:12,150 --> 00:12:15,180
And under default we see the move play rate.
209
00:12:15,180 --> 00:12:18,870
And let's say this one is just 0.4 for example.
210
00:12:19,290 --> 00:12:19,620
Right.
211
00:12:19,620 --> 00:12:21,240
And you can see the difference.
212
00:12:21,240 --> 00:12:26,160
And now not only the programmer but if you have a game designer or a level designer, they could come
213
00:12:26,160 --> 00:12:29,670
in here and just set a different speed for all of your different enemies.
214
00:12:29,670 --> 00:12:36,360
And not just that, if we select this bat, we can also go here to details and we can see the top pass
215
00:12:36,360 --> 00:12:37,740
and the bottom pass.
216
00:12:37,740 --> 00:12:40,560
And we can change this on a per instance basis.
217
00:12:40,560 --> 00:12:41,130
Right.
218
00:12:41,130 --> 00:12:42,990
So we could have the top pass here.
219
00:12:43,630 --> 00:12:48,820
Have the bottom pass here and we can kind of make the bat go diagonal.
220
00:12:49,390 --> 00:12:55,510
And this is again a very cool tool for level design, and it just brings some variety with it.
221
00:12:56,310 --> 00:12:59,520
In the next lesson, we'll create the last basic enemy type.
19702
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.