WEBVTT

00:00.080 --> 00:03.640
Let's make the game for our mobile devices.

00:03.640 --> 00:05.960
So we need to switch to Android.

00:05.960 --> 00:09.640
But before we do, let's import some as some things.

00:09.640 --> 00:15.600
Basically, we're gonna import simple input for our mobile, uh, basically an arrow.

00:15.600 --> 00:21.840
But before we do it, uh, what we need to do, we need to move over to our sample scene or in which

00:21.840 --> 00:23.640
scene we're playing our game.

00:23.680 --> 00:29.440
To do so, let's head over to project Tab assets, and I have it inside this assets folder.

00:29.440 --> 00:33.280
So I'm going to click double click on this simple, uh sample scene.

00:33.280 --> 00:35.560
So just move over to your level scene.

00:35.880 --> 00:44.400
And once we are over here so what we want we want a left arrow a right arrow for mobile devices to touch.

00:44.440 --> 00:50.520
If we just tap on left arrow, then we want this player character to move to the left direction.

00:50.520 --> 00:56.720
And if we just click on the right arrow, then we want this player, uh, game object to move to the

00:56.720 --> 01:03.380
right direction, and we're gonna have a jump button as well as a attack button for mobile devices to

01:03.380 --> 01:03.900
do so.

01:03.940 --> 01:08.100
For what we're gonna do, we're gonna we need to import simple input.

01:08.100 --> 01:13.180
So basically head over to google.com and move over to Unity Asset Store.

01:13.220 --> 01:14.340
Right over here.

01:14.620 --> 01:18.780
And in the top part search this simple input as you can see.

01:18.980 --> 01:25.380
And as soon as you search, you're gonna get this simple input system right over here as you can notice.

01:25.780 --> 01:27.900
And I just open that up.

01:27.900 --> 01:35.540
So basically you're gonna see a add to my assets button right next to this simple input right over here.

01:35.540 --> 01:39.860
So just click on that and it's gonna add to your assets.

01:39.860 --> 01:43.340
And once you done then click on this open in unity.

01:43.340 --> 01:46.700
And then click on this Open in Unity editor.

01:46.700 --> 01:52.900
And you're gonna get redirected to your unity editor and you're gonna be in my assets.

01:52.900 --> 01:56.820
So if so, we can see we have the simple input system.

01:56.860 --> 02:00.050
And you're gonna see a install button right over here.

02:00.050 --> 02:04.010
So just click on that install button and it's gonna install.

02:04.010 --> 02:06.090
And after that click on that import.

02:06.090 --> 02:09.730
You're going to see a import right after install button.

02:09.730 --> 02:11.330
So just click on import.

02:11.330 --> 02:13.570
And in the bottom you're going to see import.

02:13.730 --> 02:19.290
So we're gonna import we can import that as well by clicking in project.

02:19.650 --> 02:22.010
And uh we already done it.

02:22.010 --> 02:24.370
So I'm going to click on this cancel button.

02:24.370 --> 02:30.530
And if you are not able to find then in the left part you're going to see in Project Unity registry

02:30.570 --> 02:32.490
my assets and built in.

02:32.490 --> 02:39.850
So select this unity my assets basically select this in the left bar says my assets and search over

02:39.850 --> 02:41.770
here simple input.

02:41.770 --> 02:43.090
And it's going to pop up.

02:43.090 --> 02:43.610
Sorry.

02:44.050 --> 02:48.370
Uh it's gonna pop up which is simple input.

02:48.370 --> 02:52.570
So as soon as we type it's just popping up as you can notice.

02:52.730 --> 02:59.990
And once you are selecting that then click on this install button and then click on this import to project

02:59.990 --> 03:03.350
and then click on this import in the bottom right you're going to see.

03:03.350 --> 03:06.150
So I hope you get the idea that how you can do it.

03:06.150 --> 03:12.870
And once we done so we can simply cut this tab right now and we can just move over to our project tab

03:12.910 --> 03:13.630
assets.

