Difference between revisions of "Terrain"
(→Hills and Valleys (Adjusting Terrain Height)) |
(→Trees and Plants) |
||
(28 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | [http://space.apps.uri.edu/wiki/index.php?title=Learn_Unity_First '''Main guide page'''] | |
If you haven't already, please read the [http://space.apps.uri.edu/wiki/index.php?title=Materials previous part] to this tutorial. | If you haven't already, please read the [http://space.apps.uri.edu/wiki/index.php?title=Materials previous part] to this tutorial. | ||
=Create the Terrain object= | =Create the Terrain object= | ||
− | In the Game Object menu, Terrain is under | + | In the Game Object menu, Terrain is under 3D Object. |
[[File:newTerrain.png|800px]] | [[File:newTerrain.png|800px]] | ||
+ | |||
+ | You can also right-click in the tab labeled Hierarchy (see below, the blue dot is where I right-clicked). To get this menu you can right click anywhere inside the Hierarchy tab, as in underneath the tab name of Hierarchy. | ||
+ | |||
+ | [[File:createTerrain.png]] | ||
+ | |||
+ | Then, go down to 3D Object, and from the sub-menu that appears, choose Terrain. | ||
+ | |||
+ | Once you pick terrain from one of those places, you should see a large blank plane appear, but when you select it in the hierarchy, there are plenty more interesting options in the Inspector. | ||
+ | |||
=Editing Terrain= | =Editing Terrain= | ||
− | ==Hills and Valleys | + | ==Hills and Valleys - Adjusting Terrain Height== |
[[File:raiseTerrain.png]] | [[File:raiseTerrain.png]] | ||
− | [[File:terrainHeight.gif | + | [[File:terrainHeight.gif]] |
+ | |||
+ | Select the terrain icon that has an up arrow, then click (or click and drag to make continuous formations) anywhere on the terrain plane to raise it at that point. pressing shift while clicking will lower that part of the terrain, though it won't go below the terrain's initial level, no matter what y coordinate that may be. | ||
+ | |||
+ | ==Adding Texture to the Terrain== | ||
+ | Pick the paintbrush icon from the terrain toolbar. [[File:paintTerrain.png]] | ||
+ | |||
+ | [[File:defaultTerrain.gif]] | ||
+ | |||
+ | Add a texture to paint with by going to Edit Texture, then Add Texture, then Albedo (RGB) and Smoothness (A), Select, and choose a compatible image type for your terrain. To enlarge the images in the selection window, use the slider on the top right corner of that selection window. Only textures that are in somewhere in your assets will show up, so import any images you'd like to use first. The first texture you add becomes the default for the entire terrain. If you add another texture aside from that first one, you can paint over the default with the newly added one. Whichever texture has the blue line or rectangle underneath is the texture you have currently selected to paint with. | ||
+ | |||
+ | |||
+ | '''Brush size''' is the size of the area you'll edit by clicking on the terrain once. | ||
+ | |||
+ | '''Opacity''' is the transparency or amount of texture applied for a given amount of time you paint. | ||
+ | |||
+ | '''Target Strength''' is the maximum opacity you can reach by painting continuously. | ||
+ | |||
+ | [[File:paintTerrain.gif]] | ||
=Trees and Plants= | =Trees and Plants= | ||
+ | In your Standard Assets folder you should already have another folder labeled 'Environment', but if you don't, import it now. | ||
+ | |||
+ | First, select the Tree icon. [[File:treeIcon.png]] | ||
+ | |||
+ | ==Add a Tree== | ||
+ | Pick Edit Trees > Add Trees, and then when the window comes up, use the file picker (circled below) to choose something that looks like a tree. It can really be anything you want, but if it isn't setup right as a tree, things may be generated wrong. | ||
+ | |||
+ | [[File:addTree.png]] | ||
+ | |||
+ | ==Using the brush to place trees== | ||
+ | '''Brush size''' is how large the area you would like to paint with for 1 click. | ||
+ | |||
+ | '''Tree Density''' is how many trees will get placed in the circle when you click or move the mouse when you click and drag. Shift click to remove trees in the area you click with a radius of the chosen brush size. | ||
+ | |||
+ | [[File:trees2.gif]] | ||
+ | |||
+ | ==Mass placement== | ||
+ | This is another placement method that tells Unity to place the given number of trees evenly across the entire terrain, with some randomness involved. Most of the time it's easier to do this and then delete trees in areas you don't want than to use the brush and try to manually distribute them in all the areas you want. (Trees won't be placed on areas that Unity determines to be too steep a hill for a tree) | ||
+ | |||
+ | [[File:massPlace.gif]] | ||
+ | |||
+ | '''Note for trees and Custom Trees:''' | ||
+ | You can use any of the trees Unity provides in the Environment folder of Standard Assets or find some different ones on the Asset Store. You can also create your own trees that use Unity's random tree generator system to make every tree look slightly different. To do that, create a tree with GameObject > 3d Object > Tree, design the single tendril that appears as you want, and add it to the tree list to make more. You can also edit the trees given by Unity by dragging one into the scene and messing with it in the inspector tab. | ||
+ | |||
+ | =Water= | ||
+ | The water Unity gives by default in Environment is actually pretty good, and you can choose from several: the ones in Water > Water, Water> Water4, and Water > Water (Basic). For all of them the relevant objects are in a Prefabs folder. The first is reflective, transparent, and has small waves, and seems suited for small lakes or ponds or maybe puddles. The second is also reflective and transparent but has but much bigger waves, and seems suited for much larger bodies of water. It is also the most complex, and best looking, of these options. The last one (basic) is not reflective or transparent, this one should be used if you're targeting systems with less graphical power or framerate is getting bogged down too much already. Another issue with all of these is that the water is only one layer, so when you go under the water it doesn't really look... underwater, so keep that in mind. That problem can be fixed with some scripting, and this is something I will be talking about later. | ||
+ | |||
=Wind Zones= | =Wind Zones= | ||
+ | Wind zones can very easily help to make your world look less static and more lively by making the leaves on the trees (and particle systems) move around. One can be created by going to GameObject (or right-click in the hierarchy) > 3d Object > Wind Zone. Once a zone is placed it affects the whole scene by default, and this can be changed if you pick spherical to be its mode. Main affects the overall wind strength, while Turbulence is what allows for a bit of variation in the wind patterns. | ||
+ | |||
+ | [http://space.apps.uri.edu/wiki/index.php?title=Physics&action=edit&redlink=1 Go on to the next part, Physics!] |
Latest revision as of 09:19, 7 November 2017
If you haven't already, please read the previous part to this tutorial.
Contents
Create the Terrain object
In the Game Object menu, Terrain is under 3D Object.
You can also right-click in the tab labeled Hierarchy (see below, the blue dot is where I right-clicked). To get this menu you can right click anywhere inside the Hierarchy tab, as in underneath the tab name of Hierarchy.
Then, go down to 3D Object, and from the sub-menu that appears, choose Terrain.
Once you pick terrain from one of those places, you should see a large blank plane appear, but when you select it in the hierarchy, there are plenty more interesting options in the Inspector.
Editing Terrain
Hills and Valleys - Adjusting Terrain Height
Select the terrain icon that has an up arrow, then click (or click and drag to make continuous formations) anywhere on the terrain plane to raise it at that point. pressing shift while clicking will lower that part of the terrain, though it won't go below the terrain's initial level, no matter what y coordinate that may be.
Adding Texture to the Terrain
Pick the paintbrush icon from the terrain toolbar.
Add a texture to paint with by going to Edit Texture, then Add Texture, then Albedo (RGB) and Smoothness (A), Select, and choose a compatible image type for your terrain. To enlarge the images in the selection window, use the slider on the top right corner of that selection window. Only textures that are in somewhere in your assets will show up, so import any images you'd like to use first. The first texture you add becomes the default for the entire terrain. If you add another texture aside from that first one, you can paint over the default with the newly added one. Whichever texture has the blue line or rectangle underneath is the texture you have currently selected to paint with.
Brush size is the size of the area you'll edit by clicking on the terrain once.
Opacity is the transparency or amount of texture applied for a given amount of time you paint.
Target Strength is the maximum opacity you can reach by painting continuously.
Trees and Plants
In your Standard Assets folder you should already have another folder labeled 'Environment', but if you don't, import it now.
Add a Tree
Pick Edit Trees > Add Trees, and then when the window comes up, use the file picker (circled below) to choose something that looks like a tree. It can really be anything you want, but if it isn't setup right as a tree, things may be generated wrong.
Using the brush to place trees
Brush size is how large the area you would like to paint with for 1 click.
Tree Density is how many trees will get placed in the circle when you click or move the mouse when you click and drag. Shift click to remove trees in the area you click with a radius of the chosen brush size.
Mass placement
This is another placement method that tells Unity to place the given number of trees evenly across the entire terrain, with some randomness involved. Most of the time it's easier to do this and then delete trees in areas you don't want than to use the brush and try to manually distribute them in all the areas you want. (Trees won't be placed on areas that Unity determines to be too steep a hill for a tree)
Note for trees and Custom Trees: You can use any of the trees Unity provides in the Environment folder of Standard Assets or find some different ones on the Asset Store. You can also create your own trees that use Unity's random tree generator system to make every tree look slightly different. To do that, create a tree with GameObject > 3d Object > Tree, design the single tendril that appears as you want, and add it to the tree list to make more. You can also edit the trees given by Unity by dragging one into the scene and messing with it in the inspector tab.
Water
The water Unity gives by default in Environment is actually pretty good, and you can choose from several: the ones in Water > Water, Water> Water4, and Water > Water (Basic). For all of them the relevant objects are in a Prefabs folder. The first is reflective, transparent, and has small waves, and seems suited for small lakes or ponds or maybe puddles. The second is also reflective and transparent but has but much bigger waves, and seems suited for much larger bodies of water. It is also the most complex, and best looking, of these options. The last one (basic) is not reflective or transparent, this one should be used if you're targeting systems with less graphical power or framerate is getting bogged down too much already. Another issue with all of these is that the water is only one layer, so when you go under the water it doesn't really look... underwater, so keep that in mind. That problem can be fixed with some scripting, and this is something I will be talking about later.
Wind Zones
Wind zones can very easily help to make your world look less static and more lively by making the leaves on the trees (and particle systems) move around. One can be created by going to GameObject (or right-click in the hierarchy) > 3d Object > Wind Zone. Once a zone is placed it affects the whole scene by default, and this can be changed if you pick spherical to be its mode. Main affects the overall wind strength, while Turbulence is what allows for a bit of variation in the wind patterns.