Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:03,760 --> 00:00:06,640
Now we do have a reload animation for our gun.
2
00:00:07,060 --> 00:00:08,740
The moment we never run out of bullets.
3
00:00:09,100 --> 00:00:14,260
So in this video, we're going to create a finite amount of bullets before you have to reload.
4
00:00:15,050 --> 00:00:17,440
OK, so the first thing that we need is a reload button.
5
00:00:17,890 --> 00:00:24,730
So we've got our shoot button when the duplicate that control and D and just moved up up above the shoot
6
00:00:24,730 --> 00:00:25,060
button.
7
00:00:28,200 --> 00:00:36,900
And I want this one to simply be a reload, so let me just change the text to say reload all in capitals
8
00:00:36,900 --> 00:00:37,170
again.
9
00:00:39,230 --> 00:00:43,050
I don't want this one to be read or for it to kind of be a big circle.
10
00:00:43,770 --> 00:00:50,520
So what I'm going to do is I'm going to go back to my joystick pack sprites, and we do have some horizontal
11
00:00:51,180 --> 00:00:51,630
ones.
12
00:00:51,720 --> 00:00:52,440
I quite like.
13
00:00:53,010 --> 00:00:58,800
So for this, I'm going to choose the horizontal riched.
14
00:01:01,070 --> 00:01:08,120
OK, and just make that a little bit bigger on the width and just a little bit bigger on the height,
15
00:01:08,960 --> 00:01:09,420
you know?
16
00:01:10,430 --> 00:01:12,080
No, I don't want it to be read.
17
00:01:12,170 --> 00:01:13,430
I want this one to be orange.
18
00:01:16,870 --> 00:01:24,530
So when you take this code troll and see it, you also put it on the selected code, control the movie,
19
00:01:25,990 --> 00:01:33,110
and then when you reload, I'm just simply going to turn this white breast also on white.
20
00:01:36,010 --> 00:01:42,160
And yeah, I think I think that's OK, if you want to go with one of the other ones, that's perfectly
21
00:01:42,160 --> 00:01:46,030
fine, OK, but I think they should be OK.
22
00:01:46,300 --> 00:01:47,800
So that's my reload button.
23
00:01:48,280 --> 00:01:50,200
So let me just name it that.
24
00:01:55,010 --> 00:01:56,920
Just get that one on the end.
25
00:01:59,690 --> 00:02:04,320
At the moment, it's running this function, we're going to change this in a second.
26
00:02:04,650 --> 00:02:08,250
But I also have some bullets as well, graphics of bullets.
27
00:02:08,400 --> 00:02:08,840
Here we go.
28
00:02:08,850 --> 00:02:09,510
Small bullet.
29
00:02:10,020 --> 00:02:18,900
So what I want to do there is on the canvas, just right click UI and a new image, drag the small bullet
30
00:02:18,900 --> 00:02:20,490
into the sprite set.
31
00:02:20,490 --> 00:02:21,540
Neat size.
32
00:02:22,030 --> 00:02:22,560
There we go.
33
00:02:22,950 --> 00:02:23,610
We've got the bullet.
34
00:02:24,000 --> 00:02:25,440
This is not a rakas target.
35
00:02:26,400 --> 00:02:27,900
It's just a simple image.
36
00:02:28,050 --> 00:02:34,380
And I'm going to drag it down to the bottom and then over here to the right.
37
00:02:35,830 --> 00:02:39,420
So basically to be very near to the shoot button.
38
00:02:42,720 --> 00:02:49,650
Wondering if that bullet is a little bit vague, actually, and might actually just reduce scale down
39
00:02:49,650 --> 00:02:53,790
to zero point eight on X, Y and Z.
40
00:02:59,220 --> 00:03:00,360
Not looks a little bit better.
41
00:03:00,900 --> 00:03:04,020
All right, so this is bullet.
42
00:03:07,550 --> 00:03:13,850
In fact, what I'm going to do here is on the canvas, just right click and choose, create empty.
43
00:03:14,400 --> 00:03:18,170
I'll simply call bullets so we can keep all these objects together.
44
00:03:19,610 --> 00:03:22,790
Let's just take the bullet and put it onto bullets.
45
00:03:23,820 --> 00:03:25,190
So that is then a folder.
46
00:03:27,440 --> 00:03:31,160
And uh, now I can duplicate this.
47
00:03:31,310 --> 00:03:32,580
Some control in D.
48
00:03:33,170 --> 00:03:36,770
And then I want to move this over to the left.
49
00:03:37,250 --> 00:03:43,190
What I want to do is find out exactly what is the difference between bullet one bullet to see if that's
50
00:03:43,190 --> 00:03:43,970
400.
51
00:03:44,630 --> 00:03:46,280
This one's 368.
52
00:03:46,550 --> 00:03:48,560
Let's make it maybe three seventy.
53
00:03:52,290 --> 00:03:53,070
That looks pretty good.
54
00:03:53,580 --> 00:03:56,010
There's a difference of 30 between those two.
55
00:03:56,980 --> 00:04:02,280
All right, that's that ensures that I can have a consistency between my bullets.
56
00:04:02,940 --> 00:04:05,370
So this one is bullet to.
57
00:04:09,450 --> 00:04:18,030
Control and control, and they still got four, five, six, seven, eight and planning of eight bullets
58
00:04:18,330 --> 00:04:19,470
in the magazine.
59
00:04:20,310 --> 00:04:23,970
So if this one is 370, we've got reduced 30.
60
00:04:24,720 --> 00:04:28,530
So 340 notes, so it lines up nicely.
61
00:04:29,460 --> 00:04:30,600
So 310.
62
00:04:36,600 --> 00:04:39,000
And 280 lines up nicely.
63
00:04:41,330 --> 00:04:42,230
250.
64
00:04:46,570 --> 00:04:47,410
To 20.
65
00:04:50,470 --> 00:04:56,620
And then finally, 190, OK, notice how they're all nicely lined up with each other as well.
66
00:04:57,580 --> 00:04:57,940
Great.
67
00:04:57,950 --> 00:05:01,060
So let's just rename these three.
68
00:05:01,660 --> 00:05:08,440
It's not necessary to rename them, to be honest, but just for the sake of it being easy to read.
69
00:05:10,210 --> 00:05:15,400
Certainly if you come back to a project after a long time and you're thinking, OK, well, what's going
70
00:05:15,400 --> 00:05:15,850
on here?
71
00:05:16,180 --> 00:05:20,500
It's always best to have things organized nicely.
72
00:05:20,500 --> 00:05:23,200
And it's really, really easy to understand.
73
00:05:23,710 --> 00:05:25,360
Bear in mind, it finishes about seven.
74
00:05:25,520 --> 00:05:27,250
The first one didn't have no.
75
00:05:27,700 --> 00:05:29,290
Oh, no, it should be eight.
76
00:05:29,530 --> 00:05:31,130
Actually, the first one should have been bullet one.
77
00:05:33,310 --> 00:05:33,940
There we go.
78
00:05:34,180 --> 00:05:34,570
All right.
79
00:05:34,630 --> 00:05:35,140
Excellent.
80
00:05:36,250 --> 00:05:40,540
So now back in the script, what we want to do is
81
00:05:43,240 --> 00:05:46,380
we want to apply these to our scripts.
82
00:05:46,600 --> 00:05:49,780
You can leave Mossop comment and this is going to be reloading.
83
00:05:51,430 --> 00:05:53,980
OK, and we need access to that reload button.
84
00:05:54,640 --> 00:06:01,710
So public after game object, we'll call reload button.
85
00:06:05,240 --> 00:06:07,430
Then we need a bullet count.
86
00:06:07,790 --> 00:06:15,500
So private integer or bullet counts equals eight, since, you know, we've got eight bullets.
87
00:06:15,980 --> 00:06:20,180
And then we need to be able to drag all of those bullets into our script.
88
00:06:20,330 --> 00:06:24,410
So public game objects will call.
89
00:06:24,840 --> 00:06:25,400
Well, at one.
90
00:06:28,450 --> 00:06:38,440
Just copy this drone C control V three, four, five, six, seven, eight.
91
00:06:41,200 --> 00:06:44,200
Two, three, four.
92
00:06:46,600 --> 00:06:52,720
Five, six, seven and eight.
93
00:06:54,820 --> 00:06:55,300
OK.
94
00:06:56,110 --> 00:07:03,730
We also need some kind of a wait four seconds and which is going to wait until we've actually played
95
00:07:03,750 --> 00:07:07,210
our reload animation before it actually refills the bullets.
96
00:07:07,900 --> 00:07:12,570
So we're going to have a wait four seconds.
97
00:07:13,870 --> 00:07:17,440
I'm going to call it and reload.
98
00:07:17,560 --> 00:07:20,680
Pause equals a new.
99
00:07:20,890 --> 00:07:22,210
Wait a second.
100
00:07:24,770 --> 00:07:27,560
And it's going to be roughly about three seconds.
101
00:07:30,860 --> 00:07:38,150
OK, so now in a shoot, we want to make sure that you can only shoot as long as you've actually got
102
00:07:38,150 --> 00:07:39,560
some bullets in your gun.
103
00:07:40,250 --> 00:07:48,110
So just underneath the fire, we're going to see if bullet count.
104
00:07:50,520 --> 00:07:52,560
Is greater than zero.
105
00:07:56,170 --> 00:07:58,450
And we're going to contain all of this.
106
00:08:00,550 --> 00:08:09,760
Inside of that bullet count, OK, if you hover over these, it will actually show you what the connecting
107
00:08:10,390 --> 00:08:13,810
and curly bracket is, and that looks fine to me.
108
00:08:14,740 --> 00:08:15,160
OK.
109
00:08:15,490 --> 00:08:23,050
Each time that we fire and we want to say bullet count minus minus.
110
00:08:23,200 --> 00:08:25,870
So we're reducing that amount of bullets.
111
00:08:27,970 --> 00:08:32,700
And then we're going to run a custom function called display bullets.
112
00:08:35,210 --> 00:08:40,550
The reason why these custom functions is simply so I if I've got a function, I don't want to write
113
00:08:40,550 --> 00:08:42,980
too much in the function because it becomes harder to read.
114
00:08:43,340 --> 00:08:48,890
So by having all of these separate custom functions, it just it makes it easier to read and it's easier
115
00:08:48,890 --> 00:08:49,670
to layout.
116
00:08:51,230 --> 00:08:52,250
So I'll do it on their.
117
00:08:54,440 --> 00:08:59,630
This actually should be avoided display bullets.
118
00:09:03,330 --> 00:09:11,690
He's simply going to say if bullet count is equal to eight, and that means we've got all bullets.
119
00:09:12,080 --> 00:09:13,790
So we need to ensure that they're all switched on.
120
00:09:13,970 --> 00:09:18,320
So the same bullet can't set active.
121
00:09:21,840 --> 00:09:23,010
Oh, it's bullet count.
122
00:09:23,280 --> 00:09:24,030
It should be bullet.
123
00:09:27,530 --> 00:09:29,900
Now check out what they've done there.
124
00:09:31,220 --> 00:09:32,120
Oh, yes, Bullett.
125
00:09:32,120 --> 00:09:33,530
Well, now I put a number on it.
126
00:09:35,690 --> 00:09:38,870
Bullet one set active.
127
00:09:40,990 --> 00:09:41,700
Too true.
128
00:09:42,250 --> 00:09:51,580
So which, you know, it's the same with all the others control and see from the three, four, five,
129
00:09:51,850 --> 00:09:53,920
six, seven, eight.
130
00:10:08,570 --> 00:10:17,470
OK, there we go, and then we're going to say, if bullet count is equal to seven.
131
00:10:19,400 --> 00:10:23,660
Instead of having to write all love again or we're gonna do is switch off bullet eight because you've
132
00:10:23,660 --> 00:10:24,110
used one.
133
00:10:24,620 --> 00:10:31,580
So we're going to say bullet eight seductive to switch it off.
134
00:10:32,960 --> 00:10:37,610
Let's copy this drone C drone base now.
135
00:10:37,610 --> 00:10:45,020
Six, five, four, three, two, one case.
136
00:10:45,030 --> 00:10:47,180
It'll be the safe bullet count is equal to six.
137
00:10:47,180 --> 00:10:48,800
We're going to switch off bullet seven.
138
00:10:49,940 --> 00:10:52,020
Well, it counts as equal to five.
139
00:10:52,100 --> 00:10:53,690
Going to switch off bullets six.
140
00:10:54,500 --> 00:11:01,670
If it's four, when the switch of bullet, five if it's three, then switch off bullet four.
141
00:11:03,760 --> 00:11:04,560
It's two.
142
00:11:05,680 --> 00:11:07,390
We're going to switch off bullet three.
143
00:11:08,170 --> 00:11:14,860
And if it's one, we're going to switch off bullet two and then need another one on the bottom.
144
00:11:15,340 --> 00:11:16,750
For one, we've run out of bullets.
145
00:11:18,040 --> 00:11:18,400
OK.
146
00:11:18,520 --> 00:11:20,710
Bullet count is equal to zero.
147
00:11:21,960 --> 00:11:23,380
I'm going to switch off bullet one.
148
00:11:24,160 --> 00:11:27,250
And we need to switch on our reload button.
149
00:11:27,700 --> 00:11:30,160
So reload button.
150
00:11:30,520 --> 00:11:34,090
So seductive to true.
151
00:11:39,770 --> 00:11:43,040
OK, so that will then display all of our bullets, which is good.
152
00:11:43,340 --> 00:11:52,790
All we need to do now is basically call a reload function from our reload button so we can do so by
153
00:11:52,790 --> 00:11:56,660
saying public void, let's call it reload.
154
00:12:00,760 --> 00:12:08,200
OK, so the first thing that we need to do is access the bombs and then to set trigger.
155
00:12:09,670 --> 00:12:12,910
Let me just double check what we actually called this.
156
00:12:14,980 --> 00:12:17,320
So just wait for that to date.
157
00:12:20,920 --> 00:12:24,160
So in the animator, we called it reload with a capital R.
158
00:12:24,490 --> 00:12:28,570
OK, so we're going to set up trigger reload.
159
00:12:31,180 --> 00:12:37,840
OK, and then as soon as it's done that we're going to basically started Gorriti because we need to
160
00:12:37,840 --> 00:12:44,050
either pause more, call it and wait for reload.
161
00:12:47,990 --> 00:12:51,170
And then as soon as we've done that, we want to switch off the reload button.
162
00:12:54,610 --> 00:12:56,980
Seductive to false.
163
00:13:02,260 --> 00:13:06,850
Safer so now down in I enumerators bottom.
164
00:13:09,310 --> 00:13:13,870
I enumerator wait for reloj.
165
00:13:17,260 --> 00:13:20,500
This is then going to call a ealt return.
166
00:13:20,710 --> 00:13:30,520
And we called it and it reload porc and we go, that's going to wait three seconds and then it's going
167
00:13:30,520 --> 00:13:33,510
to set a bullet count back to eight.
168
00:13:36,070 --> 00:13:44,170
We also need to ensure that we're displaying bullets and display bullets.
169
00:13:44,510 --> 00:13:45,280
That's what we called it.
170
00:13:47,020 --> 00:13:52,540
If you don't call up, you won't get the bullets appear on screen until you actually shoot again.
171
00:13:52,630 --> 00:13:57,130
So we have to call that function so it can run through it and basically switch everything back on the
172
00:13:57,130 --> 00:13:57,310
gun.
173
00:13:58,890 --> 00:14:04,000
It's safe that that should work fine now.
174
00:14:04,150 --> 00:14:10,060
So all we need to do is attach bullets to a script.
175
00:14:13,260 --> 00:14:21,250
So on the ground now of a whole bunch of empty game object, so we've got a reload button distracted
176
00:14:22,050 --> 00:14:24,660
by default, reload button is going to be switched off.
177
00:14:29,770 --> 00:14:31,150
And then we need bullets.
178
00:14:33,910 --> 00:14:37,540
Well, at one point, two, three.
179
00:14:40,000 --> 00:14:40,480
For.
180
00:14:42,230 --> 00:14:42,840
Five.
181
00:14:44,690 --> 00:14:47,120
Just make sure you're going into the correct slots.
182
00:14:50,250 --> 00:14:51,870
OK, there we go.
183
00:14:52,680 --> 00:14:56,250
So let's just save this and check this out.
184
00:15:02,070 --> 00:15:04,430
Now, each time I shoot, get rid of a bullet.
185
00:15:07,110 --> 00:15:13,340
OK, and then as soon as I've gone through all of those, you notice I can shoot, but it won't be it
186
00:15:13,340 --> 00:15:16,100
in anything until I press reload.
187
00:15:17,790 --> 00:15:21,230
Oh, some reason it's not reload and bullets.
188
00:15:25,560 --> 00:15:27,150
Oh, I know why I didn't.
189
00:15:27,280 --> 00:15:31,480
I mean, the relo button, I didn't put anything on the script.
190
00:15:31,680 --> 00:15:33,060
I just had the main chute.
191
00:15:33,180 --> 00:15:36,960
So on the main, I'm going to choose reload.
192
00:15:37,230 --> 00:15:38,760
I have to call the correct function.
193
00:15:39,570 --> 00:15:40,680
OK, let's try it again.
194
00:15:44,840 --> 00:15:48,200
Shoot, shoot, shoot, shoot, shoot.
195
00:15:51,340 --> 00:15:58,240
OK, and then reload the bullets back and off we go again.
196
00:16:00,070 --> 00:16:01,060
Excellent.
197
00:16:03,000 --> 00:16:03,810
OK, good.
198
00:16:04,110 --> 00:16:08,160
So what will work in the next video is just given, not reload sound.
16779
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.