Unity3D Physics Keynote

1、在哪设置Layer Collision Matrix?

  "Edit"->"Project Settings"->"Physics"。

  Unity3D Physics Keynote

2、“Import Package”->"Physic Meterial",是Unity自带的物理材质包。

3、"Import Package"->"Character Controller",是Unity自带的视角控制器。

4、生成从摄像机到点的Ray,并判断与Ray相交的点。

  Unity3D Physics Keynote

5、关了断裂。

  Unity3D Physics Keynote

6、joint通过connectedBody进行与其它对象的连接。

  Unity3D Physics Keynote

7、布料,Interactive Cloth、Cloth Render两个组件共同组成了布料。通过以下代码可以操作布料:

 1 using UnityEngine;
 2 using System.Collections;
 3 
 4 public class Script_06_12 : MonoBehaviour 
 5 {
 6 
 7     //布料对象
 8     Cloth cloth = null;
 9     
10     void Start()
11     {
12         //获取布料对象
13         cloth = (Cloth)GetComponent<InteractiveCloth>();
14     }
15     
16     void OnGUI()
17     {
18         //移动布料
19         if(GUILayout.RepeatButton("向上"))
20         {
21             cloth.externalAcceleration =  new Vector3(0,1,0);
22         }
23         if(GUILayout.RepeatButton("向下"))
24         {
25             cloth.externalAcceleration =  new Vector3(0,-1,0);
26     
27         }
28         if(GUILayout.RepeatButton("向左"))
29         {
30             cloth.externalAcceleration =  new Vector3(1,0,0);
31         }
32         if(GUILayout.RepeatButton("向右"))
33         {
34             cloth.externalAcceleration =  new Vector3(-1,0,0);
35     
36         }
37     }
38 
39 }
View Code

相关文章: