首页 > 其他 > 详细

PhysX

时间:2014-02-04 02:48:50      阅读:600      评论:0      收藏:0      [点我收藏+]

PhysX

 1、施加力:

bubuko.com,布布扣
 1         if(GUILayout.Button("普通力?",GUILayout.Height(50)))
 2         {
 3             //施加一个力,X轴方向力度为1000,Y轴方向力度为1000
 4             addFrceObj.rigidbody.AddForce (1000, 0, 1000);
 5         }
 6         
 7         if(GUILayout.Button("位置力",GUILayout.Height(50)))
 8         {
 9             //施加一个位置力,物体将会朝向这个位置发力移动,力的模式为冲击力。
10             Vector3 force = cubeObj.transform.position - addPosObj.transform.position;
11             addPosObj.rigidbody.AddForceAtPosition(force,addPosObj.transform.position,ForceMode.Impulse);
12         }
View Code

 2、刚体的碰撞回调:

bubuko.com,布布扣

 3、What is Kinematic Rigidbodies?

  A Kinematic Rigidbody is a Rigidbody that has the isKinematic option enabled. Kinematic Rigidbodies are not affected by forces, gravity or collisions. They are driven explicitly by setting the position and rotation of the Transform or animating them, yet they can interact with other non-Kinematic Rigidbodies.

  Kinematic Rigidbodies correctly wake up other Rigidbodies when they collide with them, and they apply friction to Rigidbodies placed on top of them.

 4、What is Static Collider?

  A Static Collider is a GameObject that has a Collider but not a Rigidbody. Static Colliders are used for level geometry which always stays at the same place and never moves around. You can add a Mesh Collider to your already existing graphical meshes (even better use the Import Settings Generate Colliders check box), or you can use one of the other Collider types.

 5、The Physics Material is used to adjust friction and bouncing effects of colliding objects.

  bubuko.com,布布扣

 6、Character Controller

  The Character Controller is mainly used for third-person or first-person player control that does not make use of Rigidbody physics.

  Character Controller组件用于帮助控制没有RigidBody的组件。

 7、Character Controller和RigidBody互斥,同一GameObject只能应用其一。

 8、SmoothFollow.js是内置Camear脚本组件,可以让某个Camera紧跟某个对象,实现第三人称Cemera。

  bubuko.com,布布扣

 9、使用Ray检测碰撞

bubuko.com,布布扣
1         //??????0??????
2         Ray ray = new Ray(Vector3.zero, transform.position);
3         //?????????
4         RaycastHit hit;
5         Physics.Raycast(ray, out hit, 100);
6         //?????????????????????????
7         Debug.DrawLine(ray.origin, hit.point);
View Code

  10、关节必须依赖于刚体组件。

 11、Triger与Collision分布图:

bubuko.com,布布扣

 12、动态添加关节组件:

bubuko.com,布布扣
 1         if(GUILayout.Button("添加链条关节"))
 2         {
 3             
 4             ResetJoint();
 5             jointComponent = gameObject.AddComponent("HingeJoint");
 6             HingeJoint hjoint = (HingeJoint)jointComponent;
 7             connectedObj.rigidbody.useGravity = true;
 8             hjoint.connectedBody = connectedObj.rigidbody;
 9         }
10         
11         if(GUILayout.Button("添加固定关节"))
12         {
13             ResetJoint();
14             jointComponent =gameObject.AddComponent("FixedJoint");
15             FixedJoint fjoint = (FixedJoint)jointComponent;
16             connectedObj.rigidbody.useGravity = true;
17             fjoint.connectedBody = connectedObj.rigidbody;
18         }
View Code

PhysX

原文:http://www.cnblogs.com/tekkaman/p/3537585.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!