long time no learning and blog record, this year has been very lazy, slowly approaching the school, but also to adapt to the earlier, write something, so that the school can better enter the state AH ~ ~
in this note, we will carve out a more complete prefab and add a first-person character to the scene. this series of tutorials and footage is based on the translation tutorial "Unity Game Engine Basics Video Tutorial" from the Everyone's material translation group. Attached to the second note.
in the last tutorial we created a prefab, and in the end I built a simple tunnel using four prefab-vertex captures. This is just to signal the convenience of prefab, we will first remove this tunnel to only one prefab (delete in the left hierarchy view), and then make our prefab more finely crafted. our prefab.Four-sided is no physical system, no thickness, there will be no physical impact and other effects, put on the floor of things will fall indefinitely. So let's add a physical component to prefab. first expand the pfb_straight in the current scene from hierarchy, and select Mineshaft_floorClick Component,physics,box Collider on the System menu to add a box-shaped collider
Once added, there will be a green border on the floor and a newly added box collider component in the right Inspector View. We define the thickness of the collider according to our own circumstances, and I'll change Y to 0.01 in the box Collider component. This is to see you import the model scale, if you import the model format is 3d max, it should be 0.1. This self-observation, adjust the value, a very thin layer on it.
after the box collider has been established, the object touches the ground and does not fall down. Right-click the assets folder below to import the system's own Package--character Controller, which contains a first-person view and a third-person view of the small role.
we press the default to select all, do not move it, click Import can be introduced. After introduction Our assets folder will have a new subfolder named Standard assets.
Next, open the folder standard Assets--character Controllers, we can see a third-person miner character and a first-person character that resembles a capsule. we can check the current model by dragging in the bottom right corner of the preview screen, as shown in the two figure below.
and what we're going to do is drag the first-person controller into our scene and drag it up to fit the position.
at this point, if we click on the play button above, we can freely move and adjust the angle of view in our scene, the effect is like. because we do not set any light arts and background colors, etc., so the walls are black, the outside background is blue. If you play it down, it's your controller's position is too low, pan it up a bit.
Next we need to standardize our prefab and we need to make the center of the current preset the center of the physical space and let this prefab be built on top of the coordinate origin. In fact there are some errors at the moment, click on the current prefab, in the Inspector view you can see these errors. So let's tweak it to make our presets more perfect. The first step is to remove the parent-child relationship in the current scene first. That is, in the hierarchy view, select the four child elements within pfb_straight and drag out the range of the pfb_straight. The system will now prompt you, this will lose the current parent-child relationship, we click Continue. The hierarchy view changes to look like the following two graphs, and the child elements and our newly created game objects all turn white.
Next we select the empty game Object pfb_straight. Because we have built tunnels or other actions before, so now whether the floor or the ceiling wall, is not in the beginning we introduced after the adjustment based on the 0,0,0 position, so we first, we have to change the coordinates of four small parts back. first check Mineshaft_floor, we adjust its coordinates to 0,0,0, and then hold v like the beginning of the two walls dragged past, and then change mineshaft_ceiling to 0,0,0. Then move our first person controller into space. Next we select the four small pieces and drag them into the pfb_straight, and we'll see that the presets don't turn blue.
The reason is very simple, think we have broken the prefab father-son relationship, so we select Prefab, in the Inspector view, click Apply, the mouse pauses, he will appear detailed explanation. When you click Apply, the changes we make are applied to the default presets, which are each of the presets we drag behind, and the coordinates are in the physical center. Of course we can also click Apply next to revert revocation.
at this point we have created a well-established coordinate value and the axis is standard, the floor has a physical model of the prefab, and on the floor of prefab added a first person controller.
2015.2.27 0:03by Mr.losers
Unity Learning Note Four perfecting prefab and adding first person Controller