zoukankan      html  css  js  c++  java
  • Unity—Joint关节结构

    转载整理自圣典社区官方文档;

    1.Fixed Joint 固定关节

       固定关节基于另一个物体来限制一个物体的运动。效果类似于父子关系,但是不是通过层级变换,而是通过物理实现的。使用它的最佳情境是当你有一些想要轻易分开的物体,

       或想让两个没有父子关系的物体一起运动。

    Properties 属性


                  Connected Body 连接的刚体          Optional reference to the Rigidbody that the joint is dependent upon. If not set, the joint connects to the world.

                                                                         一个关节连接的刚体引用,可选。如果没有设置,那么关节将和世界相连。 Connected body类似此物体的子物体,但只能随此物体移动而动,自身的移动旋转被限制。

                     Break Force 断开力                     The force that needs to be applied for this joint to break.

                                                                                    断裂的力,破坏关节的力的大小。

                    Break Torque 断开扭矩                 The torque that needs to be applied for this joint to break.

                                                                                  断裂的扭矩,破坏关节的扭力的大小。

                    Enable Collision                           When checked, this enables collisions between bodies connected with a joint.

                                                                                  勾选,使得以关节相连的两个物体可以发生碰撞

                  Enable Preprocessing                     Disabling preprocessing helps to stabilize impossible-to-fulfil configurations.


     使用固定关节自身要有个刚体组件;

    Connected Body 记得是个刚体,所以对象一定要含刚体;

    //抓取目标,并使之与手链接
        private void GrabObjects()
        {
            //Debug.Log("666666");
            // 1
            objectInHand = collidingObject;
            collidingObject = null;
            // 2
            var joint = AddFixedJoint();
            joint.connectedBody = objectInHand.GetComponent<Rigidbody>();
        }
    
        // 3
        private FixedJoint AddFixedJoint()
        {
            FixedJoint fx = gameObject.AddComponent<FixedJoint>();
            fx.breakForce = 20000;
            fx.breakTorque = 20000;
            return fx;
        }
    
        //放下物体
        private void ReleaseObject()
        {
            // 1
            if (GetComponent<FixedJoint>())
            {
                // 2
                GetComponent<FixedJoint>().connectedBody = null;
                Destroy(GetComponent<FixedJoint>());
                // 3
                objectInHand.GetComponent<Rigidbody>().velocity = Controller.velocity;
                objectInHand.GetComponent<Rigidbody>().angularVelocity = Controller.angularVelocity;
            }
            // 4
            objectInHand = null;
        }
    View Code

    2.Hinge Joint 铰链关节

     铰链关节由两个刚体组成,约束它们像连在一个铰链上一样运动,适用于门,不过对于典型的链子、钟摆等同样适用。

    Properties

    Property:Function:
    Connected Body-连接体

    Optional reference to the Rigidbody that the joint is dependent upon. If not set, the joint connects to the world.

    为刚体指定关节连接物,如不设定,则与世界相连

    Anchor

    The position of the axis around which the body swings. The position is defined in local space.

    主体摇摆围绕的锚点坐标,基于本地坐标系。----一个棕色箭头Arrow

    Axis

    The direction of the axis around which the body swings. The direction is defined in local space.

    摇摆方向的坐标,基于本地坐标系

    Auto Configure Connected Anchor

    If this is enabled, then the Connected Anchor position will be calculated automatically to match the global position of the anchor property.

    This is the default behavior. If this is disabled, you can configure the position of the connected anchor manually.

    Connected Anchor Manual configuration of the connected anchor position.
    Use Spring

    Spring makes the Rigidbody reach for a specific angle compared to its connected body.

    弹簧使刚体相对它连接的主体达到一个特定的角度

    Spring Properties of the Spring that are used if Use Spring is enabled.
            Spring

    The force the object asserts to move into the position.

    维持对象移动到一定位置的力

            Damper

    The higher this value, the more the object will slow down.

    值越大,对象移动越慢

            Target Position

    Target angle of the spring. The spring pulls towards this angle measured in degrees.

    弹簧的目标角度。弹簧拉向这个角度,以角为单位

    Use Motor

    The motor makes the object spin around.

    Motor使对象旋转

    Motor Properties of the Motor that are used if Use Motor is enabled.
            Target Velocity The speed the object tries to attain.----对象设法达到的速度
            Force The force applied in order to attain the speed.----用于达到目标速率的力
            Free Spin

    If enabled, the motor is never used to brake the spinning, only accelerate it.

    如果启用,Motor永远不会破坏旋转,只会加速

    Use Limits

    If enabled, the angle of the hinge will be restricted within the Min & Max values.

    如果启用,铰链的角度将被限制在最大和最小之间

    Limits.....
            Min The lowest angle the rotation can go.----rotation能达到的最小角度
            Max The highest angle the rotation can go.----rotation能达到的最大角度
            Bounciness

    How much the object bounces when it hits the minimum or maximum stop limit.

    物体碰触最小/最大限制时的弹跳值

            Contact Distance

    Within the contact distance from the limit contacts will persist in order to avoid jitter.

    在接触极限距离内的接触将持续,以避免抖动。。。。。。。

    Break Force

    The force that needs to be applied for this joint to break.

    允许这个铰链破损的力

    Break Torque

    The torque that needs to be applied for this joint to break.

    允许这个铰链破损的扭矩

    Enable Collision

    When checked, this enables collisions between bodies connected with a joint.

    使得在与关节相连的物体之间发生碰撞

    Enable Preprocessing

    Disabling preprocessing helps to stabilize impossible-to-fulfil configurations.

    禁用预处理有助于稳定不可能实现配置。。。。

    ***Mass Scale

     the scale to apply to the inverse mass and inertia tensor of the body   0.00001~infinity

    物体的逆质量和惯性张量的标度............

    Connected  Mass Scale  the scale to apply to the inverse mass and inertia tensor of the connected body  0.00001~infinity

    单独的铰链关节要连在游戏对象上。铰链会绕着Anchor 属性指定的点,沿着 指定的Axis 属性方向移动。不需要给关节的Connected Body 属性分配游戏对象。

    希望关节的Transform依赖附加对象的Transform时,才需要分配游戏对象给Connected Body属性。----铰链会使得物体绕着铰链旋转,而这并不需要Connected Body。

    想一想门的铰链如何工作。Axis在这种情况下是向上的,沿Y轴正向。Anchor在门和墙交点的某处。不需要指定墙给Connected Body,因为关节默认会和世界相连。

    用Break Force来制作动态破坏的系统。这很酷,可以让玩家用火箭发射器爆破或者用疾驶的汽车撞,来把门从铰链处弄碎。

    Spring Joint 弹簧关节

    弹簧关节组连接两个刚体,让它们像被弹簧连接着一样运动。

    Property:Function:
    Connected Body

    The Rigidbody object that the object with the spring joint is connected to. If no object is assigned then the spring will be connected to a fixed point in space.

    弹簧关节连接的另一个刚体。 可选,不填另一端和世界相连。

    Anchor

    The point in the object’s local space at which the joint is attached.

    锚,所属物件本地空间坐标的点,亦关节依附的点。

    Auto Configure Connected Anchor Should Unity calculate the position of the connected anchor point automatically?---自动计算出链接物体锚点的位置
    Connected Anchor

    The point in the connected object’s local space at which the joint is attached.

    Connected Body本地坐标系下的点坐标,Joint依附于它。。若未赋予链接物体,默认是世界坐标。

    Spring Strength of the spring.-----弹簧的强度。值越高,创建的弹簧效果越强
    Damper Amount that the spring is reduced when active.-----弹簧的阻尼,当弹簧激活时减少弹簧强度。
    Min Distance Lower limit of the distance range over which the spring will not apply any force.---间距下限,大于它,不会应用任何力
    Max Distance Upper limit of the distance range over which the spring will not apply any force.---间距上限,小于它,不会应用任何力
    Tolerance Changes error tolerance. Allows the spring to have a different rest length.
    Break Force

    The force that needs to be applied for this joint to break.

    破坏关节的力的大小

    Break Torque

    The torque that needs to be applied for this joint to break.

    破坏关节的扭力的大小

    Enable Collision Should the two connected objects register collisions with each other?
    Enable Preprocessing Disabling preprocessing helps to stabilize impossible-to-fulfil configurations.

    当相连物件的当前距离保证在(初始距离-min_dis,初始距离+max_dis)范围内,则认为该状态是稳定的,不激活弹簧。否则激活弹簧。

    如果一个物件主要是通过弹簧关节来控制位置,那么最好是创建一个包含刚体的空物件,然后将弹簧关节附加给这个空物件,并连接想要控制的物件。这样,在脚本中,你就可以控制这个空物件移动,使得弹簧可以按你期望的运动。

    弹簧关节工作连接另一个刚体并不是必需的。一般来说,当你的物件需要依赖另一个刚体的位置和旋转时,那么就连接它。如果关节没有连接到刚体,那么它将和世界连接。

    Character Joint  Configurable Joint

    http://www.ceeger.com/Components/

    布娃娃系统------待更新

    余生很长,愿我们都活成自己喜欢的样子
  • 相关阅读:
    强制转换改变了对象的框架大小
    android应用程序fps meter[帧数显示]的分析 —— 浅谈root的风险 (1)
    父类virtual和overload,子类reintroduce; overload;
    MySQL版本与工具
    Verilog HDL实用教程笔记
    XE2安装JVCL
    解决Raize日历控件显示的问题
    hdu3415 Max Sum of Max-K-sub-sequence
    MFC重绘原理的关键理解
    常用代码页与BOM
  • 原文地址:https://www.cnblogs.com/bananana/p/9088066.html
Copyright © 2011-2022 走看看