03:13.630 --> 03:17.870
And we're going to see a plugins folder right over here we can see.

03:18.070 --> 03:20.070
So you're going to see a plugins folder.

03:20.070 --> 03:23.230
Once you are just going to import your simple input.

03:23.230 --> 03:24.750
So basically what you need to do.

03:24.790 --> 03:31.430
Firstly you need to move over to this project tab assets and you're going to see this plugin folder.

03:31.430 --> 03:35.190
Then click on this arrow to select our simple input.

03:35.190 --> 03:37.870
And then click on this arrow to see.

03:37.910 --> 03:40.710
And we're going to move over to our prefabs folder.

03:40.870 --> 03:42.630
And we have many prefab.

03:42.670 --> 03:45.550
We have this arrow all direction.

03:45.550 --> 03:47.870
We have arrows horizontal.

03:47.870 --> 03:49.630
We have arrows vertical.

03:49.630 --> 03:53.630
So since we want arrow horizontal basically left and right.

03:53.630 --> 03:57.290
So we're going to select this prefab says arrows horizontal.

03:57.290 --> 04:03.330
Select that, then drag it on top of this canvas GameObject in the hierarchy, and as soon as we drag

04:03.330 --> 04:05.410
it, we can see by now in the scene view.

04:05.570 --> 04:11.650
But uh, basically we're gonna select our arrows horizontal underneath our canvas, and let's press

04:11.650 --> 04:13.850
down F in order to focus on it.

04:13.890 --> 04:19.690
Make sure you select your arrows horizontal and drag it above this canvas GameObject in the hierarchy

04:19.690 --> 04:20.650
in order to see.

04:20.890 --> 04:23.730
And we're gonna select our arrows horizontal.

04:23.730 --> 04:28.570
And we can just, uh, make it bigger a little bit, something we can hold down.

04:28.570 --> 04:30.610
Also, it's going to resize from center.

04:30.610 --> 04:38.290
Or we can just, uh, we can just, uh, pull up our finger from that alt key to see this.

04:38.290 --> 04:39.570
As you can notice.

04:39.770 --> 04:42.610
And I want to replace this, uh, button arrow.

04:42.610 --> 04:47.410
Basically I want to change with square and this arrows as well.

04:47.610 --> 04:52.730
To do so we can just, uh, select right over here, but we can just click, uh.

04:52.730 --> 04:54.730
But before we do, let's have a look.

04:55.350 --> 05:00.190
So I'm going to click on this play button in the top in order to play our game.

05:00.190 --> 05:06.590
And if we try to click this left or right arrow you will able to notice our player game object.

05:06.630 --> 05:08.510
Not gonna move at all.

05:08.510 --> 05:09.990
So we need to move that.

05:09.990 --> 05:12.630
But before we do, let's have a look on it.

05:13.630 --> 05:14.950
Uh, have a look on it.

05:14.950 --> 05:22.430
So if I just click on this right arrow, we can see our player is not moving at all in the right direction

05:22.430 --> 05:24.510
as well as this left arrow.

05:24.630 --> 05:26.150
So we need to do that for it.

05:26.190 --> 05:29.630
What we basically have to do we need to get out of play mode.

05:29.630 --> 05:34.590
And we need to open up our player script where we just are moving our player.

05:34.590 --> 05:37.550
So we do know that we are doing inside our player.

05:37.550 --> 05:40.110
So we're going to select our player game objects.

05:40.350 --> 05:42.030
Uh, right over here.

05:42.270 --> 05:45.470
Other stuffs I have the player inside.

05:45.470 --> 05:48.070
So select your player game object in the hierarchy.

05:48.310 --> 05:51.470
Then open up your player script by double clicking on it.

05:51.750 --> 05:58.140
And what we need to do now we need to basically use a we need to use simple input.

05:58.140 --> 06:01.340
So just wait a moment to open up our script.

06:01.500 --> 06:05.300
And once we just gonna open up, we're just gonna link that up.

