Checked with version: 5.2
Phase 1 teaches you how to set up the base scene using the provided assets.
Intermediate Tanks tutorial
- 00:00 - 00:03
So without further ado, this is what we're going to make today.
- 00:04 - 00:06
We're making a two player
- 00:06 - 00:08
tank shooting game.
- 00:08 - 00:10
It's not a networked multiplayer game,
- 00:10 - 00:12
so don't be confused by that.
- 00:12 - 00:14
We will be releasing a version of the game
- 00:14 - 00:16
tomorrow that has Unet stuff built in to it,
- 00:16 - 00:19
sorry, multiplayer features built in to it.
- 00:19 - 00:22
But this is all about two players on one keyboard.
- 00:22 - 00:24
So we're going to build this game throughout the day
- 00:24 - 00:26
and then at the end of the day we're going to get together
- 00:26 - 00:28
and have a bit of a battle with it.
- 00:28 - 00:30
Okay, so many of you will see that there's
- 00:30 - 00:32
a completed scene loaded,
- 00:32 - 00:34
if that's not what you're seeing, don't worry about it at all.
- 00:34 - 00:36
We're going to start by making a new scene in a moment.
- 00:37 - 00:39
What I would like to you to do or suggest that
- 00:39 - 00:42
you do if you're hoping to see exactly what
- 00:42 - 00:44
we're seeing on the screens is to use the same
- 00:44 - 00:46
layout that we're using.
- 00:46 - 00:48
So what I'm going to get you guys to do is click on
- 00:48 - 00:50
the Layout drop down in the top right
- 00:50 - 00:52
and choose 2 by 3.
- 00:56 - 00:59
Then what I'm going to do is to grab my project panel.
- 00:59 - 01:02
and drag and drop that by grabbing the tab at the top
- 01:02 - 01:04
and drop it below the hierarchy.
- 01:05 - 01:07
You're looking at a layout that's something like this.
- 01:07 - 01:09
So if you're unfamiliar with Unity then you can just
- 01:09 - 01:11
drag these windows around, you can reorder them,
- 01:11 - 01:13
you can dock tabs,
- 01:13 - 01:16
but hopefully everybody's familiar with that having watched
- 01:16 - 01:18
the beginner tutorials that we sent you by email.
- 01:19 - 01:21
And then the only other thing that I'm going to do it
- 01:21 - 01:23
to set my project panel to a list style
- 01:23 - 01:25
view by dragging the slider at the bottom here.
- 01:26 - 01:28
If you drag it all the way to the left you will get a list view.
- 01:30 - 01:33
Okay, so that's our editor setup.
- 01:33 - 01:35
By the way if I'm going too fast just shout
- 01:35 - 01:37
at me, I'll slow down.
- 01:39 - 01:40
We're going to start from scratch,
- 01:40 - 01:42
so if you go to File - New Scene
- 01:43 - 01:45
command-N on mac, control-N on PC
- 01:46 - 01:47
and then the first thing we're going to do
- 01:47 - 01:49
before we start losing work, or doing work,
- 01:49 - 01:51
is to save it somewhere, so you go
- 01:51 - 01:53
File - Save Scene As
- 01:53 - 01:56
and you will find a Scenes folder.
- 01:57 - 01:59
And we're just going to call this Main.
- 02:00 - 02:01
Save it in there.
- 02:02 - 02:04
Then what we're going to do is to
- 02:05 - 02:06
remove the directional light.
- 02:06 - 02:09
So whenever you make a new empty scene in Unity
- 02:09 - 02:11
you get two things, you get a main camera,
- 02:11 - 02:12
and you get a directional light,
- 02:12 - 02:14
so it's kind of setup so that you can just
- 02:14 - 02:17
drag some artwork in there and it's going to look nice.
- 02:17 - 02:20
We've got our lighting setup in our Level prefab.
- 02:20 - 02:22
So we don't need that, so select the directional light
- 02:22 - 02:24
in the hierarchy here,
- 02:24 - 02:26
just delete it, command-backspace on mac
- 02:26 - 02:28
delete on PC.
- 02:29 - 02:31
Then what I want you to do is
- 02:31 - 02:34
look in the Prefabs folder in the project.
- 02:34 - 02:36
What you should see is that you've got a number of
- 02:36 - 02:38
prefabs in there.
- 02:39 - 02:41
One of those is called LevelArt
- 02:41 - 02:43
and if you select it it should look something like this.
- 02:43 - 02:46
So it's a little game board with all of the stuff setup.
- 02:47 - 02:49
So the reason we're giving this to you readymade,
- 02:49 - 02:51
or prefabbed as we call it,
- 02:51 - 02:53
is that we didn't want you guys to have to go through a whole
- 02:53 - 02:55
system of setting up colliders
- 02:55 - 02:56
and all of this different stuff.
- 02:56 - 02:58
We thought we would just get it all ready and then
- 02:58 - 03:00
actually go about making the game.
- 03:01 - 03:03
So I'm going to grab my LevelArt prefab and just
- 03:03 - 03:05
drop it on to the hierarchy.
- 03:08 - 03:10
Then what you'll see is that that's populated
- 03:10 - 03:12
in the scene view and you can see part of
- 03:12 - 03:14
it in the game view as well.
- 03:14 - 03:16
Now what you'll notice at this point is that there's a blue
- 03:16 - 03:18
progress bar starting down at the bottom..
- 03:18 - 03:20
So we want to change some settings for that.
- 03:20 - 03:22
What that's doing is telling us about lighting
- 03:22 - 03:25
and it's starting to create a lighting bake.
- 03:26 - 03:29
So I want you to go to Window - Lighting.
- 03:31 - 03:33
If you drop the LevelArt prefab in
- 03:33 - 03:35
to the scene that will instantiate it as well,
- 03:35 - 03:37
but it won't position it at the origin,
- 03:37 - 03:39
if you've done that don't worry about it,
- 03:39 - 03:42
just put it back at the origin by changing position to (0,0,0).
- 03:43 - 03:45
Yeah, so just to reiterate
- 03:46 - 03:49
the LevelArt should be at (0,0,0)
- 03:49 - 03:51
if you've dragged it in to the hierarchy.
- 03:51 - 03:53
If you randomly dropped it in to the scene view it might
- 03:53 - 03:55
be at a slightly different position, just set those all back
- 03:55 - 03:57
to 0 in the transform component here
- 03:57 - 04:00
Transform - Position - (0,0,0).
- 04:01 - 04:03
Okay, so the lighting panel.
- 04:03 - 04:06
First thing to do is to uncheck Auto
- 04:06 - 04:08
at the bottom of the lighting panel.
- 04:09 - 04:12
So what Auto is there to do is basically to
- 04:13 - 04:16
allow you to be lighting and moving around
- 04:16 - 04:17
geometry that's going to stay still,
- 04:17 - 04:19
okay, so if we were designing this level
- 04:19 - 04:21
and we wanted to kind of incrementally bake whenever
- 04:21 - 04:24
we moved something around it will rebake the shadows, etcetera,
- 04:24 - 04:26
then we'd leave that setup, but we've already done
- 04:26 - 04:29
that for you, so what we're going to do instead is uncheck that
- 04:29 - 04:31
and then we're going to give you some settings to put in.
- 04:35 - 04:38
First thing I'm going to do is remove Baked GI.
- 04:38 - 04:40
So we don't want any baked
- 04:40 - 04:42
lighting for this, we're going to use realtime
- 04:42 - 04:45
lighting so that when we're firing the shells around
- 04:45 - 04:48
they've all got lights on and they're going to light up the scene for us.
- 04:48 - 04:50
So we're going to use that
- 04:50 - 04:52
Precomputed Realtime GI.
- 04:52 - 04:54
But we don't want it at a realtime resolution of 2
- 04:54 - 04:57
we're going to set that to 0.5.
- 05:01 - 05:05
This is kind of, sort of low poly style artwork,
- 05:05 - 05:07
no offence Pete, it's beautiful, well done.
- 05:09 - 05:12
So, we don't need immensely high res
- 05:12 - 05:14
for the lighting there, we can get away with
- 05:14 - 05:16
- 05:17 - 05:19
Then one other thing that we need to do is to change
- 05:19 - 05:22
our ambient lighting, so in Unity lighting can come
- 05:22 - 05:23
from all the different lights that you put in there,
- 05:23 - 05:25
so you know, we saw we had a directional light,
- 05:25 - 05:28
and we have a directional light in this scene,
- 05:28 - 05:30
it's attached to this.
- 05:31 - 05:33
So you can see here, directional light.
- 05:34 - 05:36
But you can also get ambient contribution
- 05:36 - 05:38
and ambient is basically just the lighting
- 05:38 - 05:41
supplied either by a skybox or by colour or gradient.
- 05:42 - 05:45
and we're just going to set this to a colour.
- 05:47 - 05:50
What I wanted to introduce you to briefly is that
- 05:50 - 05:52
whenever we switch back to the slides we're going to have a quick
- 05:52 - 05:54
recap of what we've just done, okay?
- 05:54 - 05:56
So we've skipped through a few basic steps
- 05:56 - 05:59
but what we'll also do is when we get in to the more detailed stuff
- 05:59 - 06:01
we'll keep going back to the slides,
- 06:01 - 06:04
and the slides also have references to things.
- 06:04 - 06:06
So you can see here we have Ambient Color, and that's
- 06:06 - 06:08
what we're going to do next, and you can see I'm
- 06:08 - 06:12
asking you guys to set it to 972, 62, 113).
- 06:12 - 06:13
But what does that mean?
- 06:13 - 06:16
So Ambient Source set to color, which looks like this,
- 06:17 - 06:19
So this color box,
- 06:19 - 06:21
has RGB values, if you click here
- 06:21 - 06:23
it will change to different values, but you want
- 06:23 - 06:25
to make sure you're on RGB.
- 06:26 - 06:28
And the references there, 72 for red,
- 06:28 - 06:32
green 62 and 113 for blue.
- 06:33 - 06:36
This system of showing you
- 06:36 - 06:38
these different references is
- 06:38 - 06:40
going to be the same for X, Y and Z.
- 06:40 - 06:42
So they're represented by red, green and blue
- 06:42 - 06:44
as well, so if you see those for color
- 06:44 - 06:46
and also for positions or rotations
- 06:46 - 06:48
don't get confused, that's fine.
- 06:49 - 06:51
Okay, so back to the editor.
- 06:51 - 06:53
We've put in this kind of purple color in ambient
- 06:53 - 06:55
and that's fine.
- 06:56 - 06:58
And then right at the bottom of that panel
- 06:58 - 07:00
we're just going to click Build.
- 07:00 - 07:02
So Build will bake your lighting
- 07:02 - 07:05
and you'll see a short progress bar at the bottom.
- 07:05 - 07:08
If you've just opened Unity for the first time,
- 07:08 - 07:10
like ever, or just installed this version for the first time
- 07:10 - 07:12
then it might take a little bit longer to bake.
- 07:12 - 07:15
It doesn't matter before it's going to do it in the background
- 07:15 - 07:17
and we can carry on with the work that we're doing.
- 07:19 - 07:22
The next thing we're going to do is to setup our camera.
- 07:23 - 07:25
So the position of the camera currently
- 07:25 - 07:28
as you can see is kind of looking at some of the buildings.
- 07:28 - 07:30
It's embedded down here.
- 07:30 - 07:32
So it's this kind of default position that camera's
- 07:32 - 07:35
always are, which is at (0,1,-10) in the world.
- 07:35 - 07:37
So it's kind of away from 0
- 07:37 - 07:40
so that you can look at something if you put it in at 0.
- 07:41 - 07:43
So we're going to start by just repositioning
- 07:43 - 07:46
that so I'm going to set the position in the transform component
- 07:46 - 07:51
to (-43, 42, -25).
- 07:52 - 07:54
And I'm going to rotate this
- 07:55 - 07:59
to (40, 60, 0).
- 08:02 - 08:04
Okay, and then the final thing we're going
- 08:04 - 08:07
to do there is to set it to orthographic projection.
- 08:08 - 08:10
So as I promised we're going to do these recaps.
- 08:11 - 08:13
So in the inspector panel we're setting the position
- 08:13 - 08:18
of the camera to (-43, 42, -25).
- 08:18 - 08:23
Change the rotation to (40, 60, 0).
- 08:23 - 08:26
Finally we're changing the projection to orthographic
- 08:26 - 08:29
and we're going to talk a little bit about what that means.
- 08:29 - 08:31
So what you'll notice is that
- 08:31 - 08:33
when we've changed projection from perspective
- 08:33 - 08:35
to orthographic you now get this
- 08:35 - 08:37
strange looking flattened view.
- 08:38 - 08:40
We're going to talk a lot more about that in the specific
- 08:40 - 08:42
section on cameras later on
- 08:42 - 08:44
but just to briefly explain,
- 08:44 - 08:46
the difference between projection and orthographic is
- 08:46 - 08:48
that there's no change in scale
- 08:48 - 08:50
over distance, and we've got some diagrams
- 08:50 - 08:52
that explain that a bit better.
- 08:52 - 08:54
But what you'll need to know going in
- 08:54 - 08:58
is that size is what changes, effectively the zoom.
- 08:58 - 09:01
As I drag my size value I'm effectively zooming in and out.
- 09:01 - 09:04
We don't want you to do this, but it's just an example.
- 09:04 - 09:06
Then the last thing that we're going to do.
- 09:06 - 09:08
As you notice when I zoom out here,
- 09:08 - 09:10
sorry, wrong way round, when I zoom out I can see my
- 09:10 - 09:12
strange gradient sky box in the background
- 09:12 - 09:14
and because our camera will pan out when our
- 09:14 - 09:19
tanks move far apart we need to have a background color setup.
- 09:20 - 09:22
What I'm going to do is to change
- 09:22 - 09:25
my clear flags on the camera component
- 09:26 - 09:29
from skybox to solid color.
- 09:30 - 09:33
And then I'm going to choose a color for the background.
- 09:33 - 09:35
So this is just going to be a brown to match the
- 09:35 - 09:41
desert and the RGB reference is (80, 60, 50).
- 09:41 - 09:43
If you want to choose your own brown, you're a big fan of
- 09:43 - 09:45
brown, then you know,
- 09:45 - 09:47
pick your favourite brown.
- 09:48 - 09:50
We're just going to put in that RGB reference
- 09:50 - 09:52
and then what we'll see
- 09:52 - 09:54
when we do happen to go over the edges
- 09:54 - 09:56
is that, so it kind of fits the theme.
- 09:57 - 09:59
But like I said, don't change the size value,
- 09:59 - 10:01
that's not important.
- 10:02 - 10:05
So quick recap, we changed our clear flags
- 10:05 - 10:07
from skybox to solid colour so that the
- 10:07 - 10:09
background, so what renders behind all of
- 10:09 - 10:11
the geometry in the scene is changing
- 10:11 - 10:13
to a particular color,
- 10:13 - 10:16
we changed that color to (80, 60, 50).
- 10:16 - 10:19
And finally we're going to save our scene,
- 10:19 - 10:21
I'm going to get you to save all the time,
- 10:21 - 10:24
but it's just a good habit to control-S or command-S if you're on a mac.
- 10:24 - 10:26
Keep updating your scene.
- 10:26 - 10:28
So the next thing that we're going to do is create
- 10:28 - 10:30
our tank and it's control,
- 10:30 - 10:33
so as with the level art we've created
- 10:33 - 10:34
the artwork for you.
- 10:34 - 10:36
This time we're not going to give it to you prefabbed,
- 10:36 - 10:38
we're going to start with the model and build up
- 10:38 - 10:40
all the components that you need.