Would you like to inspect the original subtitles? These are the user uploaded subtitles that are being translated:
1
00:00:03,420 --> 00:00:08,730
Now, in this video, we want the ability to be able to shoot these enemies in order to destroy them.
2
00:00:09,180 --> 00:00:13,830
So the first thing that we need is crosshairs for a gun so that we know exactly where we're pointing.
3
00:00:14,700 --> 00:00:19,560
So in the mobile game resources, you'll find that I've given you the crosshairs.
4
00:00:20,100 --> 00:00:22,320
When the place is on the canvas.
5
00:00:22,470 --> 00:00:30,070
So if you're just right, click on the canvas Jujuy and a new image, then we're going to drag the crosshairs
6
00:00:30,090 --> 00:00:31,470
into the source image.
7
00:00:31,800 --> 00:00:33,930
OK, and then clicks that native size.
8
00:00:34,060 --> 00:00:35,160
So that's our crosshairs.
9
00:00:36,120 --> 00:00:37,680
It doesn't need to be a rakas target.
10
00:00:38,010 --> 00:00:42,720
Rakas target effectively means something that you can interact with the torch or press.
11
00:00:43,320 --> 00:00:43,650
All right.
12
00:00:43,650 --> 00:00:50,520
This is just a simple graphic that sits in the middle of the screen and not image will always stay in
13
00:00:50,520 --> 00:00:51,390
the middle of the screen.
14
00:00:51,390 --> 00:00:56,880
So as you move your going around, you basically have to rotate your camera in order to position the
15
00:00:56,880 --> 00:01:00,180
crosshairs to line up with one of these enemies.
16
00:01:01,200 --> 00:01:03,720
So let's call it crosshairs.
17
00:01:05,490 --> 00:01:05,850
OK.
18
00:01:05,880 --> 00:01:12,390
And it's default material is UI default, which I think should actually be fine.
19
00:01:13,590 --> 00:01:14,050
And.
20
00:01:17,960 --> 00:01:23,900
Yeah, it's a specific material that's designed specifically for YUAI, so it should be fine.
21
00:01:24,590 --> 00:01:24,980
OK.
22
00:01:26,090 --> 00:01:26,660
And.
23
00:01:28,690 --> 00:01:36,190
Now, we also need a sound that when we fired the gun, we can hear the sound of the gunfire, so in
24
00:01:36,190 --> 00:01:39,760
the sound effects of got a sound file called gunshot.
25
00:01:39,910 --> 00:01:40,330
All right.
26
00:01:40,900 --> 00:01:46,660
With this, just make sure that you click on the Android icon and click override for Android.
27
00:01:47,650 --> 00:01:47,920
All right.
28
00:01:47,920 --> 00:01:52,320
So really small file and it is a dot wav file.
29
00:01:52,330 --> 00:01:53,830
So I whv.
30
00:01:55,120 --> 00:01:55,600
OK.
31
00:01:56,920 --> 00:01:58,500
This one means it's uncompressed.
32
00:01:59,590 --> 00:02:03,220
Sometimes when you bring some files into the MP three, they're already compressed.
33
00:02:04,030 --> 00:02:10,420
What happens is the mobile just decompress the file to turn it into something like a wave or something.
34
00:02:10,690 --> 00:02:15,040
And then there's the re compress it into Vorbis.
35
00:02:15,430 --> 00:02:15,880
OK.
36
00:02:15,910 --> 00:02:19,660
Which is quite effective for mobiles and belief.
37
00:02:20,230 --> 00:02:23,500
Or you could even just choose an PS3 is entirely up to you.
38
00:02:24,010 --> 00:02:29,100
And whereas if you've got a wave file, basically it doesn't have to decompress it.
39
00:02:29,100 --> 00:02:31,270
It only has to it only has to compress it.
40
00:02:31,570 --> 00:02:32,980
So you actually save in time.
41
00:02:33,710 --> 00:02:36,850
And that works for small sound files.
42
00:02:37,240 --> 00:02:42,630
If you've got like a really big sound, like a background music, don't don't import that as a way.
43
00:02:42,730 --> 00:02:46,180
It's going to be absolutely massive and it's going to increase your file size.
44
00:02:46,600 --> 00:02:52,480
You would obviously have as an MP three, and you would just instead of decompress and load on that
45
00:02:52,480 --> 00:02:55,450
one, you would simply stream a really, really large file.
46
00:02:56,350 --> 00:02:56,810
OK.
47
00:02:57,340 --> 00:02:58,810
So on the.
48
00:02:59,500 --> 00:02:59,940
Oh, yeah.
49
00:03:00,280 --> 00:03:02,850
Apply that to the sound.
50
00:03:02,970 --> 00:03:03,970
So now it's changed.
51
00:03:04,570 --> 00:03:10,390
And I think what they'll do is actually apply this to the parent.
52
00:03:10,540 --> 00:03:15,040
I think I'm going to click add component and choose audio.
53
00:03:15,050 --> 00:03:24,640
So you've got audio source and then basically drag this gunshot sound directly into the audio clip file.
54
00:03:25,030 --> 00:03:28,750
Don't play it on the way and don't loop could have to the sound.
55
00:03:28,750 --> 00:03:31,630
So I don't often mess around with any of these settings.
56
00:03:32,740 --> 00:03:36,130
And then basically we can then call out inside of the script.
57
00:03:38,440 --> 00:03:41,020
OK, so let's let's actually get into the script then.
58
00:03:41,500 --> 00:03:45,580
So under the name, let's just open this and we'll place into this one.
59
00:03:46,120 --> 00:03:49,840
And first of all, I'm just going to comment this.
60
00:03:49,840 --> 00:03:52,750
So this is shooting.
61
00:03:54,590 --> 00:04:00,470
OK, so the first thing I need is the actual Processo public type game objects.
62
00:04:00,770 --> 00:04:02,090
Well, call for us.
63
00:04:04,220 --> 00:04:04,610
OK.
64
00:04:04,880 --> 00:04:09,560
And then I need the animator of the arm so I can get it to effectively fire.
65
00:04:09,830 --> 00:04:16,780
So then I'm going to say pablic oxide animator will call arms and the.
66
00:04:19,810 --> 00:04:29,200
OK, and then obviously audio source that we've just added, so public oxide audio source will call
67
00:04:30,790 --> 00:04:32,710
gunshot sound.
68
00:04:36,240 --> 00:04:37,380
All right, there we go.
69
00:04:37,530 --> 00:04:39,210
So I'm just going to save that.
70
00:04:45,250 --> 00:04:48,920
Let's wait for that to compile, obviously.
71
00:04:49,240 --> 00:04:54,340
Script is on the ground, so we need, first of all, the crosshairs.
72
00:04:54,770 --> 00:04:56,740
So let's just drag that into that slot.
73
00:04:57,250 --> 00:05:03,340
The arms and then we'll actually be on the arms is basically going to get this on the meter, which
74
00:05:03,340 --> 00:05:05,890
is then going to be able to talk to these animations.
75
00:05:06,040 --> 00:05:08,320
It's going to be able to run these parameters.
76
00:05:10,470 --> 00:05:17,700
And so let's just drag arms around him and he automatically finds down the meter and then the gunshots
77
00:05:17,700 --> 00:05:20,880
sound is sound effects.
78
00:05:22,930 --> 00:05:24,130
Rag in the gun shop.
79
00:05:24,400 --> 00:05:26,260
Oh, sorry, not on that one.
80
00:05:26,650 --> 00:05:27,700
It's on the parent, isn't it?
81
00:05:27,710 --> 00:05:28,540
The audio source.
82
00:05:28,990 --> 00:05:31,270
And so we'll just drag.
83
00:05:35,070 --> 00:05:36,170
Oh, I'm on the canvas.
84
00:05:37,830 --> 00:05:38,220
Control.
85
00:05:38,340 --> 00:05:42,650
See you, the parent at the top, there should be no ground.
86
00:05:44,610 --> 00:05:48,240
Just drag parent into that and it finds the audio source.
87
00:05:48,460 --> 00:05:49,170
All right, excellent.
88
00:05:50,110 --> 00:05:50,910
It's safe.
89
00:05:51,360 --> 00:05:54,570
So now what we need is an actual button allows us then to fire.
90
00:05:55,110 --> 00:05:55,460
OK.
91
00:05:55,530 --> 00:05:58,020
I'm actually going to use something very similar to this.
92
00:05:58,580 --> 00:06:02,340
So on the canvas, I'm going to right click.
93
00:06:02,350 --> 00:06:06,570
I'm going to choose 3D object, sort of UI and button.
94
00:06:07,560 --> 00:06:07,830
All right.
95
00:06:07,830 --> 00:06:09,210
That gives me this little button here.
96
00:06:09,930 --> 00:06:14,880
And I want to change the graphic instead of UI Sprite.
97
00:06:15,000 --> 00:06:22,300
I actually want to go with that joystick pack sprites and handle.
98
00:06:22,650 --> 00:06:22,960
All right.
99
00:06:22,990 --> 00:06:25,860
Now I actually want this one, but without the arrows.
100
00:06:26,650 --> 00:06:32,790
OK, so if I go to a button, I can then drag this handle, react directly into the source image, and
101
00:06:32,790 --> 00:06:33,540
I get this.
102
00:06:33,630 --> 00:06:33,990
All right.
103
00:06:34,410 --> 00:06:39,930
Now, what I need to do is basically just change my width to make it a little bit smaller and then change
104
00:06:39,930 --> 00:06:40,710
the height.
105
00:06:41,370 --> 00:06:44,380
Now, technically, the button should be roughly about the same.
106
00:06:44,400 --> 00:06:49,920
So let's say 100 on the height and 100 on the width.
107
00:06:50,340 --> 00:06:51,780
We only got perfect circle.
108
00:06:52,530 --> 00:06:58,050
So now I'm just going to write this down and over to the right.
109
00:07:00,820 --> 00:07:04,300
Now we have to be careful about this one because it's over on the right hand side.
110
00:07:04,780 --> 00:07:06,580
My match up with this device.
111
00:07:07,090 --> 00:07:11,740
But then if I change to a different device, let's say, like the Apple iPod.
112
00:07:12,340 --> 00:07:13,600
Notice it's off screen.
113
00:07:13,930 --> 00:07:14,300
All right.
114
00:07:14,380 --> 00:07:15,910
Just just be careful.
115
00:07:16,690 --> 00:07:21,970
You set this one up and it's perfectly fine there.
116
00:07:24,130 --> 00:07:27,190
So you might have to go through a few of those to actually line it up.
117
00:07:27,700 --> 00:07:31,570
So what I'm going to do, I'm going to actually bring it over here a little bit.
118
00:07:32,410 --> 00:07:32,740
All right.
119
00:07:32,740 --> 00:07:34,150
So it's more in line with this.
120
00:07:34,600 --> 00:07:38,200
And I want it to anchor to be the bottom.
121
00:07:38,200 --> 00:07:38,860
Right.
122
00:07:39,160 --> 00:07:42,880
OK, so it's going to try and stick to those bottom right section.
123
00:07:51,680 --> 00:07:57,380
Since this is the smallest screen, I can get it lined up on this one and just make sure.
124
00:07:59,270 --> 00:08:00,460
Everything is fine.
125
00:08:01,410 --> 00:08:01,660
Yeah.
126
00:08:02,220 --> 00:08:07,620
Now on this, what we need to do here is safe area, and what we can see is that the Botten is outside
127
00:08:07,620 --> 00:08:08,580
of the safe area.
128
00:08:09,480 --> 00:08:14,310
Always make sure if you've got an intractable item, that does it within the safe area.
129
00:08:18,770 --> 00:08:19,040
Yeah.
130
00:08:21,140 --> 00:08:21,640
OK.
131
00:08:21,830 --> 00:08:26,810
Switch off the safe area now and yeah.
132
00:08:27,140 --> 00:08:28,550
All right, that's looking good.
133
00:08:35,800 --> 00:08:38,050
Yeah, it's looking fine on all of these, isn't it?
134
00:08:38,530 --> 00:08:41,850
So once again, just safe area up so perfectly fine.
135
00:08:41,860 --> 00:08:43,570
OK, and.
136
00:08:47,040 --> 00:08:47,280
Yeah.
137
00:08:47,760 --> 00:08:48,240
All right.
138
00:08:50,550 --> 00:08:54,090
That's the good thing about this simulator, it allows you to make sure it's going to work on all the
139
00:08:54,090 --> 00:08:54,930
different devices.
140
00:08:55,470 --> 00:08:55,780
OK.
141
00:08:56,340 --> 00:08:59,250
It does need to be a recast target because we do need to push it.
142
00:08:59,670 --> 00:09:00,150
All right.
143
00:09:00,690 --> 00:09:05,310
It's going to be a simple image and we're going to apply a color to this.
144
00:09:05,310 --> 00:09:06,900
So it's normal color.
145
00:09:06,900 --> 00:09:08,850
I actually want this to be a red color.
146
00:09:10,470 --> 00:09:16,830
Now, when you press it or highlight it, I actually want it to sort of turn to an orange.
147
00:09:17,550 --> 00:09:23,520
When you pressed it, I want it to be pretty much the same orange selected color.
148
00:09:23,700 --> 00:09:25,140
Also the orange.
149
00:09:25,650 --> 00:09:28,860
OK, so it just it just shows you that you pressed it basically.
150
00:09:29,640 --> 00:09:41,520
And now the text itself, I want this to say, shoot all uppercase the text color to be white.
151
00:09:41,880 --> 00:09:44,370
So it stands out against that red background.
152
00:09:44,760 --> 00:09:47,370
The font size would increase to about 20.
153
00:09:47,730 --> 00:09:48,840
So you can definitely see that.
154
00:09:49,260 --> 00:09:51,870
And I want the font to be bold.
155
00:09:52,080 --> 00:09:52,440
All right.
156
00:09:52,440 --> 00:09:53,670
So it really stands out.
157
00:09:55,080 --> 00:09:55,710
Excellent.
158
00:09:55,780 --> 00:09:59,100
Now, I'm just simply going to rename this as shoot button.
159
00:10:02,780 --> 00:10:04,850
There we go, and then we can access that.
160
00:10:05,150 --> 00:10:12,950
And in the script, so on the button we get an on click event whereby we can actually call a custom
161
00:10:12,950 --> 00:10:13,400
function.
162
00:10:14,000 --> 00:10:17,650
So back into the main script, what we're going to do is we're going to.
163
00:10:18,590 --> 00:10:21,470
And first of all, call our own function.
164
00:10:21,740 --> 00:10:27,830
So below the update, make sure it's definitely not inside of either the start or the update or any
165
00:10:27,830 --> 00:10:28,430
other function.
166
00:10:28,820 --> 00:10:32,600
It's got to say outside of it, but inside of the class.
167
00:10:32,600 --> 00:10:37,760
So it has to be inside of this element, definitely not below this final curly bracket.
168
00:10:38,540 --> 00:10:44,320
And so I'll say public service available from outside voit.
169
00:10:44,370 --> 00:10:45,920
Now, call it shoot.
170
00:10:47,570 --> 00:10:52,820
So give it a name that's going to make sense because it's probably going to be a lot of functions to
171
00:10:52,820 --> 00:10:53,390
choose from.
172
00:10:53,400 --> 00:10:55,970
You want instantly know exactly what it's doing.
173
00:10:57,560 --> 00:11:03,410
OK, so the first thing is we need to access the arms and get those to animate.
174
00:11:03,610 --> 00:11:07,730
So arms and then don't set trigger.
175
00:11:09,830 --> 00:11:16,760
And the trigger name that you have to put inside of quotation marks is whatever that variable was on
176
00:11:16,760 --> 00:11:17,470
arms.
177
00:11:18,440 --> 00:11:19,400
It was called fire.
178
00:11:19,880 --> 00:11:22,220
OK, so let's do that.
179
00:11:23,270 --> 00:11:25,070
That's to be spelled exactly the same way.
180
00:11:25,460 --> 00:11:31,550
So if it's got capital B capital, if it's a lowercase F lowercase, otherwise it definitely won't work.
181
00:11:32,450 --> 00:11:36,620
OK, and then we simply want this gunshot sound to play.
182
00:11:38,790 --> 00:11:40,700
Gunshots sound.
183
00:11:42,240 --> 00:11:45,720
Play don't that will simply just play that sound.
184
00:11:48,560 --> 00:11:49,200
Save that.
185
00:11:49,490 --> 00:11:53,300
And I just want to test it at the moment to make sure that it does work.
186
00:11:57,680 --> 00:12:05,690
So in a simulator with our shoot button, just want to click the plus on the long click drag in the
187
00:12:05,690 --> 00:12:11,120
ground, and that will access the script on background, which is the main script.
188
00:12:11,510 --> 00:12:13,880
And then we simply call this shoot function.
189
00:12:14,450 --> 00:12:20,520
So every time you press it button, it will basically run all of those commands.
190
00:12:20,540 --> 00:12:21,680
There's only two at the moment.
191
00:12:21,950 --> 00:12:25,010
So it should animate and play a gunshot sound.
192
00:12:25,940 --> 00:12:29,390
So let me change back to game.
193
00:12:29,690 --> 00:12:33,270
Make sure I don't check my new audio so we can actually hear this.
194
00:12:34,370 --> 00:12:34,880
And then.
195
00:12:36,510 --> 00:12:36,960
C.
196
00:12:43,040 --> 00:12:44,130
OK, there we go.
197
00:12:44,220 --> 00:12:48,800
Oh, and that's now yellow, actually, so I want that to return back to red.
198
00:12:48,830 --> 00:12:50,090
So selective color.
199
00:12:50,690 --> 00:12:56,390
I'm going to have it as that same red eye, if you want, in the exact same.
200
00:12:56,390 --> 00:12:56,690
Right.
201
00:12:56,930 --> 00:12:57,860
You can just click on this.
202
00:12:57,890 --> 00:13:06,500
You can take this code, the extra decimal control and see to paste into this one control and V to paste,
203
00:13:06,500 --> 00:13:08,480
and you'll end up with the exact same color.
204
00:13:09,860 --> 00:13:11,870
She's trying again to make sure that works.
205
00:13:24,690 --> 00:13:30,180
All right, does it does work for some reason, it was just showing me as selected, OK, and we can
206
00:13:30,180 --> 00:13:31,590
hear the gunshot sound as well.
207
00:13:31,980 --> 00:13:32,310
All right.
208
00:13:32,310 --> 00:13:33,690
So we definitely know that's working.
209
00:13:34,650 --> 00:13:40,290
So what we'll do in the next video is we'll sort out a recasting system whereby we'll shoot away from
210
00:13:40,290 --> 00:13:47,130
the gun towards the game world and we'll hit whatever character there is there and basically kill the
211
00:13:47,130 --> 00:13:48,060
anime characters.
18057
Can't find what you're looking for?
Get subtitles in any language from opensubtitles.com, and translate them here.