Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Unity Basics!
You have completed Unity Basics!
Preview
Letβs create our first game object and learn about the commonly used Transform Tools.
Unity 6 Documentation
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
Alright, ready to start building
your first game?
0:05
Let's go!
0:08
First things first, notice
this little white box in the scene window?
0:09
This represents our camera's viewport,
meaning what the player will see.
0:13
If I squish and stretch this window,
see how the box changes shape as well?
0:18
Well that's no good.
0:22
We don't want the viewport changing shape.
0:23
Let's address this by checking
the target resolution for our camera.
0:26
Since we're building this
for our computers and not a mobile device
0:30
for example, I think
1080p is a good resolution to go with.
0:33
Let's open the game window and see here
where it says Free Aspect.
0:37
If you click here, you will see
0:42
we'll open some other default resolutions
you can choose from.
0:43
For example, if you'd to build for 4K,
0:47
you can select this 4K UHD option here.
0:49
You can even create your own custom sizes
by clicking this plus icon at the bottom.
0:52
I feel that 1080p
is still a commonly used resolution
0:57
for monitors,
and just so we're all on the same page
1:00
throughout this
project, let's select that.
1:03
This is typically the
1:06
first thing I do in a new project.
1:07
Now if I squish and stretch this window,
the aspect ratio remains the same.
1:10
Awesome.
1:15
I'm going to move these bottom tools here
1:17
and just pin them up top
to create some more room.
1:19
You don't need to do this though.
1:22
Alright, let's create our first game
object that will be our player.
1:25
To create a new game object, we just have
to right click in our hierarchy window
1:28
and we'll see all sorts of objects
we can make down here.
1:32
Let's go to 2D object,
1:37
then sprites,
and we'll see some basic shapes here.
1:39
Let's create a circle.
1:43
You can see in our scene window,
it's given us a white circle object
1:46
In the inspector we see this game
object comes with two components
1:50
a transform and a sprite renderer.
1:53
Up top here is a field where we can edit
the name.
1:57
Let's rename this circle to Player
and hit Enter or Return.
1:59
One thing to note is every single game
2:05
object in Unity has a transform component.
2:07
This tells Unity its position, rotation
and scale in our scene.
2:10
We can type in values into these boxes
to adjust
2:15
things.
2:18
Also, if we hover over one of these X,
2:21
Y, or Z labels, we'll get this drag icon.
2:24
We can click and drag side to side
to adjust things this way as well.
2:27
In 2D, the X axis
2:32
represents horizontal, or side to side,
2:33
the Y axis represents vertical,
or top to bottom,
2:36
and the Z, or Zed, which would normally
determine depth, meaning how close or far
2:40
from the camera the object is, is not
used all that much in 2D.
2:45
We do typically use the Z rotation
in 2D though.
2:49
My preferred way to change an object's
position is with the Move tool.
2:53
You can click this icon here,
or use the keyboard
2:57
shortcut W,
and you'll see these arrows here.
3:00
Clicking and dragging
the green changes the Y,
3:03
the red changes the X,
3:08
and if we click and drag in this box,
we can have free control.
3:10
I'm going to right-click on the component
name here and click Reset.
3:14
This will zero it out.
3:19
Notice the position
of this circle is 0, 0, 0
3:21
and it's directly
in the center of the screen.
3:24
If we drag the X position to the left,
3:27
the object will move left
and the numbers go negative.
3:30
Likewise, to the right of 0 is positive.
3:33
Same goes for the Y axis.
3:36
Going up is positive and down is negative.
3:38
Now there are other tools here as well.
3:41
We have the view tool,
which I never really use
3:46
as we get the same functionality
by clicking and holding down
3:48
the scroll wheel of the mouse.
3:51
It helps us move
3:54
around in our scene view. Also note,
if you see me zooming in and out,
3:54
I'm rolling the scroll wheel
on my mouse as well.
3:59
Then there's the rotate tool,
where we can click and drag
4:02
these axis lines to adjust the transforms
rotation.
4:04
You can see the values
4:10
changing up in the inspector.
4:11
I'm going to reset this again.
4:14
There's the scale tool
which does the same with its scale.
4:19
Clicking and dragging the center box
adjusts all three axes together.
4:22
I'm going to use Ctrl-Z or Cmd-Z on Mac
4:27
to undo this.
4:29
The Rect tool is handy
as it allows us to manipulate the position
4:33
and scale together
by clicking and dragging these dots
4:36
or outlines.
4:40
Holding Shift while doing this links
4:43
all of the scale axes
together to keep its shape.
4:44
And you can also click in the image
and move it around with this too.
4:47
Lastly, there's the
4:52
Transform tool, which combines
all of these into one place.
4:53
I haven't gotten proficient
with this one yet to be honest.
4:57
I switch between the Move and Rect tool
all the time though.
5:00
Conveniently, the keyboard shortcuts
for all of these is QWERTY.
5:04
So it's very easy to remember.
5:08
Q-W-E-R-T-Y.
5:10
Alright, moving on.
5:13
The sprite renderer component does
what its name suggests.
5:17
It renders a sprite,
or image, for our object,
5:20
and right now it's using a Unity built-in
sprite named Circle.
5:24
We'll change this to Mike the Frog later
on, don't worry.
5:28
For now,
5:31
let's just get the game working before
worrying about making it look all fancy.
5:31
For now, we don't need to worry
about these other properties.
5:36
We'll come back to some later on,
but every component has many adjustable
5:38
properties, and I don't want this course
to be overwhelming. I'd like it to be fun.
5:42
So we'll work with what we need as we need it.
5:46
I'll be leaving helpful links in the teacher's
notes below if you'd like to read further
5:49
about any of these components
though. So always check down there.
5:53
Up top here we have a play button.
This will let us test
5:57
our game and automatically
bring the game window into view.
6:00
Let's see what happens
when we we play our game.
6:04
We're waiting...
we're waiting...
6:08
Okay.
6:12
Well, not much.
6:13
But this is because
we simply haven't told Unity
6:15
to do anything with this game object yet,
6:17
besides put it in this position
and give it this sprite.
6:19
Let's click stop.
6:23
And before we do anything else,
6:25
there's a nifty little trick
that I wish I knew earlier in my journey.
6:26
Did you notice the time it took to enter
play mode,
6:30
we can cut this down significantly.
6:33
Let's go to Edit,
6:35
Project Settings,
6:39
and click on Editor.
6:43
Let's scroll down near the bottom
and right here where it says Enter
6:45
Play Mode Settings.
6:48
Let's change this to
Do Not Reload Domain or Scene.
6:50
For this small game we're making,
this is fine.
6:54
For bigger games
using a lot of static objects,
6:56
which you also don't
need to worry about yet,
6:59
this could potentially cause issues,
but we'll be alright in our scenario.
7:02
I'll put a link in the teacher's
notes below
7:06
if you'd to know more about this setting.
7:07
Okay, let's click play again,
and now it's almost instantaneous.
7:10
Nice!
7:14
Lastly, notice this little
7:16
asterisk next to our scene
name in our hierarchy?
7:17
This is informing us
that we have unsaved changes in our scene.
7:20
You can go to File, Save,
7:25
or simply use Ctrl S on Windows
or Command S on Mac.
7:27
This is something you'll want to do
frequently, just in case the very rare
7:31
event of Unity crashing happens,
you won't lose tons of progress.
7:34
Alright, in the next video,
we're going to start bringing our game
7:39
to life with physics and collisions.
7:41
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up