06:05.300 --> 06:11.940
So if we move over to update function, as you can notice right over here, we using this moment equal

06:11.940 --> 06:14.620
to input dot get axis horizontal.

06:14.620 --> 06:21.300
So this movement parameter right over here is responsible for moving our player to left and right.

06:21.300 --> 06:24.740
And we doing input dot get axis horizontal.

06:24.860 --> 06:28.220
Sorry I don't know why are we getting some errors.

06:30.700 --> 06:32.820
So we're getting some errors.

06:34.460 --> 06:37.180
Uh so basically it's uh fine.

06:37.580 --> 06:39.300
Just I'll need a moment.

06:39.300 --> 06:40.940
So it's fine by now.

06:41.180 --> 06:44.100
So we created this movement right over here.

06:44.100 --> 06:49.780
Private float movement parameter, which is responsible for moving our player left and right.

06:49.780 --> 06:55.600
And we can see right over here we just setting it equal to input dot get axis horizontal.

06:55.760 --> 06:59.280
And we do know that this input dot get axis horizontal.

06:59.600 --> 07:05.320
Uh, it's gonna just take if we press down a key on our keyboard, that means this is just going to

07:05.320 --> 07:11.360
be minus one means this movement right over here just going to be minus one means our player just going

07:11.360 --> 07:12.920
to move to the left direction.

07:13.120 --> 07:15.960
And if we press down D key then it's going to be one.

07:15.960 --> 07:18.840
So this movement over here it's going to be one.

07:18.840 --> 07:22.520
So our player will start moving to the right direction.

07:22.520 --> 07:24.800
So what we're gonna do we're gonna leave this.

07:24.800 --> 07:29.120
And now we're going to check we we're gonna use simple input for that.

07:29.440 --> 07:32.360
For this basically we need to type this simple input.

07:32.360 --> 07:35.400
So make sure you type this simple input.

07:35.400 --> 07:38.800
And we can use the same function which is dot get axis.

07:38.800 --> 07:42.840
So we're going to use this dot get axis get axis.

07:42.840 --> 07:49.320
And this in quotation it's going to take the axis in which axis you just want to move your player.

07:49.320 --> 07:54.500
So since we want to move our player Horizontally flow a left or right.

07:54.660 --> 07:57.020
So that's why we're going to use this horizontal.

07:57.060 --> 07:58.900
Basically doing the same things.

07:58.900 --> 08:02.500
So we're going to do the same thing for horizontal.

08:02.500 --> 08:04.460
And make sure you spelling it correct.

08:04.460 --> 08:06.740
And then close that off with semicolon.

08:06.740 --> 08:09.580
So this simple input dot get axis horizontal.

08:09.620 --> 08:14.700
It can be minus one plus 1 or 0 depending upon which arrow we pressing.

08:14.700 --> 08:19.900
Let's suppose we are clicking on this or we or just touching our left arrow.

08:19.940 --> 08:23.180
Then this function right over here it's going to be minus one.

08:23.380 --> 08:27.860
And if we just press down the right one then it's going to give plus one.

08:27.860 --> 08:35.220
And if we just don't tap on tap both of these arrows basically both of this button then this simple

08:35.220 --> 08:36.820
input dot get access.

08:36.860 --> 08:38.860
It's going to give us zero value.

08:38.860 --> 08:44.450
So what we're gonna do we're gonna store it into this movement parameter which can be plus one, -1

08:44.450 --> 08:45.380
or 0.

08:45.620 --> 08:49.980
So what we're going to do we're going to store the result into this movement parameter.

08:49.980 --> 08:56.440
So we're going to say sorry, uh, movement, movement equal to this.

08:56.440 --> 09:02.680
So this movement is just going to be minus one or plus 1 or 0, depending upon which key we're clicking.

09:02.680 --> 09:05.920
If we're clicking the right one then it's going to give one.

09:05.960 --> 09:12.160
Then if we click the left one then it's going to give the minus one means our player.

09:12.160 --> 09:19.200
And over here as you can notice, we're just replacing the x with our x axis with our movement which

