[MUSIC]
In this video, we're gonna play around with the dimensions,
get our camera set up right.
Make sure that our player is the right size in relation to the enemy,
in relation to the background so we're happy with our game and
we can start creating the functionality of it.
So let's jump in and get our project started.
If you're interested, you can jump in to this lecture as a challenge and
go through what I'm about to go through, but you can do it at your own pace.
Or pause the video and
see if you can figure out these different aspects yourself without watching me.
So we're gonna create a new Unity project, import our game assets.
I'm using the Kenney Space Shooter Assets.
We will add a background, add a player, add an enemy.
And add canvas to define the aspect ratio that we're using within the game.
So, if you wanna take that on as a challenge, pause the video and
do that now.
Otherwise, follow along with me and we'll get our project created.
I'm really excited for this section of the course.
This is gonna be really cool.
First thing we need to do is create a new project.
I am in Unity Hub, and I've clicked on New.
I'm gonna call my project name Laser Defender.
I'm using, currently, 2018.2.3.
It's okay if you're using anything that is 2018 and later.
They'll be using 2021 in the future.
Location, the usual place in my \Repos\Unity2D,
template 2D, Create Project.
So that's gonna take a little bit of time.
What I'll do while it is creating the project is show you the assets we're
gonna use for this section.
I've jumped over to Kenney.
So if you go to Kenney.nl.
I'll leave a link in the resources against this lecture for kenney.nl.
Kenney creates free assets, and, as you can see, no strings attached.
Kenney is a champion, feel free to donate
to let Kenney know that he's a champion and thank him for his hard work.
Click on the Assets tab up the top of the website.
Just a side note, I'm gonna give you these assets,
so you don't need to go through this yourself.
I'm just showing you how awesome Kenney is and where I got these assets from.
I found the space, where is it, space space space, something in here.
Let me search for space.
Space shooter, I believe it's called.
The space shooter pack, it's going to take a moment to,
well, if I click the button correctly, take a moment to think.
I'm using Space Shooter Redux, this is the pack that we're using.
And I have given you, this is a download against this lecture with a couple of
other things that I've added to it as well.
You can see lots of good stuff in there, and lots of little components.
So you can make your own enemy ships, or your own player ships, and
do a lot of great stuff with it.
And because Kenney's assets in the section are all pretty similar, you can go and
grab one of the other assets packs as well, the extension pack and
some of the other things, and they all fit in nicely together.
So anyway, I'm using Kenney as the asset.
My Unity is still loading.
So what I will do next is jump over to my folder.
I've got Kenney's Space Shooter Assets unzipped.
There, you can see a folder here.
As soon as Unity has started a project for us,
we're gonna drag this entire folder into Unity and it's disappeared.
Here it is again.
There we go. Okay, so we're in the game.
I've been playing around with this at, well, I've been doing my prototyping so
you might see my layout here.
I've got the scene and
the game next to each other because I'm creating my project as a vertical shooter.
I asked the community and you guys say, we want a vertical shooter.
So that's what we're doing.
Just so you know, we won't go through the whole mechanism of dragging a particular
window to a particular spot.
But you can see I've got my scene window, my game window, and
my inspector over on the right.
So open up my Explorer, find the Space Shooter Visual Assets.
Drag the entire folder over into Assets.
We don't need all of the assets.
But for now what I'm showing you, what I'm doing, I think this is the easiest way for
me to show you.
Go grab this asset and go grab that asset.
Instead of having to go to my Explorer and show you an asset at a time,
let's just drag them all in so we've got them all available to us.
I think that would be nifty to do.
Okay, and you can see down in the bottom here of my project.
I've got the Space Shooter Visual Assets.
In here we've got Background.
There's one background in here,
this blue one that I created myself with my own very hands.
So we'll be using that throughout this section.
And then the PNG folder is the other one where we're gonna get a lot of good
stuff in there.
We have player ship, you can see there's a lot of player ships,
see that there's some enemies, click on enemies.
You see a bunch of enemy ships and lots of other great, great assets.
Okay so in terms of how I am serving up my layout here, so
we can be on the same page.
I've created a 9, 16 resolution.
So if you don't have that, click the little plus icon,
make sure that we are on Aspect Ratio.
If you're on Fixed Resolution it'll be 9 pixels by 16 pixels, which is no fun.
Aspect Ratio, and then the width is going to be 9, and
the height is going to be 16 and then click OK.
I'm gonna click Cancel because I've already got one.
9, 16 that means that our play space will be a nice vertical 9 by 16,
which is a lot more mobile friendly.
Okay, over to our scene now.
First thing I'll do is find my backgrounds.
And this is gonna get a little bit messy if we're spending time grabbing
assets from here.
So each time I grab and asset I'm gonna go and
put it in it's proper place in my Assets folder.
So I'm gonna right-click, Create New folder and I'll call it Sprites.
So these is the sprites that we are actually using in our game.
And like I said, is just so
we don't have to go digging around in this Kenney folder.
Normally I won't bring the whole folder in, but this just makes it easier for
me to show you exactly which asset I'm going for without having to go off and
find it in our Windows Explorer or our Mac Explorer.
Mac Finder I guess the case might be.
Okay, so we've got our Sprites folder.
From the Space Shooter folder, I will find backgrounds.
You should see this, what's it called, Space Background Tiled, has a background.
I'm going to drag that into my Sprites folder.
There we go, so I'm going to steal it from where it was and put it in to there so
now it lives in this spot.
I will also find in the PNGs,
let's go find which player ship we're going to have.
Let's see, blue, green, or red?
Or that sort of spaceship or this sort of spaceship?
Choose whichever one you want if you're using the Kenney assets.
If you're bringing in your own assets,
obviously you'll choose something a bit different.
For me, let's see I'm gonna go with green for now I can always change it later on.
Drag it into there and then for the moment I'll go and
pick one enemy that will be our example enemy for awhile.
As we're playing around with things we'll go and find mister orange,
we'll find this orange kind of looks a bit like a toe fighter I think.
I'll drag that into my Sprites as well.
Great, so now in my Sprites folder, I should have three assets.
Very good. Okay,
let's drag in our background into our scene and bloomp!
Instantly we've got a game.
Very cool.
Done, job done [LAUGH] we've got a game.
And while I remember, before we go and put too many things in here.
I'm gonna create my canvas, so that we know where it is that our score,
and other user interface elements will be going.
So over in the hierarchy right-click,
Create, under UI, we are going to find Canvas.
Down at the bottom there, Canvas.
That will put Canvas onto the scene.
Okay, clicking on the Canvas, we'll have a look at the inspector.
I'm gonna make sure instead of constant pixel size,
which means that as we increase and decrease our background,
then the pixels will stay exactly the same size that they are.
So something that's ten pixels on a small screen will be ten pixels on a big screen.
I'm going to change this to be scale with screen size.
I think that's going to be a better way to do it.
And the reference resolution we will make 1080 by 1920.
Doesn't have a huge impact, but this is just the reference resolution that
the game thinks that's what we're trying to target.
And if someone is playing on a bigger screen then that will stretch it, and
if someone's playing on a smaller screen then that will shrink it.
If you mouse over reference resolution,
it gives you a little bit of that information as well.
I'll also, while I'm on my background just make it a little bit smaller,
I'll hold down shift as I move it so it moves In the right aspect ratio.
And then roughly put it just there, great stuff, so
we can see how it's looking within our game.
Yep, and yep.
Cool, okay, so we have a starfield.
Now, let's add a player, just simply, in the hierarchy,
let me just make a little more space in the hierarchy.
Right-click, Create Empty, always reset the transform when we create an empty.
We will call this player, and on our player we need a component, so
I'll add component, and can you guess what we need?
We need a sprite renderer, so that we can actually see what the player is.
We'll grab our player sprite, and drag it over into the sprite area,
now we have a sprite of our player and click W and move the ship down.
That's a pretty good start.
Now we will do similar for an enemy.
Right-click in the hierarchy, Create Empty, we'll call this enemy.
For now it's just going to be generic enemy.
We'll have a ton of enemies later on.
Reset the transform, and we will add a component, again a sprite renderer.
We can either drag in or click on the little select a box.
If I click on the select a box, I get all of these sprites that are in our project.
So it's a little bit easier just to drag the enemy from our sprite folder.
So we've got an enemy on the screen.
Okay, so now we have player.
We have an enemy.
So part of the reason we lay it out like this is that we can see the relative size
of things and make sure everything looks like it's the right size.
Before I forget, we need to make sure that we have things on different depths.
So currently our background, if we have a look at the place of it, we see
the background is on zed of 19.6 as I just dragged it willy-nilly into my scene.
If I click the 2D button on my scene, change from 2D to 3D.
We have a look.
I'm just scrolling around by holding Alt and my left mouse button.
We can see that the background is way back there which is good it's in
the background.
That's where it should be.
We don't need it to be quite so
far back so I'm going to change this to five on the zed axis.
It's still underneath the player and the enemy.
That is great.
That is exactly what we need.
Click back on the 2D button so we're back here in reality.
So I can click on the player sprite and
change the pixels per unit to make it bigger or larger on the screen.
I think what I'll do first of all is change the main camera.
Just so we can move the main camera back a little bit.
It's currently five.
I think we can try seven.
And keep moving it around until we get to the point where we're happy with
the size of the playership.
I think that's not too bad for the moment.
Obviously we need to change the background again.
But the size of the player looks pretty good.
So I will change my background now.
I'm happy with that size of camera.
We'll click on the background, hold down Alt and drag it up.
Make sure it fits on the left and the right, cool.
So now we have a background.
Our player looks pretty good, our enemy looks pretty good.
The enemy could be a little bit bigger but
that great, it gives us room to move in the future.
Drag the player down the bottom of the screen,
drag the enemy up to the top of the screen, so there we go.
That's the relationship.
If you're wanting your camera a little bit closer, so
you can see your player a little bit bigger on your screen you can do that.
Or you can move things out so everything is even smaller on your screen.
That's fine as well, but I'm pretty happy with this particular layout.
So we've got our background, we've got our player and enemy mocked up.
We've got our aspect ratio that we've figured out, and
we've set up a new project.
We're ready to go, in the next video,
we'll start getting some movement happening in our game.