Hello guys.
Welcome to the video.
So in this one we're going to set up the player which is going to sort of uh you know do the setup.
But we're not going to do any scripting.
We're just going to prepare it for the next video.
First of all, if you skipped previous section where I explained the basics of unity and C sharp, you
need to know that we've got asset from the Pixel Adventure Asset Pack, which you can find on the website
of Unity Asset Store.
So this is how it looks.
You can just find it on the Unity Asset Store, and you need to get the second one as well.
That's all what we've got.
Okay, now let's get back to the project and let's set up the player so we can use it in the future.
I'm going to delete this game object.
And I'm going to delete empty game object.
And now we need to go to graphics and decide what we're going to use as a default player.
I think I'm going to use a virtual guy here.
We need to open idle.
And just drag it here like so.
Very good.
Now let's rename it to.
Let's do Rename animator.
And I want this GameObject to be responsible for the visuals of the player.
It will not have script on it, it will not have rigidbody on it.
It will have only sprite renderer.
And also later on we're going to add animator, which we're not going to use now, but this GameObject
will be responsible only for visuals.
And in the script we'll have manual control of the movement and manual control of the animations.
And we're just going to update the animation when the character is moving.
Okay.
This is how it's going to be, so let's just have it as it is.
Uh, yeah.
I'm going to delete the animator here and let's click right button and click Create Empty Parent.
And now this animator became a child of another GameObject.
Let's name it as player over here.
And I'm going to reset transforms.
Okay.
Very well.
So now there's going to be a parent object which will be responsible for movement.
It will have rigidbody collider, anything like that.
And visuals will be as a child will just be there to play different animations and that's it.
The only thing I want to change is to move animator above slightly.
We can do it easily just by dragging this yellow arrow over here, but actually I know the value.
So we can go to the transform and type here dot 25 on the Y.
Now if we select the player and choose Pivot Point over here, we can see that center of the character
moved down a little bit.
And that's what I want to have.
I want to have center of the character in the center.
That's why I'm doing it.
Uh, it will work fine if you keep Animator at Zero and you'll have your character center a bit higher
than mine.
It will work fine as well, but I suggest to do things like I do.
So we have same project.
Okay.
Yeah.
So let's go here, do 0.25 just like that.
And now center is here.
Pivot point is very important.
It's very important to know where the position of the character is.
Uh why is that.
Actually let me quickly explain why is that okay.
I'm going to duplicate this object.
And on this version I'm going to set animator's position to zero.
And again, if you don't see the center of it now, you can just click here and choose Pivot Point.
Now let's imagine we want to respawn character on a checkpoint.
I'm going to make checkpoint quickly here.
And I'm going to make it smaller.
So let's say this is the checkpoint and we place it here and we want to place character on the checkpoint.
And it's very important where the center of the character is when we're doing that, because we using
transform position of the character, which is a pivot point at the same time.
And for this one center is here.
So when we would place player on a checkpoint, we would place it with the center and he would appear
like that.
But if we use this character with the center point in the center on the checkpoint, it would appear
like that.
So that's kind of the main idea of it.
So this is the setup.
I have animator with a y point 25 and on the player we want to add rigidbody 2D.
We want to add a capsule collider.
This will be more suitable for the player because.
Because if we have Collider and player will stand on the edge, he will slide down.
And I like that behavior a bit more.
Actually, let me show you that.
We're going to go to Edit Collider and increase size of the collider to something like so.
Yeah.
So this will be the shape of the character.
And now let's place character on the edge and see what happens.
Oh, you're all done.
Let's fix it.
Let's go to rigid body, find constraints over here and choose Freeze Rotation Z okay.
Now, if we go to play mode again, we can see that he's just sliding down, which is good.
But if we would have another collider on it, for example.
Box Collider.
2D and this would be the shape of the character.
Then player would be able to stand on the platform like so.
And even like so, which I don't really like.
That's why we're going to use Capsule Collider.
It's the main reason for it.
Okay.
I've got rigid body, I've got capsule Collider.
Let's add player script on this.
And that's all what we need for now.
I only would like to have bigger distance for the camera, because now I feel like player is kind of
big, but I'm not going to downscale the player.
I'll just select main camera and here on the size let's choose eight.
So it will be a bit further away.
All right that's good for now.
Let's go to the next video and let's set up movement.