09:19.200 --> 09:25.440
can be minus one plus 1 or 0 means if we press down, the right arrow means this player just gonna move

09:25.440 --> 09:26.880
to the right direction.

09:26.880 --> 09:32.040
And if we click the left arrow, then this player will start moving to the left direction.

09:32.160 --> 09:39.320
Basically, we're doing the same thing as we have done earlier with this input dot get axis for our

09:39.320 --> 09:39.720
PC.

09:40.000 --> 09:45.720
And basically we just need to use this simple input dot get axis horizontal for our mobile.

09:45.720 --> 09:46.920
And that's all.

09:47.120 --> 09:49.080
So I hope you get the idea.

09:49.080 --> 09:54.390
So this movement just going to be minus one plus 1 or 0 in the mobile as well.

09:54.390 --> 09:59.590
If we just click or tap on this left or right arrow or buttons.

09:59.590 --> 10:02.550
And now we're going to press down Ctrl S to save our skip.

10:02.550 --> 10:04.590
And now let's move over to unity.

10:04.590 --> 10:06.750
And you will be able to notice that.

10:06.750 --> 10:07.990
So just wait a moment.

10:08.390 --> 10:12.950
And if we click the left one or right one we're going to be able to notice.

10:12.950 --> 10:18.830
So if we just go ahead and then click on the left arrow, then we're going to start moving to the left

10:18.830 --> 10:19.630
direction.

10:19.630 --> 10:24.710
And if we click on the right arrow then we're gonna start moving to the right direction.

10:24.710 --> 10:31.630
And if we don't click or tap or both of these arrows, then our then movement is going to be zero means

10:31.630 --> 10:36.670
our player just gonna stand at one point and it's not gonna move at all.

10:36.870 --> 10:38.270
So let's have a look.

10:38.270 --> 10:42.870
So I'm going to click on this play button in the top in order to play our game.

10:42.870 --> 10:45.070
And now let's have a look on this.

10:49.130 --> 10:50.690
So just wait a moment.

10:52.370 --> 10:52.930
Sorry.

10:53.930 --> 11:00.650
And now if we click the right arrow, we can see our player started moving to the right direction.

11:00.650 --> 11:07.010
And if we click the left arrow or hold down the left arrow, we can see our player is started moving

11:07.050 --> 11:08.290
to the left direction.

11:08.330 --> 11:10.410
Basically, it's working fine.

11:10.610 --> 11:16.530
And means if you just check that out in your mobile, you can do that as well.

11:16.850 --> 11:19.810
And I'm gonna tell you how you can do it.

11:19.810 --> 11:25.170
And for now it let's, let's leave it like this and let's get out of play mode.

11:25.170 --> 11:30.610
And we're gonna do the testing, testing on our mobile devices as well.

11:31.130 --> 11:33.490
Uh, but before we do, we're gonna do these things.

11:33.490 --> 11:39.930
We're gonna just make all the buttons to do, uh, to make the functions, uh, or basically to move

11:39.930 --> 11:40.810
the player.

11:40.810 --> 11:43.250
And I want to change the arrow icon.

11:43.250 --> 11:47.010
Basically, I want square type instead of circle to do.

11:47.010 --> 11:52.070
So what we basically need to do, we need to move over to our hierarchy than canvas.

11:52.070 --> 11:55.670
And then we're going to move over to these arrows horizontal prefab.

11:55.990 --> 11:58.350
Then we're going to select the left or right.

11:58.590 --> 12:00.150
You can select any of them.

12:00.670 --> 12:02.230
Basically we just want to change.

12:02.230 --> 12:03.070
So that's why.

12:03.230 --> 12:05.310
So firstly I'm going to choose the left one.

12:05.310 --> 12:10.710
So make sure you click right over here arrows horizontal and then choose any of them.

12:10.710 --> 12:13.630
So I'm gonna do I'm gonna start with the left one.

12:13.630 --> 12:14.870
So I'm gonna select that.

