We will make the parallax effect.
So in order to make that, we need to drag our backgrounds.
To do so let's head over to our project tab, then assets.
And then I will move over to my sprites folder, then environment folder and then backgrounds folder.
Of course I will give a link in the description or of sorry not in description.
You can find it in the resources so you can check that out.
So we can select one by one and drag it over to the scene view or into this hierarchy.
So I'm going to select this sky one.
So let's drag it into this in view.
As you can notice it seems too much small and within.
We need to make it bigger to to make it bigger, we will select all of these individual sprites of this
background, then go over to Inspector and Sprite mode to choose.
Choose a single instead of multiple.
Because we have individual sprite, we don't have multiples like that.
We basically we need to split.
We don't need to split.
So that's why in this moment, we just choose a sprite mode to single and pixel per unit.
We're going to make it something around 16.
So we do know that if we make this less, our sprite is going to be large in size, and to get rid of
blurry, we need to choose filter mode to point of filter in the bottom, and then click on this apply
button in the bottom right.
And as soon as we're going to click on it, you will notice that.
So we not able to see for somehow so what we're going to do I'm going to select that and let's delete.
We're going to select the sprite one more time and let's drag it over to the scene view.
Or in this hierarchy.
As you can notice, as soon as we drag it we can see our background, but it still seems a little bit
small.
So we can just make it a little bit bigger.
And basically to make our pixel per unit less, let's basically means, uh, b that's the sprite just
going to be large in size.
So we will select all of these sprite one more time by holding down shift.
Then go over to Inspector and Pixel per unit.
Let's make it something around eight and then scroll down and let's click on this apply button in the
bottom right.
And now we can see that seems pretty much cool, but we need to fit it perfectly.
But before I do I'm going to select my sky or this background in the hierarchy.
Then go over to Inspector, right click on this transform and then reset.
So it's going to reset the all of the position.
And we can just drag it a little bit down.
But I don't want to do that.
I just want to make it a little bit smaller.
Basically this background background or this sky.
So let's select one more time all of this sprite.
Let's go over to Inspector and let's make this pixel per unit something around ten.
Instead of putting eight we're going to do it ten.
Let's click on this apply button one more time.
And now that seems pretty much fine.
And I'm going to select my background basically this sky.
And let's select the move tool in the hierarchy sorry move tool in the scene view.
And we're going to move it somewhere over here to just fill it the area.
You can simply say, and we need to drag all of this background one by one.
So I'm going to select the clouds.
Let's drag it over to this in view or into this hierarchy.
So let's drag it into the scene view.
As you can notice this seems pretty much cool.
But I guess if we make our sprites a little bit small, it's gonna be fine.
So we can just go ahead with 16 pixel per unit.
So let's select one more time.
All of this.
Let's go over to Inspector.
Let's make pixel per unit 16.
And let's click on this apply button.
And now this seems pretty much fine.
And we can just arrange that.
Before I arrange we need to place this layer.
Basically we don't want this sky background uh far from our player game object or from this main camera.
Or you can simply say, we want this layer to be all the way behind.
So we need to assign some sorting layer.
So I'm going to choose my sky sky in the hierarchy.
Then go over to Inspector Sprite Renderer then additional settings sorting layer.
So let's click there and let's click on this add sorting layer.
So let's create some sorting layer for our backgrounds.
So this will be sky.
So let's click on this plus icon in Inspector Sorting Layer.
And let's call this one background.
Or we can simply call this one sky.
So let's call it sky instead.
And let's create one for our clouds.
So let's create four clouds and one for we're going to create four rocks I guess uh, to check that
out I'm going to move over to my sprites folder environment, then backgrounds.
And let's check the name.
So we have crops and grass and rocks.
So let's create two other uh sorting layer.
So this is just going to be grass.
And then we're going to add one more sorting layer.
And we're going to name this one to something like rocks uh rocks or stones.
And we want this sky all the way behind uh all the way behind.
That's why we're going to drag it in the top.
Then I want the clouds, then I want the rocks, and then I want the grass.
So this grass layer will be all the way up, and this sky layer will be all the way behind.
So we need to assign with this sky with our sky sorting layer.
So we will choose our sky game object in the hierarchy or sky background.
Then go over to Inspector Sprite Renderer.
As sorting layer we're gonna choose assign with Sky.
And now we're going to choose our clouds.
And we're gonna assign with sorting layer clouds.
So let's click on the sorting layer and you need to choose the sorting layer.
And now we're gonna drag our this grass.
So let's drag it into this in view or into this hierarchy like that.
And we're gonna assign this grass as a grass sorting layer.
And now let's choose the rock.
Let's drag it into this in view.
And let's assign with our rocks.
Sorry.
Uh, we want the ground, uh, top of this grass, I guess.
So we're gonna choose our grass.
Sorry, this is not grass.
Basically this mountain, I really apologize.
So we can just rename this sorting layer.
To do so.
Let's click on it.
Let's click on Add Sorting Layer.
And you can just name the sorting layer.
So we're gonna call it something like Rouse Mountain like that.
Uh like that I really apologize if I miss spelling misspelling that I really apologize for it.
Mountains.
And we're gonna assign with Grass Mountain.
And now this is fine.
And for this Rocks Mountain, we're gonna choose rocks.
And now that's basically cool.
cold, and we will select all of these sprites by holding down shift in the hierarchy.
Then go over to Inspector.
Right click on this transform and then reset.
So it's going to reset the position.
And we need to duplicate this background to duplicate.
But before we do we're going to create an empty parent game object.
And we will drag all of this background into that game object in order to make our hierarchy a little
bit clean.
So that's why we're going to do that.
To do it, let's go over to hierarchy.
Right click or hit this plus icon.
Then create an empty game object sorry.
And create an empty game object.
And we're going to call this game object to something like backgrounds.
So let's call it backgrounds backgrounds.
Then go over to Inspector Transform.
Let's right click there and then reset.
And we will select all of this background.
Basically this sky, clouds, grass mountain rocks mountain and then drag it over top of this background
game object.
And now if we select our backgrounds, we can move it anywhere we want.
As you can notice.
So I'm going to reset the position to zero zero.
So let's set back to zero in the x, zero in the y.
And now we need to duplicate.
But before we duplicate we need to do some settings.
Basically I want to drag this grass mountain a little bit up as well as the rocks.
So let's click over here.
But before you do make sure you just select your backgrounds game object and then make that one a prefab.
So you're gonna have the copy.
And you don't need to work from scratch or you don't need to start over.
So make sure you just make your backgrounds a prefab.
So let's select our backgrounds GameObject in the hierarchy, and let's drag it over to this prefabs
folder in order to turn it into a prefab, basically a copy.
So that's why we created an empty parent GameObject first.
And then we just made this sky, clouds, grass, mountains, rock, mountains style of that game object.
And I'm going to select my grass mountain and let's select the move tool in the scene view.
And let's move it up in the y axis, something like this much.
And we're going to select our rock mountains.
Let's drag it in the y little bit up.
Then we're gonna choose our clouds and let's move it up.
And then sky background something like this.
Much as you can notice, and this already seems pretty much cool.
And now what we have to do, we need to duplicate this, uh, background in order to fill our area.
So we're going to select all of this background.
Basically don't select the parent.
So don't select this background.
Instead select the child's basically sky clouds ground grass mountain rocks mountain.
And then press down Ctrl D in order to duplicate.
And you can move it over to the left side or into the right side.
So I'm going to move it over to my left side.
Something around I guess -19 or -20 seems perfect number.
And if we scroll our mouse to zoom in, we can notice it seems pretty much fine.
So now what you have to do.
You need to make sure you select the duplicate one, and then drag it over to top of the first one.
Basically, make the duplicate child of the first one.
So I'm going to select my sky one and let's drag it over to the sky.
And we're going to do the same thing with this glass clouds across mountains and rock mountains.
So let's select these clouds.
Let's drag it over to clouds, then Grass Mountain and then rock mountains.
And now this seems pretty much cool.
And we also need to do in the you can simply say in the right side as well as in the left side.
We already done it.
And we're going to make it a little bit something like that.
But before we do, make sure you select your parent game object.
Then go over to Inspector Overrides and then apply all.
So the changes you made inside this background game object, it's gonna save into this background scheme
object prefab as well.
Now let's deal with the right side.
So what we're going to do now we're going to select our child.
That which we duplicate it.
We're going to select all of them by holding down control.
So let's select this sky one then clouds one then grass mountains one and then this rock mountains one.
And we can simply press down Ctrl D to duplicate.
And now we're going to move over to the right side which will be plus 20.
So the left one was something around -20.
So in the positive side it should be 20 plus 20.
So let's move it 20.
And now as you can notice it fits perfectly.
And you can select one more time and then you can just duplicate.
So I'm going to duplicate one more time.
So I'm going to select the duplicate one.
So let's select duplicate one not the parent.
So select duplicate one.
Let's press down Ctrl D in order to duplicate.
And let's move it over to in the X, something like 40.
We need to move that since this is 20.
So this position over here is gonna be 40.
So what we're going to do now, we're going to put 40 and we can sorry not 50.
We're gonna do 40.
And we can duplicate this one more time by Ctrl D.
And now sorry we're going to choose the duplicate one.
So let's choose the duplicate one.
And let's press down one more time Ctrl D to duplicate.
And we're going to move it over something over here.
So it should be 40 plus 20 which is 60.
So we need to put 60 right over here.
Or you can simply select your move tool from this in view.
And you can just simply drag it in the right side.
But instead of doing that you can just approach in this way and it's going to be fine.
So I hope you get the idea that how you can do it, and we need to make the parallax effect as well.
So before we do that, let's select our parent game object.
So I'm going to click on this in order to collapse and make sure you select your parent game object
which is in my case backgrounds.
And make sure you just turn it into a prefab so you will have the copy.
So I'm going to select my background game objects, then go over to Inspector Overrides and then apply
all.
So that's why I just created an empty parent game object first.
And then I just place all of those backgrounds into this backgrounds game object to make it a prefab,
and it's gonna save a lot of time.
So that's why.
And now we are ready to we basically ready to make our parallax effect.
And in order to make the parallax effect, firstly we need to choose our main camera.
Make sure you choose that.
Then go over to Inspector, then camera component and over here projection.
As you can notice it says orthographic.
So we need to choose perspective.
And as soon as we choose perspective now it's going to make the parallax effect.
But what we basically want, we want to move this green mountain a little bit faster.
If our player moving is left and right, and we want to move this rock mountains a little bit slower
as compared to the Grass Mountain, which is just gonna be closer to our player game object.
If any background is far away from this player game object or from this main camera, then we want that
background to move slowly as compared to the close one.
So we want the sky to move a little bit slowly.
So what we basically need to do, we need to drag our sky sky in the z axis little bit further away.
So how you can do that in this scene view top bar you can see uh, 2D right over here in the top bar
in scene view you can see 2D.
So just click on it and you can hold down alt on your keyboard, and you can just move your mouse in
order to take a look around this.
As you can notice that all of the backgrounds in the same position in the z axis.
So what we need to do when we're gonna drag our scribe background far, far, far from this player game
object, or from this camera, from this camera.
So it's gonna move slowly as compared to the close one.
For to do that, we're gonna move over to hierarchy, then backgrounds, and then we're gonna choose
our Sky one, and let's move it far away from our from our main camera, this sky background.
So let's move it.
Something like this much, I guess.
And let's move it something around six, and then we're gonna choose our clouds, and we're gonna go
for clouds.
So we can simply put a 4.5, because we want this clouds cloud to be moved a little bit faster as compared
to the sky.
That's why we just drag it our sky far from our main camera.
Or you can simply say from this player game object.
And now we're going to do with Grass Mountain.
Let's move this in the z axis as something around three I guess.
And then and we're going to move this up a little bit in the y axis our rock mountains.
Sorry, sorry.
It's basically the green mountains I really apologize.
Instead we have to do it with rock mountains.
So for green mountains let's set back to zero.
And we're going to choose our rock mountains.
And we're going to move in the Z axis three.
So make sure you select your rock mountains.
Then go over to Inspector Transform.
Then Z axis you can put something around three.
And now I want my grass mountain.
So this grass mountain just gonna move a little bit faster as compared to the rock, mountains, clouds
and sky.
Why.
Because it's gonna be closer.
So that's why it's gonna move a little bit faster as compared to the, uh, as compared to the which
one is far, far, far away from our main camera or from the player game object.
So I hope you get the idea that how you can do it.
So we're going to choose our grass mountain and we're going to move it in the Z, something like one.
Or we can simply do with two.
And let's move it a little bit up in the y axis.
And we're going to do the same thing with uh, you can simply say this rock mountains.
So let's move it up in the y axis.
And then I'm going to choose my clouds and let's move it up in the Y.
And then this sky background, something like this.
And now if we just go ahead and then click on this play button, you will notice the parallax effect.
Just gonna happen right away.
And this grass mountain is just gonna move faster as compared to which one is far, far away from our
player game object or from our main camera because we have chosen the perspective.
And now if we go ahead and you can notice that as you can notice our backgrounds basically doing the
parallax effect.
But the problem is that it seems like it's too much slow like that.
So what we can simply do, we can just drag a little bit further away from this player game object.
So it's going to be fine.
So let's get out of play mode.
So I'm going to choose my sky background.
So let's choose our sky background.
And let's go over to Inspector Transform then position inset.
We're going to do something around ten I guess ten seems pretty much fine.
Let's move it up a little bit.
And then we're going to choose our clouds and let's move it something around seven.
And let's move up a little bit.
Then we're going to choose our grass mountain and let's move it something like four.
Uh sorry.
This grass mountain, uh, firstly we're gonna choose our rock mountain.
We're gonna do it for.
And we will choose our grass mountain and we're going to do it something like two.
Let's choose our rock mountains one more time.
I guess you can hold down alt on your keyboard, and you can just adjust as well by selecting by selecting
this move tool in this in view in order to make the parallax effect.
So I'm going to choose my grass mountain.
Let's move it a little bit down something like this much.
And then I'm going to choose my rock mountains.
Let's move it a little bit down.
Then clouds a little bit down.
And I want my sky a little bit up.
Something like this much.
Now this seems pretty much cool and once you are satisfied, make sure you just move over to your parent
game object.
Then go over to Inspector Inspector, then over X and then apply all.
So the changes you made, it's going to be saved into this backgrounds GameObject prefab as well.
And now if we go ahead and then click on this play button in the top we will notice the parallax effect.
a parallax effect, parallax effect.
By now, it's going to be fine.
And once you are satisfied, then you can simply press down Ctrl S on your keyboard in order to save
your project.
And now if I just move left and right.
As you can notice the parallax effect, by now it seems a lot more a lot more cool.
And you can just play around with those values and you're gonna get that.
And we can also notice our camera shake.
As you can see, if I attack my enemy two game object, we can see this.
So this seems pretty much cool as you can notice.
So we made the parallax effect.
And in the by I guess we need to do something a little bit so we can simply get out of play mode.
And you can just play around with the y axis as well.
And let's suppose you just want to go back into the plane.
Something in the scene view.
You just want to go back.
Then you have to click on this story in the top bar in the scene view you can notice.
So just click on it in order to go back in, uh, plain, uh, plain plain scene, you can simply say
2D.
I hope you get the idea that how you can do it and make sure you press down Ctrl s on your keyboard
in order to save your project.
So firstly, you need to choose your main camera, then go over to Inspector Camera.
And then you need to choose this projection to perspective.
So it's going to make the uh make the parallax effect.
And you need to adjust all of these backgrounds, backgrounds in the z axis in order to make the parallax
effect.
And if you drag any background closer to the player game object, then it's going to move a little bit
faster.
Which one is far away from this player game object?
Or you can simply say from this main camera.
So you need to adjust that.
So I hope you get the idea that how you can do it.
And I'm gonna press down one more time, Ctrl s on my keyboard in order to save my project.
I hope you get the idea of this.