Beginning Unity 3D for iOS: Part 1/3

A beginning Unity 3D tutorial that shows you how to make a simple game for the iPhone. By Christine Abernathy.

Leave a rating/review
Save for later
Share
You are currently viewing page 3 of 6 of this article. Click here to view the first page.

Scale Tool

The Scale Tool allows you to, you guessed it, scale GameObjects up or down in size.

Using the Scale Tool

As with the other GameObject manipulation tools, you can make your changes along only one of the three axes, and you have the choice of modifying the Inspector\Transform component instead of using the tool.

Select the Main Camera and note that the Scale Gizmo consists of cube handles at the end of each axis and one at the center.

To scale freely across all axes, select the cube at the center of the object and left-click, then move up to make the GameObject bigger and move down to make it smaller. Take a look at the Inspector\Transform\Scale properties. You should see the numbers go up or down as you grow or shrink the object.

Scale Component in Unity

Test scaling along the x-axis by selecting the red gizmo handle for the x-axis, and holding and then moving the handle outward. Verify using the Inspector that the Transform\Scale x-value is the only one that changes. Try this with the y and z axes as well.

Once you’re done playing around with the controls, reset the Main Camera to the following settings using the Inspector\Transform section:

  • Position: 0,1,-10
  • Rotation: 0,0,0
  • Scale: 1,1,1

Your Transform menu should look like this:

After transform properties reset.

You will learn about the other Editor interface components as you walk through the tutorial. This includes previewing a game using the Play button and using the Unity debugger.

Lonely No More: Adding GameObjects

Now that you’ve run through the basic concepts, you’re ready to begin adding GameObjects to keep the camera company – it’s been pretty lonely all by itself :]

Right now the camera is looking out on a very desolate world. Never fear – get ready to add a cube GameObject that represents the player, as well as a plane GameObject that represents the floor the player will move upon.

When you’re designing a game with Unity, a best practice is to first develop the gameplay without any fancy assets that represent the player. That way, you can concentrate on optimizing gameplay and player movements without being distracted by graphics.

Another point to note is that Unity is a very good game engine, but you don’t want to use it to create graphic assets. There are many tools out there that are wonderful in the graphics department and Unity is adept at importing assets from a wide range of tools.

Often, the typical division of game development labor is that the game developer works on the gameplay using Unity while the graphics designer creates assets in parallel using their favorite graphics tool. The two converge down the line when it makes sense to bring in the graphical assets to polish up the game.

Now that you’ve got that to think about, let’s get shaking! Add the floor GameObject, represented by a plane, by selecting Game Object\Create Other\Plane.

The new plane GameObject should appear in the Hierarchy View. Select the plane in the Hierarchy View and set Transform\Position to 0,0,0 using the Inspector. Also use the Inspector to scale it up to 50,1,50. Your scene should look something like this:

Adding plane GameObject.

Next you’ll add the player GameObject, which in your game will be represented by a cube. That’s right, the Heroic Cube!

Select Game Object\Create Other\Cube, and the new cube GameObject should appear in the Hierarchy View. Select the cube in the Hierarchy View and set the Transform\Position to 0,0,0 using the Inspector. Your scene should look like this:

Adding Cube GameObject.

Click on the Move Tool, then click the y-axis in the Scene Gizmo to constrain the object’s move to only the y-axis. Move the Heroic Cube up a little so it’s above the plane (floor). You can also set the transform position to 0,1,0 to move the Cube up a little.

Now comes an exciting moment – click the Play button on the Unity Editor toolbar (at the top) to preview your game thus far:

Play game.

You’re now testing your game using the Unity Editor. The Editor should switch to the Game View and you should see something like this:

Initial game view.

What you’re seeing is a view of the game through the Main Camera in your scene. Your player, the Heroic Cube, is shown in the distance, above the floor – alone in the world, but bravely present!

There’s not much going on in the game because you haven’t added any components to modify the player’s behavior. It’s also a little dark in this scene. You can take care of the latter issue first by adding a light source to your scene.

Stop the game preview by clicking on the Play button again. Back in the Scene View, add a light source. Select Game Object\Create Other\Point Light. As usual, move the light to the origin before making further adjustments to its position. Set the transform position to 0,0,0 using the Inspector.

Now adjust the light’s height and brightness so you can see more of the scene. Here’s a hint: use the Move Tool and constrain movement along the y-axis only.

To adjust the brightness, modify the Range and Intensity settings in the Light component. Make use of the Hand Tool to swivel around if you need to get a better view of the scene.

A good way to see if you have enough light is to switch to the Game View using the Game tab (rather than hitting the Play button). Go back and forth until it looks like you can see your player:

Adding point light GameObject.

After you’ve made your adjustments, hit the Play button again to verify your changes. Your view should be similar to the following when you switch to the Game View:

Game after light source added.

Congrats, you’ve added all the GameObjects you need for this stage of the tutorial! Remember, as a good practice you are focusing on gameplay first, then adding graphics later.

Since you’ve done something meaningful, go ahead and save your work as a scene in the project. A project can be made up of one or more scenes. You can think of a scene as the equivalent of a level in a game.

In this tutorial, you’ll represent each part of the tutorial as a scene. This is an artificial concept of a game level, but it allows you to reuse assets from one scene in the next.

To save the scene, select File\Save Scene and in the Save Scene dialog, name your scene Level_1. Your Project View should update with the scene you’ve just created.

Level 1

Christine Abernathy

Contributors

Christine Abernathy

Author

Over 300 content creators. Join our team.