Version: 2019.2
角色关节
恒定力

可配置关节

可配置关节 (Configurable Joint) 包含其他关节类型的所有功能,并提供更强大的角色移动控制。当您想要自定义布娃娃的运动并对角色强制实施某些姿势时,这种关节特别有用。使用可配置关节还可以将关节修改为您自行设计的高度专业化关节。

属性

属性: 功能:
Edit Joint Angular Limits 在 Scene 视图中添加视觉辅助图标以帮助您编辑关节角度限制。要使用此辅助图标,请将 Angular X, Y, Z Motion 设置为 Limited__,然后便会出现用于拖动和调整关节旋转空间的控制柄。 | |Connected Body__ 关节连接到的刚体对象。可将此属性设置为 None 来表示关节连接到空间中的固定位置,而不是另一个刚体。
Anchor 用于定义关节中心的点。所有基于物理的模拟都使用此点作为计算中的中心。
用于基于物理模拟来定义对象自然旋转的局部轴。
Auto Configure Connected Anchor 启用此设置会自动计算连接锚点 (Connected Anchor) 位置以便与锚点属性的全局位置匹配。这是默认设置。禁用此设置可以手动配置连接锚点的位置。
Connected Anchor 手动配置连接锚点位置。
Secondary Axis AxisSecondary Axis 定义了关节的局部坐标系。第三个轴与另外两个轴正交。
X, Y, Z Motion 根据以下描述的限制属性,将沿 X、Y 或 Z 轴的移动设置为 Free、完全 LockedLimited
Angular X, Y, Z Motion 根据以下描述的限制属性,将沿 X、Y 或 Z 轴的旋转设置为 Free、完全 LockedLimited
Linear Limit Spring 当对象超过了限制位置时施加弹簧力以拉回对象。
Spring 弹簧力。如果此值设置为零,则无法逾越限制。零以外的值将使限制变得有弹性。
Damper 根据关节运动的速度按比例减小弹簧力。设置为大于零的值可让关节“抑制”振荡(否则将无限期进行振荡)。
Linear Limit 设置关节线性移动的限制(即,移动距离而不是旋转),指定为距关节原点的距离。
Limit 从原点到限制位置的距离(采用世界单位)。
Bounciness 设置当对象达到限制距离时要将对象拉回而施加的弹力。
Contact Distance 需要强制执行限制时,关节位置和限制位置之间的最小距离公差。公差越大,对象快速移动时违反限制的可能性就越低。但是,这种情况下需要通过更频繁进行物理模拟来考虑限制,并会略微降低性能。
Angular X Limit Spring 当对象超过了关节的限制角度时施加弹簧扭矩以反向旋转对象。
Spring 弹簧扭矩。如果此值设置为零,则无法逾越限制。设置为零以外的值将使限制变得有弹性。
Damper 根据关节旋转的速度按比例减小弹簧扭矩。设置为大于零的值可让关节“抑制”振荡(否则将无限期进行振荡)。
Low Angular X Limit 关节绕 x 轴旋转的下限,指定为距关节原始旋转的角度。
Limit 限制角度。
Bounciness 设置当对象的旋转达到限制角度时要在对象上施加的反弹扭矩。
Contact Distance 需要强制执行限制时的最小角度公差(关节角度和限制位置之间)。公差越大,对象快速移动时违反限制的可能性就越低。但是,这种情况下需要物理模拟更频繁地考虑限制,并会略微降低性能。
High Angular XLimit 类似于上述 Low Angular X Limit 属性,但确定的是关节旋转的角度上限,而不是下限。
Angular YZ Limit Spring 类似于上述 Angular X Limit Spring_,但适用于围绕 Y 轴和 Z 轴的旋转。 | |Angular Y Limit ||这类似于上述 Angular X Limit_ 属性,但会将限制应用于 y 轴,并将角度的上限和下限视为相同。
Angular Z Limit 这类似于上述 Angular X Limit 属性,但会将限制应用于 z 轴,并将角度的上限和下限视为相同。
Target Position 关节的驱动力移动到的目标位置。
Target Velocity 关节在驱动力下移动到_目标位置 (Target Position)_ 时所需的速度。
XDrive 根据 Position SpringPosition Damper 驱动扭矩,设置 Unity 用于使关节绕其局部 x 轴旋转的力。Maximum Force 参数用于限制力的最大大小。仅当 Rotation Drive Mode 属性设置为 X & YZ 时,才可使用此属性。有关更多信息,请参阅下面的驱动力部分。
Position Spring 由 Unity 用于将关节从当前位置向目标位置旋转的弹簧扭矩。
Position Damper 根据关节当前速度与目标速度之间的差值按比例减小弹簧扭矩量。此做法可减小关节移动速度。设置为大于零的值可让关节“抑制”振荡(否则将无限期进行振荡)。
Maximum Force 限制可以施加的驱动力大小。要施加计算出的驱动力,请将此属性设置为不太可能计算的驱动高值。
YDrive 类似于上述 X Drive_,但适用于关节的 y 轴。 | |ZDrive ||类似于上述 X Drive_,但适用于关节的 z 轴。
Target Rotation 关节旋转驱动朝向的方向,指定为四元数。除非设置了 Swap Bodies 参数(在这种情况下,目标旋转相对于连接的主体的锚点),否则目标旋转相对于关节连接到的主体。
Target Angular Velocity 关节的旋转驱动达到的角速度。此属性指定为矢量。矢量的长度指定旋转速度,而其方向定义旋转轴。
Rotation Drive Mode 设置 Unity 如何将驱动力应用于对象以将其旋转到目标方向。如果将该模式设置为 X and YZ_,则会围绕这些轴施加扭矩(由如下所述的 Angular X/YZ Drive_ 属性指定)。如果使用 Slerp 模式,则 Slerp Drive 属性用于确定驱动扭矩。
Angular X Drive 此属性指定了驱动扭矩如何使关节围绕局部 x 轴旋转。仅当上述 Rotation Drive Mode 属性设置为 X & YZ 时,才可使用此属性。有关更多信息,请参阅下面的驱动力部分。
Position Spring The spring torque that Unity uses to rotate the joint from its current position towards its target position.
Position Damper Reduces the amount of spring torque in proportion to the difference between the joint’s current velocity and its target velocity. This reduces the speed of the joint’s movement. Set a value above zero to allow the joint to dampen oscillations which would otherwise carry on indefinitely.
Maximum Force Limits the amount of force that the drive can apply. To make the drive apply the force that it’s calculated, set this to a high value that the drive is unlikely to calculate.
Angular YZDrive This is similar to the Angular X Drive described above but applies to both the joint’s Y and Z axes.
Slerp Drive This specifies how the drive torque rotates the joint around all local axes. The property is only available if the Rotation Drive Mode property described above is set to Slerp. For more information, see Slerp Drive section below.
Position Spring The spring torque that Unity uses to rotate the joint from its current position towards its target position.
Position Damper Reduces the amount of spring torque in proportion to the difference between the joint’s current velocity and its target velocity. This reduces the speed of the joint’s movement. Set a value above zero to allow the joint to dampen oscillations which would otherwise carry on indefinitely.
Maximum Force Limits the amount of force that the drive can apply. To make the drive apply the force that it’s calculated, set this to a high value that the drive is unlikely to calculate.
Projection Mode This defines how the joint snaps back to its constraints when it unexpectedly moves beyond them, because the physics engine is unable to reconcile the current combination of forces within the simulation. The options are None and Position and Rotation.
Projection Distance The distance the joint must move beyond its constraints before the physics engine attempts to snap it back to an acceptable position.
Projection Angle The angle the joint must rotate beyond its constraints before the physics engine attempts to snap it back to an acceptable position.
Configured in World Space Enable this property to calculate the values set by the various target and drive properties in world space instead of the object’s local space.
Swap Bodies Enable this property to make the joint behave as though the component is attached to the connected Rigidbody (ie, the other end of the joint).
Break Force If a force larger than this value pushes the joint beyond its constraints then the joint is permanently “broken” and deleted. Break Torque only breaks a joint when its axes are Limited or Locked (see Constraining movement section below).
Break Torque If a torque larger than this value rotates the joint beyond its constraints then the joint is permanently “broken” and deleted. Break Force can break a joint regardless of whether its axes are Free, Limited or Locked (see Constraining movement section below).
Enable Collision Enable this property to let the object with the joint collide with the object it is connected to. If this is disabled, the joint and object will pass through each other.
Enable Preprocessing If preprocessing is disabled then certain “impossible” configurations of the joint are kept more stable rather than drifting wildly out of control.
Mass Scale The scale to apply to the inverted mass and inertia tensor of the Rigidbody, ranging from 0.00001 to infinity. This is useful when the joint connects two Rigidbodies of largely varying mass. The physics solver produces better results when the connected Rigidbodies have a similar mass. When your connected Rigidbodies vary in mass, use this property with the Connect Mass Scale property to apply fake masses to make them roughly equal to each other. This produces a high-quality and stable simulation, but reduces the physical behaviour of the Rigidbodies.
Connected Mass Scale The scale to apply to the inverted mass and inertia tensor of the connected Rigidbody, ranging from 0.00001 to infinity.