12:14.870 --> 12:19.030
And after doing that I'm going to move over to my project tab assets.

12:19.030 --> 12:22.310
And then I will head over to my sprites folder.

12:22.310 --> 12:25.070
And then I'm going to head over to my UI folder.

12:25.230 --> 12:30.390
And I have if I scroll down, as you can notice I have a square sprite.

12:30.390 --> 12:32.270
So I'm going to select my left button.

12:32.270 --> 12:33.430
So let's select that.

12:33.430 --> 12:36.990
Then go over to Inspector then Image component in the bottom.

12:36.990 --> 12:44.070
And you need to drag the right sprite right over here with with with which one you just want to replace

12:44.070 --> 12:44.510
with.

12:44.750 --> 12:47.140
So since why I want this square one.

12:47.140 --> 12:49.700
So I'm going to select that and let's drag it there.

12:49.940 --> 12:54.300
And as soon as we drag it as you can notice it just gets changed.

12:54.340 --> 12:58.100
But the problem is that we're not able to see our arrow.

12:58.100 --> 13:02.180
So top of this left we're going to add the image icon.

13:02.180 --> 13:04.540
Basically you can simply say that.

13:04.540 --> 13:06.900
So we're going to select our left arrow.

13:07.220 --> 13:08.100
Let's select that.

13:08.100 --> 13:12.540
Let's right click on it and let's go to GUI and then image in the top.

13:12.540 --> 13:14.020
And we're going to select this image.

13:14.020 --> 13:17.220
And we can call this image to something like icon.

13:17.220 --> 13:24.260
And make sure you do inside this left icon basically inside this square we want that arrow icon.

13:24.260 --> 13:27.460
So that's why we just right click it on this left arrow.

13:27.460 --> 13:30.060
And then we have chosen the image component.

13:30.060 --> 13:32.100
And I'm going to change it with icon.

13:32.100 --> 13:34.020
Basically I'm going to call it icon.

13:34.220 --> 13:37.820
And if we move over to Inspector basically select the icon.

13:37.820 --> 13:40.180
Then go over to Inspector Image Component.

13:40.180 --> 13:41.900
And we can drag the sprite.

13:41.900 --> 13:44.780
Basically we need to drag the sprite right over here.

13:44.780 --> 13:46.440
So I'm going to select the left one.

13:46.440 --> 13:50.280
As you can notice, I have it inside my, uh UI folder.

13:50.280 --> 13:51.680
So I'm going to choose that one.

13:51.680 --> 13:54.240
And let's drag it over to the source image field.

13:54.360 --> 13:57.040
And as soon as we drag it now this is fine.

13:57.160 --> 14:03.040
And I want to resize this arrow icon as the size of my square.

14:03.040 --> 14:09.760
So what I'm gonna do I'm gonna select my icon, then go over to Inspector Transform and then click over

14:09.760 --> 14:10.320
here.

14:10.320 --> 14:12.640
And we're going to hold down alt on our keyboard.

14:12.640 --> 14:16.680
And we're going to select this bottom right one to make the size of it.

14:16.720 --> 14:20.440
Uh as our square button.

14:20.480 --> 14:24.000
As you can notice, it's kind of seems a little bit bigger.

14:24.000 --> 14:25.920
So we can just make it smaller.

14:25.920 --> 14:29.360
So what we can do, we can just go over to drag transform.

14:29.360 --> 14:34.400
And from the left side we can do 100, uh, or we can do something like ten.

14:34.440 --> 14:37.520
I guess doing 20, it's going to be fine.

14:37.520 --> 14:40.520
Let's do it 5050.

14:40.560 --> 14:42.240
Let's do 40.

14:42.680 --> 14:45.220
And from the right side we're going to do the same thing.

14:45.260 --> 14:48.660
40 and from the top I'm going to do ten.

14:48.700 --> 14:50.700
Let's do it 40 instead.

14:50.700 --> 14:52.500
So it's going to be square type.

