[Basics of Unity] 9. Terrain system Terrain

[Basics of Unity] 9. Terrain system Terrain

        Hello everyone, I am Lampard~~
        Welcome to the Unity basic series blog. The knowledge I learned comes from Teacher Afa at Station B~Thank you 

(1) Terrain editor Terrain 

(1) Create terrain

    Most of the mountains, rivers and landforms in the game scene are created based on the terrain. Today we will learn to use the terrain editor that comes with Unity. The first thing is to create a terrain. When we right-click create 3Dobject, select Terrain .

    After the creation is successful, press F to select the terrain. You can see that this terrain looks larger, and the magic is that its anchor points are at its corners instead of in the center . We can click the settings button to adjust its size.

    Like other components, we can adjust its position property and rename it. Then the terrain data we adjust will be saved in the terrain file pointed to by Terrain Data.

(2) Terrain layer management

    Just like a 3D object will have a material, the surface of the terrain will also cover its layer to achieve effects such as grass, land, snow, sand, etc. So where to set it?

    First select our terrain object, and then see 5 buttons from left to right: Create Neighbor Terrain to create nearby terrain, Paint Terrain to draw terrain, Paint Tree to draw trees, Print Detail to draw details, and when we resize just now Encountered Terrain Setting terrain settings

    For terrain layer information, you need to select the second button, then select Paint Texture in the check box below , and find Terrain Layers in the attribute information below. The surface layer information is stored there.

(3) Create surface layer object

    We can right-click create in the Assert directory, and there will be something called Terrain Layer in the bottom list. By selecting it, we can set texture maps, normal maps and other information for it.

     For example, I made a grassland and a loess layer, and then just dragged it to the terrain editor. It supports multiple terrains.

    Then we see that the terrain in the scene changes to the color of grass. It seems that it uses the surface layer of grass by default.

    So what should I do if I want to set this terrain as a loess layer, or set some places as a loess layer?

    We can continue to draw the terrain in the Paint Terrain menu and scroll down. There is a Brushes brush below and a bunch of weird patterns next door.

    Its meaning is very simple, just like attaching a brush. You can select different Terrain Layers to "dye" the brush, then select patterns with different shapes and transparency, and set the brush head to paint in this terrain system.

    Well, it's complicated to say, but it's very simple to operate.

    So what should I do if I make a mistake with my hand and want to correct it? It's very simple. The first method is to use ctrl Z to go back. The second method is to reselect the grass layer and paint again.

    After we select the pattern, we can also refine and adjust its size and transparency below to achieve the desired effect.

(2) Flowers, plants and trees

(1) Create flowers and plants in batches

    Let's draw a random drawing on the grassland with the yellow earth surface, and it will feel like a country road.    

    Next we can plant some flowers and plants on it. If we only plant one or two plants, then we can directly make a prefabricated model and pull it onto the scene.

    But if we want to create a lot of flowers and plants in batches and let them be naturally distributed, then we can use the Print Detail function of the terrain editor to draw them in batches.

    First we create some flowers and plants. We first add our flower and plant resources in Details (drawing content). Click the Edit Details button and you can see that there are two options: Add texture and add mesh. We can add textures or models.

    We randomly found a few pictures of flowers and plants and loaded them in, so the resources are ready.

     The method of use is very similar to surface drawing. We first select the flower and grass resources we want to draw, and then just brush them directly on the terrain (remember to adjust the transparency and density, otherwise you will suffer from trypophobia...)

    And what should I do if there are too many paintings? It's very simple. You just need to hold down ctrl and brush a few times to delete the extra drawings.

    Through visual adjustments, we will find that if the view is pulled farther away, Unity will simulate the visual effects and make them smaller simultaneously. When a threshold is reached, it will not be displayed to reduce memory consumption.

    Also, no matter what angle we rotate to, the flowers and plants will face us . Obviously these flowers and plants are 2D resources. This effect is because the terrain editor will also rotate these flower and grass objects synchronously.

(2) Plant trees

    There is also a paint tree function in the terrain edit button, when we select it. Unity's special "tree" model can be added to the resource.

     In my impression, when we first learned about 3D objects, we saw a Tree object, so we can use it first to see the effect.

     Just brush it like flowers and plants, hahaha, just like Kimimaro’s ultimate move.

     It's too dense and ugly. Adjust the brush range and density, and change to a normal tree resource to see the effect.

(3) Mountains, rivers and lakes

(1) Mountain building

    Next we have to learn how to raise and lower the terrain. In the Print Terrain button, select the secondary option Raise or Lower Terrain option to increase or decrease the terrain.

    Similarly we can select the orogenic brush and adjust the size and height of the brush

     We can swipe a few times to see the effect. If we want to superimpose the effect, we can click a few more times. If we want to undo, we can ctrl Z to undo :

    If we want to set a fixed height of the top of the mountain, then we can perform the setHeight operation so that the mountain we build will not exceed this height.

(2) Make a lake

    The technology used in the process of building a lake is actually the raising and lowering of the terrain. If we want to dig out a lake, we first need to raise the terrain to a platform , because the height of the terrain itself is 0 and we cannot dig directly down.

   The next step is to dig a pit down on this raised platform. The height of our platform is 10, so let’s dig a pit of 5 meters.

   Then we paint it with our lake texture and use the print texture function to paint it . It just looks a bit like it hhhhhh

    Okay, let’s stop here today and do more complicated animation editing operations next week~
    Like and follow! ! !

Guess you like

Origin blog.csdn.net/cooclc/article/details/134937825