WEBVTT

00:00.050 --> 00:00.590
Hello guys.

00:00.590 --> 00:01.580
Welcome to the video.

00:01.580 --> 00:06.560
So in this one we're going to set up the player which is going to sort of uh you know do the setup.

00:06.560 --> 00:07.970
But we're not going to do any scripting.

00:07.970 --> 00:10.220
We're just going to prepare it for the next video.

00:10.220 --> 00:15.320
First of all, if you skipped previous section where I explained the basics of unity and C sharp, you

00:15.320 --> 00:20.900
need to know that we've got asset from the Pixel Adventure Asset Pack, which you can find on the website

00:20.900 --> 00:22.070
of Unity Asset Store.

00:22.070 --> 00:23.180
So this is how it looks.

00:23.180 --> 00:28.220
You can just find it on the Unity Asset Store, and you need to get the second one as well.

00:28.280 --> 00:29.630
That's all what we've got.

00:29.630 --> 00:34.910
Okay, now let's get back to the project and let's set up the player so we can use it in the future.

00:35.550 --> 00:37.440
I'm going to delete this game object.

00:38.650 --> 00:41.290
And I'm going to delete empty game object.

00:42.210 --> 00:46.590
And now we need to go to graphics and decide what we're going to use as a default player.

00:46.590 --> 00:49.770
I think I'm going to use a virtual guy here.

00:49.770 --> 00:51.300
We need to open idle.

00:53.600 --> 00:55.670
And just drag it here like so.

00:59.120 --> 01:00.110
Very good.

01:00.140 --> 01:03.320
Now let's rename it to.

01:03.470 --> 01:06.350
Let's do Rename animator.

01:06.350 --> 01:11.510
And I want this GameObject to be responsible for the visuals of the player.

01:11.510 --> 01:14.750
It will not have script on it, it will not have rigidbody on it.

01:14.750 --> 01:17.090
It will have only sprite renderer.

01:17.090 --> 01:23.090
And also later on we're going to add animator, which we're not going to use now, but this GameObject

01:23.090 --> 01:25.280
will be responsible only for visuals.

01:25.280 --> 01:30.980
And in the script we'll have manual control of the movement and manual control of the animations.

01:30.980 --> 01:33.710
And we're just going to update the animation when the character is moving.

01:33.710 --> 01:34.130
Okay.

01:34.130 --> 01:37.790
This is how it's going to be, so let's just have it as it is.

01:38.790 --> 01:39.150
Uh, yeah.

01:39.150 --> 01:45.480
I'm going to delete the animator here and let's click right button and click Create Empty Parent.

01:46.110 --> 01:50.280
And now this animator became a child of another GameObject.

01:50.280 --> 01:52.980
Let's name it as player over here.

01:52.980 --> 01:55.770
And I'm going to reset transforms.

01:56.770 --> 01:57.010
Okay.

01:57.010 --> 01:57.580
Very well.

01:57.580 --> 02:01.360
So now there's going to be a parent object which will be responsible for movement.

02:01.360 --> 02:04.030
It will have rigidbody collider, anything like that.

02:04.030 --> 02:09.490
And visuals will be as a child will just be there to play different animations and that's it.

02:09.490 --> 02:13.780
The only thing I want to change is to move animator above slightly.

02:13.780 --> 02:19.270
We can do it easily just by dragging this yellow arrow over here, but actually I know the value.

02:19.270 --> 02:23.620
So we can go to the transform and type here dot 25 on the Y.

02:23.770 --> 02:30.940
Now if we select the player and choose Pivot Point over here, we can see that center of the character

02:30.940 --> 02:32.500
moved down a little bit.

02:32.500 --> 02:33.790
And that's what I want to have.

02:33.790 --> 02:36.580
I want to have center of the character in the center.

02:36.580 --> 02:37.750
That's why I'm doing it.

02:37.750 --> 02:43.810
Uh, it will work fine if you keep Animator at Zero and you'll have your character center a bit higher

02:43.810 --> 02:44.260
than mine.

02:44.260 --> 02:47.680
It will work fine as well, but I suggest to do things like I do.

02:47.680 --> 02:49.090
So we have same project.

02:49.090 --> 02:49.540
Okay.

