Game terrain
In the gaming world, there must be a variety of game elements integrated. They are diverse and have little effect. Generally, game elements can be divided into two types: Frequently used and not commonly used. Common elements are important elements in the game. You generally need to use scripts to implement some special functions. For example, the main character object controlled by a player and the enemy to be attacked. Therefore, common elements directly affect the operation of the game, but not uncommon elements, such as the sky and clouds in the game. It does not affect the main line of the game, but only improves the overall effect of the game.
Create terrain
In 3D games, ups and downs often occur. This article introduces how to create game terrain in a game.
First, select terrain ---- create terrain in the navigation bar to create a game terrain. The enrollment diagram is displayed:
(After I rotate it closer, you can watch it more intuitively)
Terrain Parameters
The terrain parameters include the width, height, length, resolution, and height of the terrain. After creating a terrain, you can modify it as needed. Select terrain ---- set resolution from the navigation menu. The heightmap resoluton window is displayed. Enter the modification directly.
The following describes the parameters in the heightmap resoluton window:
Terrain width: Total terrain width
Terrain Height: Total Terrain Height
Terrain length: Total terrain Length
Heightmap resoluton: Resolution of the terrain height chart
Detail resolution: detailed resolution, mainly used for grass on the terrain or other models. The higher the value, the better the display effect. Of course, higher machine configurations are also required.
Detail resolution per Patch: detailed resolution patch
Control texture resolution: Controls texture resolution
Base texture resolution: relative texture resolution
Edit terrain
So far, our terrain is just a huge plane. To achieve ups and downs, select terrain in the hierarchy view. In this case, the terrain is edited in the Inspector view on the right.
A button is displayed in the terrain menu:
Their meanings are: editing the Terrain Height, editing the specific Terrain Height, smoothing over-terrain, topographic maps, adding tree models, adding grass and grid models, and other settings.
The following figure shows the terrain paint brush:
Brush size: paint width value range
Opacity: Specifies the value range of the paint height.
After selecting the terrain menu and paint brush, you can edit the terrain ups and downs. However, because the terrain map is gray by default, it will be very ugly.
In the terrain menu, click the second button (edit the specific Terrain Height) to go to the page for setting the specific Terrain Height. Like the previous page, there is only one additional height:
On the Edit Terrain Height page, the opacity is the maximum height, while on the edit specific height page, the height is the maximum height. For example, if the opacity value on the editing page is 100 and the height value is 80, the highest terrain is 80.
For example, in the terrain menu, click the third button (smooth transition terrain), select a suitable paint brush, and then smooth the over-terrain.
Smooth Topographic Map:
After a terrain is created, the terrain collider component is automatically added to the terrain. This component allows the terrain to sense the collision with other objects. After a physical material is given to the terrain skin, objects on the terrain will collide according to the Set collision parameters, such as elasticity, power, friction, and so on.
Material: physical material. It sets the physical friction effect after the model and terrain collide.
Is trigger: whether to enable terrain collision
Terrain Data: terrain resource, connected to the terrain file in the project view
Create tree colequalers: whether to create a Tree Collision
Terrain Maps
The default gray terrain is not flattering. In reality, in order to make the terrain look more beautiful. Unity provides standard terrain resource packages. First, we need to import the terrain resource package into the current project. Right-click the project view and choose import ----- terrain assets.
After importing the image, you can learn how to add a new texture to the terrain. First, click the fourth button (terrain map) in the terrain menu bar. You can find that there are no terrain maps in the textures list. Click Edit --- textures (edit texture) in the lower right corner to bring up a selection list.
In the selection list, select Add textures to display the Left window.
Briefly describe the meanings of each parameter:
Texture: select a terrain map from the resource folder.
Normal map: select a normal terrain map in the resource folder.
Size X: X axis width of the texture
Size Y: the Y axis width of the texture.
Offset X: the offset of the X axis of the texture.
Offset Y: the offset of the texture Y axis.
Click Select in texture. The select texture2d window is displayed. All the texture files on the page are from the folder in the project view.
Double-click any texture in the select texture2d window, and click Add in the lower right corner of the add terrain textures window.
After adding a terrain map, you can render the texture. Select a Paster folder and select a rendering pen. Finally, render the image directly in the scene view.