Getting started with Unity3D

1. Initial development tools

   Scence: Edit the scene and list all the objects in the scene.

   Game: The panel seen by the player, captured by the camera in the scene

   Project: Project panel, manage all the resource files in a project, the Project panel and the Assets folder in the project folder are completely connected

   Hierarchy: Hierarchy panel, used to manage all GameObjects in the scene, and display all objects in a hierarchical form

   Inspector: Inspector panel, showing components and properties on a game object

Two. Unity component

   Mesh Filter Mesh filter determines the shape of the game object

3. Use of Material

Custom materials. See api documentation for details

4. Use of Terrain

1. Ascending terrain

    Bursh brush style

    Bursh size

    Opcity brush hardness

    Press and hold shift to descend the terrain, the lowest can drop to 0

2. Constant height terrain

3. Smooth terrain

4. Draw the ground texture

 

Five.PhysicMaterial physical material (bouncing friction)

 

bounceCombine Clarify how the elasticity is combined.
bounciness                                                 How elastic is the surface? A value of 0 will not be flexible. A value of 1 will be elastic without any energy loss.
dynamicFriction                                  Friction is used when it has moved. The value is between 0 and 1.
frictionCombine     Clarify how friction is combined.
staticFriction                                    When the object lies on the surface, the friction coefficient is used.

Six. Use of coordinate system

World coordinate system
Local coordinate system
Camera coordinate system Viewport
screen coordinate system
unity uses left-handed coordinate system
x axis right y axis up z axis in

--------------------- Get horizontal axis --------------------

float horizontal = Input.GetAixs("Horizontal")

--------------------- Get vertical axis --------------------

float vertical = Input.GetAxis("Vertical");

------------------- Get your own coordinates ---------------------

transform.position

-------------------- vector3 three-dimensional vector ---------------------

back Write a shortcode for Vector3 (0, 0, -1).
down Write a shortcode for Vector3 (0, -1, 0).
left Write a shortcode for Vector3 (-1, 0, 0).
one Write a shortcode for Vector3 (1, 1, 1).
right Write the shortcode of Vector3 (1, 0, 0), which is to the x axis.
up Write a shortcode of Vector3 (0, 1, 0), which is to the y axis
forward Write the shortcode of Vector3 (0, 0, 1), which is to the z axis.
zero Write a shortcode for Vector3 (0, 0, 0).
//创建一个坐标
Vector3 position = new Vector3(x , y , z);

------------------------ rotation ------------------------

//局部旋转
transform.localRotation 
//变换角度
transform.Rotation 

Quaternion.LookRotation (a parameter representing the x, y, and z coordinates of the rotation)

//需要变换多少角度,根据坐标变化角度
transform.Rotation = Quaternion.LookRotation(new Vector3(1f,0f,0.3f));

----------------------- Panning forward ------------ -

transform.Translate (a parameter indicating how much distance to move)

transform.Translate(Vector3.forward * speed * Time.deltaTime);

transform.Translate (one parameter, indicating how much distance to move, the second parameter is based on world coordinates)

transform.Translate(Vector3.forward * speed * Time.deltaTime,Space.World);

 

Seven. Receive user input (Input)

Mouse input:

input.getButton("Fire1");

input.getButtonDown (0); // means the left mouse button

input.getButtonUp (1); // 1 means the right mouse button

keyboard input:

input.getKey (); // default

input.getKeyDown (); // Press to trigger

input.getKeyUp (); // Wait when the mouse is raised

 

8. The basic method of MonoBehaviour

    Awake:顾名思义,Unity3D的脚本苏醒时需要调用的方法,这个方法比Start方法执行的还要早,也是执行一次。


    Start:可以理解为类的构造函数,或者是init函数,用于初始化各种变量,仅执行一次。


    Update:类似于flash AS3 onframe的回调函数,每帧均回调。


    Fixedupdate:每一帧都执行,处理Rigidbody时,需要用FixedUpdate代替Update。例如:给刚体加一个作用力时,你必须应用作用力在FixedUpdate里的固定帧,而不是Update中的帧。(两者帧长不同)FixedUpdate,每固定帧绘制时执行一次,和update不同的是FixedUpdate是渲染帧执行,如果你的渲染效率低下的时候FixedUpdate调用次数就会跟着下降。FixedUpdate比较适用于物理引擎的计算,因为是跟每帧渲染有关。Update就比较适合做控制。


    Lateupdate:每帧均回调,但每次均在Update之后再调用。


    OnGUI:每帧均回调,用于绘制GUI对象。


    Reset:用户点击检视面板的Reset按钮或者首次添加该组件时被调用。此函数只在编辑模式下被调用。Reset最常用于在检视面板中给定一个最常用的默认值。


    OnDisable:当物体被销毁时 OnDisable将被调用,并且可用于任意清理代码。脚本被卸载时,OnDisable将被调用,OnEnable在脚本被载入后调用。注意: OnDisable不能用于协同程序。


    OnDestory:当MonoBehaviour将被销毁时,这个函数被调用。OnDestroy只会在预先已经被激活的游戏物体上被调用。注意:OnDestroy也不能用于协同程序。

 

Published 23 original articles · Like 11 · Visits 30,000+

Guess you like

Origin blog.csdn.net/weixin_42279584/article/details/103182601