02:49.540 --> 02:49.750
Yeah.

02:49.750 --> 02:52.780
So let's go here, do 0.25 just like that.

02:52.780 --> 02:54.970
And now center is here.

02:54.970 --> 02:56.500
Pivot point is very important.

02:56.500 --> 02:59.800
It's very important to know where the position of the character is.

03:00.220 --> 03:01.090
Uh why is that.

03:01.090 --> 03:04.000
Actually let me quickly explain why is that okay.

03:04.870 --> 03:06.640
I'm going to duplicate this object.

03:07.120 --> 03:12.520
And on this version I'm going to set animator's position to zero.

03:14.460 --> 03:19.440
And again, if you don't see the center of it now, you can just click here and choose Pivot Point.

03:19.560 --> 03:24.930
Now let's imagine we want to respawn character on a checkpoint.

03:24.930 --> 03:27.150
I'm going to make checkpoint quickly here.

03:29.870 --> 03:31.640
And I'm going to make it smaller.

03:32.560 --> 03:38.440
So let's say this is the checkpoint and we place it here and we want to place character on the checkpoint.

03:38.440 --> 03:43.960
And it's very important where the center of the character is when we're doing that, because we using

03:43.960 --> 03:48.040
transform position of the character, which is a pivot point at the same time.

03:48.040 --> 03:50.260
And for this one center is here.

03:50.260 --> 03:55.630
So when we would place player on a checkpoint, we would place it with the center and he would appear

03:55.630 --> 03:56.680
like that.

03:57.040 --> 04:03.430
But if we use this character with the center point in the center on the checkpoint, it would appear

04:03.430 --> 04:04.420
like that.

04:04.780 --> 04:07.780
So that's kind of the main idea of it.

04:11.320 --> 04:12.370
So this is the setup.

04:12.370 --> 04:19.540
I have animator with a y point 25 and on the player we want to add rigidbody 2D.

04:20.310 --> 04:23.460
We want to add a capsule collider.

04:23.460 --> 04:27.030
This will be more suitable for the player because.

04:28.240 --> 04:32.380
Because if we have Collider and player will stand on the edge, he will slide down.

04:32.380 --> 04:34.300
And I like that behavior a bit more.

04:36.110 --> 04:37.640
Actually, let me show you that.

04:38.670 --> 04:43.860
We're going to go to Edit Collider and increase size of the collider to something like so.

04:47.620 --> 04:48.010
Yeah.

04:48.010 --> 04:50.140
So this will be the shape of the character.

04:50.440 --> 04:56.080
And now let's place character on the edge and see what happens.

05:00.160 --> 05:02.380
Oh, you're all done.

05:02.530 --> 05:03.220
Let's fix it.

05:03.220 --> 05:10.390
Let's go to rigid body, find constraints over here and choose Freeze Rotation Z okay.

05:11.880 --> 05:16.710
Now, if we go to play mode again, we can see that he's just sliding down, which is good.

05:16.710 --> 05:22.080
But if we would have another collider on it, for example.

05:22.080 --> 05:23.280
Box Collider.

05:25.370 --> 05:28.880
2D and this would be the shape of the character.

05:30.080 --> 05:34.700
Then player would be able to stand on the platform like so.

05:36.220 --> 05:39.400
And even like so, which I don't really like.

05:39.400 --> 05:41.560
That's why we're going to use Capsule Collider.

05:42.040 --> 05:43.780
It's the main reason for it.

05:45.530 --> 05:45.890
Okay.

05:45.890 --> 05:48.590
I've got rigid body, I've got capsule Collider.

05:48.590 --> 05:51.440
Let's add player script on this.

05:51.440 --> 05:53.180
And that's all what we need for now.

05:53.180 --> 05:58.370
I only would like to have bigger distance for the camera, because now I feel like player is kind of

05:58.370 --> 06:01.490
big, but I'm not going to downscale the player.

06:01.490 --> 06:07.430
I'll just select main camera and here on the size let's choose eight.

06:07.430 --> 06:08.990
So it will be a bit further away.

06:08.990 --> 06:10.610
All right that's good for now.

06:10.610 --> 06:13.280
Let's go to the next video and let's set up movement.