详细信息

与其他关节一样,使用可配置关节可以限制对象的移动,而且通过可配置关节还可以使用作用力将对象驱动到目标速度或位置。由于有许多配置选项,可能需要尝试不同的选项,才能使关节完全按照所需的方式运行。

约束运动

可使用 X, Y, Z MotionX, Y, Z Rotation 属性独立约束每个关节轴上的平移运动和旋转。启用 Configured In World Space 可以将运动约束到世界轴而不是对象的局部轴。所有这些属性都可以设置为 LockedLimited 或 _Free_:

  • Locked 轴会限制所有运动,因此关节根本无法移动。例如,世界 y 轴中锁定的对象无法上下移动。
  • Limited 轴允许在预定义的限制范围内自由移动,如下所述。例如,通过将炮塔的 Y 旋转限制到特定角度范围,可以给炮塔设置受限制的火弧。
  • Free 轴允许任意移动。

可使用 Linear Limit 属性限制平移运动,该属性定义了关节可从其原点移动的最大距离(分别沿每个轴进行测量)。例如,为了能够约束空气曲棍球台的曲棍球,可让关节在 y 轴为锁定状态(在世界空间中),在 z 轴为自由状态,并在 x 轴为受限状态以便适应球台的宽度限制;这样,曲棍球会被限制在游戏区域内。

