Chapter 2 simple unity3d Preview
Each unity3d version comes with a demo source file. In the official version 3.0, the demo is the powerful shooting game displayed on the Internet. In general, you only need to open unity3d V3.0 for the first time and you will see the demo project file that comes with it. However, if unity3d does not open this project file, you can also click the "open project" option under the "file" menu in unity3d, in "C: in the path \ Documents ents and Settings \ All Users \ Documents ents \ unity projects, find the project folder "bootcamp Demo" and select and open it. After opening the project, if nothing is displayed on the stage scenario panel, double-click the scenario file in the project [project file bar ].
. After a moment, all objects in the stage scenario can be imported to the stage scenario. After the import is successful, the result is 2.1:
Click the play button in the middle to perform a test (if your machine configuration is not very high, it may take a little longer to wait ). Wait a moment and you will be able to see a running shooting game in game [animation panel.
In this game scenario, you will see more delicate and realistic screen effects than other mainstream games, such as real-time shadows of various objects. 2.2:
Of course, if your machine configuration is high, you can also click the "ESC" key to further increase the game quality. The adjustment page 2.3 is shown in the following figure:
Next, let's take a look at the game screen comparison before and after adjusting the screen effect, as shown in Figure 2.4.1 and figure 2.4.2:
Obviously, we can feel that the effects of river water and the effects of the shadow in scenes are quite real.
Chapter 3 create a terrain map in unity3d
In the previous two chapters, we carefully explained the unity3d interface and performance. I believe that many of my friends have tried to operate unity3d by themselves after seeing such a powerful screen effect. Next, we will try to create a mountain map in unity3d.
Step 1: Create a new project.
Open the unity3d software and it will automatically load the "bootcamp Demo" project file we opened last time. Don't worry about it. After the software is opened, click -->. In the displayed dialog box, find the folder address for project creation, or click "select a folder address" next to it (note: the folder of the unity3d project that has been created cannot be used as the folder of the newly created Project. Otherwise, an error is reported because the file cannot be found.) then, select the project file package to be imported in, each package has some plug-in functions. Since we created the project file for the first time, we checked all the check boxes. However, this will slow unity3d loading. After that, we will all be familiar with the functions of each plug-in package. when creating the unity3d project file, you only need to select the plug-in package to be used. Option panel 3.1:
After all settings are complete, click Create project.
Step 2: Create a terrain.
After creating a new project, we can see that only the project [project file bar] contains two folders, these two folders contain all the files in the project package imported during project creation. In addition, other la s are empty. Don't worry. We will use the File package and system functions to enrich the content of each layout right away. First, click --> on the menu bar to create a plane with terrain attributes, as shown in Figure 3.2:
Step 3: Add a camera.
After creating the terrain, we will find that there is still no picture in game [animation panel. In fact, the truth is very simple, just like the live broadcast of the concert. The scenes are all set up, and actors are performing on the stage, but there is no camera. How can the audience in front of the TV see the scene?
Next we will create a camera. Click --> to create a camera in the scenario. This allows you to view the star image observed by the camera in game [animation panel. 3.3:
Step 4: Adjust the terrain size.
By default, the terrain created by the system is 2000*2000 square meters, which is very large during actual editing and inconvenient to operate. Therefore, we adjusted the terrain area, for further editing.
Click --> on the menu bar to bring up a panel to adjust the size of the ground. Change the number to 500. Then, change the number to 500. click the button to change the original terrain to an area of 500*500.
Step 5: Edit materials for the scenario.
Select the created ground object in the scenario panel, you can also select the expected object in hierarchy's hierarchical list, which contains the object objects in all scene panels. After selecting the ground object, we will immediately find the corresponding property in Inspector [attribute panel], including: position [coordinates], rotation [rotation quantity], scale [scaling size], and inherent sum of Ground Objects. 3.4:
The button like a paint brush is used to change the texture of the ground. After clicking it, we can find the button below and click --> to go to the page, as shown in Figure 3.5:
Click the circle next to it to add your favorite materials to the ground. After the selection, click the button to fill in the new material. The ground 3.6 After the material is added is shown as follows:
If you think the texture of this terrain is too simple, you can click --> to add the second material, and then select the desired brush shape in 3.7, as shown in:
Then you can click the area range of the new material on the scene panel. 3.8:
Step 6: Create a mountain.
After the ground material is created, you can create a mountain.
Click one of the three buttons and select the appropriate paint brush. In the topographic map, the shape of the mountain is displayed, as shown in Figure 3.9:
If you think that the mountain we have painted is too high, you can hold down the Shift key and use the selected brush to reverse fl.
Step 7: plant grass and trees.
Next we can plant some grass and trees for the terrain. The specific planting button is, the planting button is. The methods for setting grass and trees are similar to those for setting terrain materials. You need to click the button to add the required flowers and trees, then, fl the required area in the scenario panel. 3.10:
Note that unity3d adopts the method of removing resources in the editing mode to save resources. If you do not see the grass you planted while using the brush, you only need to zoom in to observe the effect of the grass. 3.11:
Step 8: Set the wind speed and shadow effects on the terrain.
Planting grass and trees makes people feel unnatural if they are still running in the game, so we add wind and shadow effects to the terrain to let the grass swing with the wind, this will become more realistic.
Click the button to set the wind speed, shadow, and other effects on the terrain. 3.12:
Step 9: add the illumination effect.
All effects related to the terrain have been set, but we found that the screen in game [animation panel] is very dark, because no light is added.
Click --> to create a sunlight effect. 3.13:
The relationship between the sun light and the sun itself is not big, but only from its own perspective. This is consistent with the sun in our daily life. To make the scenario brighter, we need to use the rotate button in the scenario adjustment tool to rotate the sunlight. You can also adjust it in the property panel. According to our common sense, when the sun shines directly on the ground, the light is the strongest. The adjusted effect is as follows:
How is the screen in game [animation panel] highlighted a lot?
Step 10: camera observation settings.
To enable the camera to fully observe the scenario we just created, you can find and find the three script files in the project [project file bar, and drag them to the camera in the scenario in sequence. 3.15:
If you think there are too many files in the project [project file bar], you can enter their names in the search box at the top of the project [project file bar] to search. In this way, you can quickly find the corresponding file. After the placement is complete, click the test button and you will be able to roam in the game [animation panel] You just created. Use the mouse to control the Angle of View and the arrow key of the keyboard to control the walk. During the process of roaming, you can clearly see the grass just created gently swinging with the breeze. Result 3.16:
Step 2: add the sky effect.
At this time, the sky we see in game [animation panel] has no effect. Next we will add a sky box to the scene to make the scene have a blue sky effect.
Select the camera object in the scenario, and click --> in the menu bar to add a sky box to the camera. After the camera is successfully added, we can find the added sky box in the camera property panel.
Go to the project [project file bar] and find the "skyboxes" folder under the "Standard assets" folder. There are many material balls for the sky. You only need to select one of your favorite materials for the sky, drag and Drop the material attribute [custom skybox] of the sky box [skybox] That leaves the camera to fill the sky of the scene with this material effect. 3.17 and figure 3.18 are shown in the following figure:
Select the illumination object in the scene, find "flare" in its property panel, and click the circle behind it. In the pop-up dialog box, double-click the illumination effect so that you can clearly see the position of the sun in the Animation Mode. Run the animation to see the effect.
Step 2: Add a shadow effect.
Careful friends will surely find that the trees and other objects in the current scene do not have shadows, which is not natural. Therefore, to make the scenario more realistic, we can also add the light shadow effect to the scenario.
The method is as follows: select a light object and find it in its property panel. The default value is (no shadow). You can change it to "soft ".
Shadows, soft shadow, or hard shadows, hardware shadow ]. "Soft Shadows" and "soft rendering shadow" produce shadow effects at the cost of CPU computing. This mode is slow to run, but it is the only choice for users with relatively low machine configurations. "Hard shadows" [hardware rendering shadow] uses the graphics card acceleration function of the Next Generation GPU to render the shadow effect for the game. It runs fast and has an ideal rendering effect. However, no matter which option you choose, the animation scene objects will have a longer shadow effect than the sunlight. 3.19:
Step 2: Save the project.
After debugging is complete, press Ctrl + S to save the scenario file, which is called "text" for future calls. If the file is successfully saved, you will see such a file in the project file bar of your project.