It may be easy to start learning U3D and record some learning things. Do not spray.
In the terrain, I placed a model of a truck and used the arrow keys to control the movement of the truck. The camera follows the movement of the truck.
I will not record the basic operations.
1. First, create a terrain map, add a terrain map, brush a bit of grass, and then plant a Vertex Tree. OK. A simple terrain is formed.
2. How are trucks controlled?
First, create a cube. It is very easy to control a cube. Add a write control script for this cube.
VaR movespeed = 5;
VaR rotatespeed = 20;
Function Update (){
If (input. getkey (keycode. W )){
This. Transform. Translate (vector3.forward * time. deltatime * movespeed );
} Else if (input. getkey (keycode. s )){
This. Transform. Translate (vector3.forward * time. deltatime *-movespeed );
} Else if (input. getkey (keycode. )){
This. Transform. Rotate (vector3.up * time. deltatime *-rotatespeed );
} Else if (input. getkey (keycode. d )){
This. Transform. Rotate (vector3.up * time. deltatime * rotatespeed );
}
}
The code is very simple, that is, to move the cube through the keyboard.
Now a cube can be moved. How can we move a truck?
Set the position of the cube to (0, 0), and set the position of the truck to (0, 0, 0 ).
Note that the zaxis direction of the cube and truck should be the same. Scale the Cube as big as the truck, and then remove the mesh Renderer of the cube. In this way, the cube appearance will not be rendered. Move the truck to the cube in the hierarchy panel.
In this way, the cube is moved.
Finally, do not forget to set camera to follow the cube.