Unity3D Physics Keynote

1、在哪设置Layer Collision Matrix?

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

  Unity3D Physics Keynote-LMLPHP

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

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

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

  Unity3D Physics Keynote-LMLPHP

5、关了断裂。

  Unity3D Physics Keynote-LMLPHP

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

  Unity3D Physics Keynote-LMLPHP

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

 using UnityEngine;
using System.Collections; public class Script_06_12 : MonoBehaviour
{ //布料对象
Cloth cloth = null; void Start()
{
//获取布料对象
cloth = (Cloth)GetComponent<InteractiveCloth>();
} void OnGUI()
{
//移动布料
if(GUILayout.RepeatButton("向上"))
{
cloth.externalAcceleration = new Vector3(,,);
}
if(GUILayout.RepeatButton("向下"))
{
cloth.externalAcceleration = new Vector3(,-,); }
if(GUILayout.RepeatButton("向左"))
{
cloth.externalAcceleration = new Vector3(,,);
}
if(GUILayout.RepeatButton("向右"))
{
cloth.externalAcceleration = new Vector3(-,,); }
} }

8、通过TrailRender组件可以渲染走过的路径。通过以下代码可以操作此组件:

 public class Script_06_13 : MonoBehaviour
{
//路径渲染对象
private TrailRenderer trialRender; void Start ()
{
//获取路径渲染对象
trialRender = gameObject.GetComponent<TrailRenderer>();
} void OnGUI()
{ if(GUILayout.Button("增加宽度",GUILayout.Height()))
{
trialRender.startWidth +=;
trialRender.endWidth +=;
} if(GUILayout.Button("显示路径",GUILayout.Height()))
{
trialRender.enabled = true;
} if(GUILayout.Button("隐藏路径",GUILayout.Height()))
{
trialRender.enabled = false;
}
}
}

  

  

05-26 23:06