约束是一条规则,关节一种物理组件,允许在刚体组件之间建立动态连接,通常允许一定程度的移动,例如铰链。 更多信息
参见 术语表 会试图确保不会永久断裂。存在不同类型的约束,所有关节至少提供一个适用于并控制刚体一个组件,允许游戏对象受模拟重力和其它力的影响。 更多信息
参见 术语表 2D 行为的约束。某些约束限制行为,例如确保刚体保持在一条线上或特定位置。有些是“驱动”约束,主动促使刚体游戏对象Unity 场景中的基本对象,可以表示角色、道具、场景、摄像机、路径点等等。游戏对象的功 能由附加在其上的组件定义。 更多信息
参见 术语表 以某种方式运行,例如试图使游戏对象保持特定速度。
Unity 的物理系统期望约束可以暂时断开,例如当对象之间的距离超出其设定的距离约束或速度超出其设定的速度约束时。当约束未断开时,关节不会施加任何力。当约束断开时,关节会施加力来修复约束。
例如,对于“驱动”约束,关节会施加力来保持距离或确保约束设定的速度。虽然这种力的施加通常很快,但它并不总是立即修复约束,而是随着时间的推移逐渐修复约束。这可能导致关节看起来伸展或显得不那么刚性。延迟发生是因为物理系统正在尝试施加关节力来修复约束,而其他物理力同时仍在作用以破坏相同的约束。除了作用于游戏对象的冲突力之外,某些关节比其他关节更稳定且反应更快。
无论关节提供哪些约束,关节只使用力来修复约束。这些力要么是线性(直线)力,要么是角(扭矩)力。
注意:建议在将较大力施加到连接了关节的刚体对象时,尤其是在质量较大的对象上时,应谨慎操作,因为作用于关节的冲突力。
所有关节都能够监控其施加的力或扭矩以保持在其自身的约束范围内。某些关节同时监控力和扭矩,而其他关节仅监控力。这会告知您关节在尝试维持其约束时何时超过特定力或扭矩,您可以将这些阈值指定为 Joint2D.breakForce
和 Joint2D.breakTorque
。当关节超过这些阈值时,称为关节断裂。
您可以使用 Joint2D.breakAction
指定关节断裂时要采取的操作。默认的断裂操作是销毁 Joint2D 组件,您可以参考 JointBreakAction2D
以获取其他可用的固定操作。
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.