14:52.500 --> 14:56.660
And if at the bottom we can do 40 as well.

14:56.660 --> 14:59.900
And now as you can notice it seems pretty much fine.

14:59.900 --> 15:01.500
Or what you can simply do.

15:01.540 --> 15:07.060
You can select your icon and you can hold down alt on your keyboard to resize it from center.

15:07.060 --> 15:07.860
Like this.

15:08.300 --> 15:09.340
As like this.

15:09.340 --> 15:12.540
You can do this as well, or you can just put the value.

15:12.540 --> 15:21.260
So I'm going to do 40 and 40 in the top from the top 40 in the from the bottom and 40 from the right.

15:21.260 --> 15:25.260
And now it seems square type and this much this is pretty cool.

15:25.420 --> 15:28.140
And we're going to do the same thing with the right arrow.

15:28.140 --> 15:29.220
So let's do that.

15:29.220 --> 15:31.540
So let's select the right arrow.

15:31.660 --> 15:33.420
Uh sorry right button.

15:33.420 --> 15:36.220
Let's go over to Inspector then image component.

15:36.220 --> 15:37.780
So we need to drag the sprite.

15:37.780 --> 15:39.300
So I'm going to select my square.

15:39.340 --> 15:40.580
Let's drag it there.

15:40.940 --> 15:46.280
And we need to put the icon or basically the arrow right arrow icon to do so.

15:46.320 --> 15:47.600
Let's select our right.

15:47.880 --> 15:48.720
Right button.

15:48.720 --> 15:49.960
Let's right click on it.

15:49.960 --> 15:53.000
Let's go to UI then image component in the top.

15:53.160 --> 15:55.840
Basically basically we're gonna do the same thing.

15:56.000 --> 15:59.480
And now we're gonna call this one icon instead image.

15:59.480 --> 16:01.000
So let's call it icon.

16:01.320 --> 16:03.040
And we need to drag the sprite.

16:03.040 --> 16:04.880
So let's select that.

16:04.880 --> 16:09.200
Let's drag it over here and make sure you go over to Rect Transform.

16:09.320 --> 16:15.400
And then click right over here and hold down alt on your keyboard and select this bottom right one.

16:15.400 --> 16:23.480
And as soon as we have chosen that we can see this does get size of our square button.

16:23.720 --> 16:25.360
So we want the same thing.

16:25.360 --> 16:27.680
So from the left we're going to do 40.

16:27.880 --> 16:32.280
From the right we're gonna do 40 from the top we're gonna do 40.

16:32.560 --> 16:34.760
And from the bottom we're gonna do 40.

16:34.920 --> 16:40.760
And once you are done then you, you can simply just move over to your parent game object, then go

16:40.760 --> 16:45.110
over to Inspector Overrides and then click on this apply all.

16:45.110 --> 16:47.670
So the changes you made, it's going to be fine.

16:47.670 --> 16:51.710
As you can notice this, uh, this seems pretty much cool by now.

16:51.870 --> 16:57.590
And if we just go ahead and then click on this play button in the top, it should work fine.

16:57.590 --> 17:03.470
So if we click on this or just tap on this right arrow, then this player just going to move to the

17:03.470 --> 17:04.550
right direction.

17:04.550 --> 17:11.190
And if we just click on this left arrow then this player just gonna start moving to the left direction.

17:11.190 --> 17:12.310
So let's have a look.

17:12.350 --> 17:17.670
As you can notice uh we can see and the buttons basically working fine.

17:17.670 --> 17:20.830
And you can just do these things in your mobile.

17:21.070 --> 17:24.070
And we're going to have a look on that later as well.

17:24.070 --> 17:30.670
That how we can check with our mobile, uh, basically live in the mobile.

17:31.150 --> 17:32.750
So I hope you get the idea.

17:32.750 --> 17:39.310
So I'm gonna get out of play mode and I'm gonna press down Ctrl s on my keyboard to save my project.

17:39.310 --> 17:42.150
So I hope you get the idea that how you can do it.
