After the first tutorial about Unity Interface Intro, in this one, we will learn how to create a basic terrain with Ground, Tree, Vegetation, Light and Sky.
Tutorial Information
- Difficulty: Beginner
- Platform used: Unity
- Estimated completion time: 2 hours
Unity Installation & Basic Control
Learning Unity – Basic Interface
Setup
If you are new to Unity, please refer to my previous tutorial about Unity Basic Interface and create a new project. It doesn’t matter what package we import in the beginning, we always can import more during the making.
Let’s create a new Scene in your project:
- Go to File/ New Scene (Ctrl + N)
- Go to File/ Save Scene (Ctrl + S)
- Name our scene as CreatingTerrain.
- Hit Save or Enter.
Import required packages:
- Go to Assets/ Import Package/ Character Controller/ Hit Import.
- Go to Assets/ Import Package/ Terrain Assets/ Hit Import.
- Go to Assets/ Import Package/ Skyboxes/ Hit Import.
Step 1:
Create flat terrain.
Go to Terrain/ Create Terrain.
Our Scene Panel should be like this:
Now we change the size of the terrain to be smaller.
Go to Terrain/ Set Resolution…
Modify the values of both Terrain Width and Terrain Length to be 500.
Notes:
We can see in the top-left corner of unity, there are 4 buttons:
From left to right we have:
- Pan: (shortcut P) move the scene camera around.
- Move: (shortcut W) move the selected object in X, Y, Z axis.
- Rotate: (shortcut E) rotate the selected object.
- Scale: (shortcut R) scale the selected object.
Step 2:
Let’s polypaint the terrain.
Click on the terrain in the scene, our Inspector should look like this:
The part that I underlined is the menu of different paint mode for terrain.
We will go over it one by one.
Click on the first item in the menu – Raise/ Lower Terrain.
We can see the Settings section under it, which display the modification option for the brush, such as Brush Size and Opacity.
I will leave the fun part to you, just play with different Brush Size and Opacity.
Remember we always can undo our action with Ctrl + Z.
The final of our terrain should have some mountains with variety of height as well as some flat areas.
My example:
Step 3:
Color the terrain.
Click the forth Icon in Terrain menu mode, which is Paint Texture.
Click the Edit Textures/ Add Texture….
There will be a new window popping up. Click Select in the Texture Section.
Double-click Cliff Texture.
Click Add Button.
Now your whole terrain should be painted with this texture.
But with only one texture, it seems kinda boring. So let’s add grass texture also.
Click the Edit Textures/ Add Texture….
Click Select in the Texture Section.
This time double-click in the Grass texture.
Click Add button.
There will be nothing happen.
…
So sad. We have to paint it the the terrain manually. Sign … 😀
Click the Grass texture in the Textures section.
Play with the brush Settings, and color some part of the terrain where we want to grow grass.
The final can be something as:
Step 4:
Add trees. A lot of trees.
Click the fifth Icon in Terrain menu mode, which is Place Trees.
Click the Edit Trees…/ Add Tree.
There will also be a pop-up window.
Modify Bend Factor to 0.2.
In the Tree attribute, click the circle icon with the dot in the middle.
Double-click the Palm tree.
Click Add button.
Now Paint the terrain with palm trees to have something like this.
Step 5:
Add Grass. A lot a lot of more grass.
Click the sixth Icon in Terrain menu mode, which is Paint Details.
Click the Edit Details…/ Add Grass Texture.
There will also be a pop-up window.
Change the Healthy Color and Dry Color to be a bit more realistic (not so bright as default) by click the color bar.
In the Detail Texture attribute, click the circle icon with the dot in the middle.
Double-click the Grass texture.
Click Add button.
Now we paint the terrain with the new grass texture.
Notes:
- This brush is very sensitive. It is easy to flood out, bit hard to control. Therefore, we should modify the Opacity and Target Strength to be a bit low. (0.1 and 0.125 respectively for my case)
- This brush is made specially to be seen in short distance. So if will paint the far area, it will still can be painted but we need to zoom in to see the result.
Step 6:
Play your game. Wow!
Make sure there is no First Person Controller object in your Hierarchy panel. If there is, click it and delete it.
In the Project panel, type First Person Controller in the search panel.
Then we drag First Person Controller object to the place of our starting position. Make sure it above the ground (press W and drag it up).
Now we click the play button in the top middle panel or press Ctrl + P.
If nothing goes wrong, it should be like this.
Notes:
Some basic controls:
- Up/Down/Left/Right Arrows: Move Forward/ Move Backward/ Move to the left/ Move the the right.
- W/S/A/D: same as Up/Down/Left/Right Arrows
- Space: Jump
- Ctrl + P: Back to working scene (Stop/Play)
- Ctrl + Shift + P: Pause/ Unpause
Step 7:
Add Light and Sky.
Go to GameObject/ Create Other/ Directional Light.
If we test the game it should be like this.
Now we add the sky by:
Go to Edit/ Render Settings
In the Inspector Panel, we click the setting circle in the Skybox Material attribute.
We double-click the Sunny1 Skybox Material.
Now, our terrain is finished.
Let start the adventure around this territory!!!!
Ending
Here we have the best map for our first game. So easy right? To make a map in Unity.
This type of map is best for FPS game, with a lot of enemies, guns, explosions.
Find us in the next tutorial for Unity and create our world together.