zoukankan      html  css  js  c++  java
  • Unity—Rigidbody-Collider笔记

    翻译转载自官方文档圣典等处:

    ceeger link

    Kinematic:

    当刚体标记为运动学模式,他不会受到碰撞,力及任何物理影响,它表示你必须直接通过(Transform.position/.rotation)变换的方式来操纵该物体。

    运动学模式的刚体会与其他物体进行物理交互,但自身不受物理系统的影响。例如,通过关节约束那些和运动学刚体连接起来的刚体,那些与之发生碰撞的刚体则会受到运动学刚体影响,受到物理系统控制影响。

    Colliders:碰撞器

    Colliders define the physical boundaries of a Rigidbody 碰撞器定义刚体的物理边界,它和刚体一起,来使碰撞发生。如果两个刚体撞在一起,物理引擎将不会计算碰撞除非它们包含碰撞器组件

    没有碰撞器的刚体,会在物理模拟中相互穿透。

    Static Colliders 静态碰撞器

    一个包含碰撞器但不含刚体的游戏对象,to create floors, walls and other motionless elements of a scene。

    (disabled/enabled, moved or scaled during gameplay),不要在gameplay期间,做出以上()内改变,否则,改变静态碰撞器将导致物理引擎的内部计算,非常耗费资源,而且会造成性能的极大下降,更糟的是可能

    会产生未定义的错误物理模拟现象。

    ***Consequently,If you want a collider object that is not affected by incoming rigidbodies but can still be moved from a script then you should attach a Kinematic Rigidbody component to it rather than no Rigidbody at all.

    Continuous Collision Detection 连续碰撞检测

    连续碰撞检测是为了防止快速移动 的碰撞器相互穿过的一个功能。当使用标准(Discrete)碰撞检测时,当一个碰撞器和另一个碰撞器的只有一帧的距离,并且在下一帧通过碰撞器,可能出 现这个问题。为了解决这个问题,

    可以在快速移动物体的刚体上启用连续碰撞检测。设置碰撞检测模式为Continuous防止刚体通过任意静态(如,非刚 体)网格碰撞器。

    设置为Continuous Dynamic也防止刚体穿过任意其他检测模式设置为Continuous 或 Continuous Dynamic的刚体。

    Friction and bouncyness 摩擦力和弹力

    riction, bouncyness and softness are defined in the Physic Material.

    摩擦力、弹力和柔软度由物理材质中定义。标准资源( Standard Assets)中包含了大部分常见的物理材质。要使用只需点击物理材质上的下拉箭头然后选中一个,比如冰。你也可以创建你自己的物理材质并调整摩擦力的大小。

     Mesh Collider--网格碰撞器

    通常,两个网格碰撞器之间不会发生碰撞。所有的网格碰撞器可以和任何原始碰撞器碰撞。如果网格标记为凸起的(Convex),那么就可以和其他网格碰撞器碰撞。

    除非被标记为凸起的(Convex),否则网格碰撞器间不会发生碰撞。因此,它们最常被用于背景对象比如环境布景。

    原型控制器(Primitive Colliders)对于对象的物理控制更加节省资源。

    要给一个对象添加多个碰撞器,应该创建子对象并给每个子对象添加一个碰撞器。这使每个碰撞器可以被单独操作。

    Mesh Colliders that do not have Convex enabled are only supported on GameObjects without a Rigidbody component. To apply a Mesh Collider to a Rigidbody component, tick the Convex checkbox.

    未勾选Convex的Mesh Colliders只支持不含刚体组件的对象。若要给刚体组件对象应用Mesh Collider,记得勾上Convex 选框!

    ——碰撞,触碰条件

    Physic Material 物理材质

    物理材质用来调节碰撞物体的摩擦力和弹力效果,要创建物理材质从菜单栏选择Assets->Create->Physic Material。然后从项目视图拖拽物理材质到场景的一个碰撞器上。

    There is a special case when the two colliders in contact have different combine modes set. In this particular case, the function that has the highest priority is used. The priority order is as follows:

    Average < Minimum < Multiply < Maximum. For example, if one material has Average set but the other one has Maximum, then the combine function to be used is Maximum, since it has higher priority. 

    Wheel Collider:链接

     

     

    Constant Force 恒力

    Constant Force is a quick utility for adding constant forces to a Rigidbody. This works great for one shot objects like rockets, if you don't want it to start with a large velocity but instead accelerate.

    恒力(Constant Force)是添加恒力到刚体的一个快速工具,对于像火箭一个发生物体,这是一个伟大的工作,如果不想启动时有很大的速度,而是慢慢加速。


    A rocket propelled forward by a Constant Force 由一个恒力助推火箭向前。

    Properties 属性

    • Force
      The vector of a force to be applied in world space.
      在世界空间应用的向量力。----世界坐标系
    • Relative Force 相对力
      The vector of a force to be applied in the object's local space.
      在物体的局部空间应用的向量力。---自身坐标系
    • Torque 扭矩
      The vector of a torque, applied in world space. The object will begin spinning around this vector. The longer the vector is, the faster the rotation.
      在世界空间应用的扭矩向量。该物体将开始围绕这个向量旋转。向量的时间越长,旋转速度越快。
    • Relative Torque 相对扭矩
      The vector of a torque, applied in local space. The object will begin spinning around this vector. The longer the vector is, the faster the rotation.
      在局部坐标应用的扭矩向量。该物体将开始围绕这个向量旋转。向量的时间越长,旋转速度越快。

    Details 细节

    To make a rocket that accelerates forward set the Relative Force to be along the positive z-axis. Then use the Rigidbody's Drag property to make it not exceed some maximum velocity (the higher the drag the lower the maximum velocity will be).

    In the Rigidbody, also make sure to turn off gravity so that the rocket will always stay on its path.

    为了使火箭加速前进,沿正Z轴,设置相对力。然后使用刚体的阻力属性,使其不超过最大速度(较高的摩擦力将会降低最大速度)。在刚体,也确保关闭了重力,因此火箭将总是保持其路径。

     void Rigidbody.AddForce()

    给具有刚体的物体添加力,常使用的方法void Rigidbody.AddForce();有四个重载:void Rigidbody.AddForce(vector3 Force);、void Rigidbody.AddForce(Vector3 Force,ForceMode mode);

    (其中第一个参数与第一个一样都是需要传入一个向量,第二个参数传入一个力的作用模式)、void Rigidbody.AddForce(float x,float y,float z);、void Rigidbody.AddForce(float x,float y,float z,ForceMode mode)(与前两个基本一样);

    其中ForceMode有四种形式:ForceMode.Acceleration、ForceMode.Force、ForceMode.Impulse、ForceMode.VelocityChange。

        刚体运动速度的计算公式是:f•t=m•v

        ForceMode.Force:给物体添加一个持续的力并使用其质量。本次测试采用质量为2

        ForceMode.Acceleration::给物体添加一个持续的加速度,但是忽略其质量。即无论设置的质量为多少,都采用默认质量1

        ForceMode.Impulse;:给物体添加一个瞬间的力并使用其质量

        ForceMode.VelocityChange;:给物体添加一个瞬间的加速度,但是忽略其质量

    奥斯丁

    余生很长,愿我们都活成自己喜欢的样子
  • 相关阅读:
    python学习笔记(基础二:注释、用户输入、格式化输出)
    python学习笔记(基础一:'hello world'、变量、字符编码)
    python学习笔记(python简史)
    关于第三方框架"SDWebImage"
    <NSSting部分操作整理>
    简单说-自定义cell
    简单说-控制器跳转
    简单说-代理
    iOS程序员须知
    关于swift中的只读属性
  • 原文地址:https://www.cnblogs.com/bananana/p/9084602.html
Copyright © 2011-2022 走看看