Beginning Unity 3D for iOS: Part 2/3

In this second tutorial,, you’ll add functionality to enrich the project, including better player movement and better game scenery. You’ll also learn how to use Unity Remote for debugging. By Christine Abernathy.

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

Don’t Forget Your Veggies

Switch back to the Scene View. You can create vegetation by first adding a terrain GameObject, then adding material (e.g., grass) and objects (e.g., trees).

You no longer need the plane GameObject, as the terrain will take over flooring responsibilities. Right-click on the plane GameObject in the Hierarchy View and select Delete.

Select Assets\Import Package\Terrain Assets.

Importing package assets for the terrain.

Click Import to import all the selections. The Terrain Assets should show up under your Standard Assets folder. You can use the imported assets to modify the behavior of a terrain GameObject.

Select Terrain\Create Terrain to add a terrain GameObject to your scene. Select the terrain object and change its transform position to -1000,0,-1000 using the Inspector. This stretches the terrain out far enough to give your player room to move.

Terrain GameObject transform adjusted.

The Terrain (Script) section contains tools that you can use to dress up your terrain:

Terrain tools.

Select the Paint tool to bring up the brushes you can work with:

Terrain paint tool.

You’ll be painting your terrain with grass. Click Edit Textures\Add Texture:

Terrain paint texture selection.

In the Add Terrain Texture dialog, click Select in the Texture area, select the Grass (Hill) texture, close the Select Texture2D pop up, then click Add:

Grass texture added.

Click around in your scene to paint the grass. To check out your artwork, click on the Game tab:

Game View after grass added.

If only landscaping could always be so easy!

Switch back to the Scene View – now you’re going to plant some palm trees! Select the Place Trees tool in the Terrain (Script) section:

Terrain place trees tool.

Click Edit Trees\Add Tree:

Tree selection.

In the Add Tree dialog, click the circular icon next to the Tree entry, select the Palm GameObject, then click Add:

Tree available to add to scene.

Set the Brush Size to 20:

Place trees tool settings.

Start adding trees to your scene by clicking where you want the trees to be. Hint: Zoom into the scene and pan around as you place the trees. Try adjusting the Point light range and height to see more of the scene as you add trees.

Point light adjustments to place trees.

When done, your scene should look something like this:

Scene View after trees added.

Wow, that’s much better! It’s starting to look like a real world down there. But your terrain’s still looking a bit flat, isn’t it?

You can easily add some height variation to your terrain. In the Terrain (Script) section, select the leftmost tool to raise and lower the terrain height:

Terrain height adjustment tool.

Set the Brush Size to 20, then in the Scene View, click on two to three spots around the player (not too near, though) to vary the terrain height.

Scene View after height adjusted.

Preview the game and move around the scene. Tweak the number of trees in the scene as you see fit but remember to stop the game before making any changes you wish to keep.

Game after scene enhancement done.

Save your scene.

Test your project using Unity Remote and when satisfied, build it as an Xcode project. Select File\Build Settings and in the Build Settings dialog, click Add Current to add the Level_2 scene. The new scene will show up in the Scenes In Build list. Deselect the Level_1 scene to build only Level_2.

Build Settings changes for new scene deployment.

Click Build, choose to replace the previous project if asked and then launch the Xcode project. Deploy and test on your iOS device.

Game on iOS.

Not bad, eh? Imagine how long it would have taken to do all this with raw OpenGL ;]

Where to Go From Here?

Well done! You’ve taken another big stride forward in developing your Unity skills. :] Soon, your Heroic Cube will be closing in on the finish line, too.

Here are some downloads with all of the code from the project up until this point: Unity Project, Xcode Project.

In the final part of the tutorial, you’ll build on the project by adding gameplay. Then you’ll polish it up by adding all the bells and whistles that players expect.

How do you like Unity so far? We’d love to hear about your experiences in the forums!

Christine Abernathy

Contributors

Christine Abernathy

Author

Over 300 content creators. Join our team.