还可以使用 Angular Limit 属性来限制旋转。与线性限制不同,此属性可用于为每个轴指定不同的限制值。还可以为 x 轴的旋转角度定义单独的上限和下限;其他两个轴在原始旋转的两侧使用相同的角度。例如,可使用平面构造一个“摇摆平台”,将关节约束为允许在 X 和 Z 方向轻微摇摆,同时锁定 Y 旋转。

弹性和弹簧

默认情况下,关节在达到限制时会停止移动。然而,像这样的非弹性碰撞在现实世界中是罕见的,因此向受约束的关节添加一些弹跳感会很有用。为了使受约束的对象在达到限制后反弹,可使用线性和角度限制的 Bounciness 属性。大部分的碰撞在有了少量弹性之后会显得更自然,但也可以将该属性设置为更高的值,从而模拟弹性异常大的边界,比如台球桌垫。

有弹性的关节不会超越限制
有弹性的关节不会超越限制

为了进一步软化关节限制,可使用弹簧属性:用于平移的 Linear Limit Spring 和用于旋转的 Angular X/YZ Limit Spring。如果将 Spring 属性设置为大于零的值,关节达到限制时不会突然停止移动,而是会通过弹簧力被拉回到限制位置。这个力的强度由 Spring 值确定。默认情况下,弹簧具有完美的弹性,并会按照与碰撞相反的方向弹回关节。

可使用 Damper 属性来减少弹性并以更温和的方式将关节恢复到限制位置。例如,可使用弹簧关节创建一个可向左或向右拉动的杠杆,然后弹回到直立位置。如果弹簧具有完美弹性,则杠杆在释放后将围绕中心点来回摆动。但是,如果添加足够的阻尼,弹簧将迅速稳定到中立位置。

弹簧关节越过限制位置但被拉回到限制位置
弹簧关节越过限制位置但被拉回到限制位置

驱动力

关节不仅可以对附加到的对象做出反应,而且还可以主动施加_驱动力_使对象运动。一些关节需要保持对象以恒定速度移动,例如转动风扇叶片的旋转电机。使用 Target VelocityTarget Angular Velocity 属性可为此类关节设置所需的速度。

可能需要使用关节来将关节的对象移向空间中的特定位置或移向特定方向。使用 Target PositionTarget Rotation 属性可以设置此功能。例如,要实现叉车,可将叉车的叉子安装在可配置关节上,然后使用脚本设置目标高度以升高叉子。

设置了目标后,_X, Y, Z Drive_ 和 Angular X/YZ Drive_(或者是 Slerp Drive_)属性可以指定用于将关节推向目标的作用力。驱动的 Mode 属性选择关节是否应该寻找目标位置和/或速度。在寻找目标位置时,_Position Spring_ 和 Position Damper 的工作方式与关节限制相同。在速度模式下,弹簧力取决于当前速度和目标速度之间的“差距”;阻尼器有助于速度稳定在所选值,而不是在该值周围无限振荡。例如,_XDrive_ 力的公式为:

force = PositionSpring * (target position - position) + PositionDamper * (targetVelocity - velocity)

因此,力会根据当前值与目标值之间的差值成比例增大,并根据当前速度和目标速度之间的差值成比例减小阻尼。Unity 会将力施加到位置驱动和旋转驱动。

Maximum Force 属性用于最终微调,无论关节距其目标有多远,均可防止弹簧施加的力超过限制值。这样可以防止远离目标的关节快速以不受控制的方式将对象拉回。

在使用任何驱动力(下面描述的 Slerp Drive 除外),关节都会在每个轴上单独将力施加到对象。举例来说,可实现一个航天器,使之具有较高的向前飞行速度,但在侧向转向运动中具有相对较低的速度。

Slerp Drive

不同于其他驱动模式在不同的轴上施加力,_Slerp Drive_ 使用四元数的球面插值或“Slerp”功能来重新定向关节。Slerp 过程不会隔离单个轴,而是寻找将对象从当前方向带到目标的最小总旋转,并根据需要将该旋转应用于所有轴。Slerp Drive 的配置比较简单,但不允许为 X 和 Y/Z 轴指定不同的驱动力。

要启用 Slerp Drive,请将 Rotation Drive Mode 属性从 X and YZ 更改为 Slerp。关节可以使用 Angular X/YZ Drive 值或 Slerp Drive 值,但不能同时使用两者。


  • 2019–05–23 页面已修订
角色关节
恒定力
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961