ジョイントの制約とは “規則” で、ジョイントは、これが恒久的に破られないように努めます。制約には様々な種類があり、全てのジョイントは少なくとも 1 つの制約を提供します。この制約は、リジッドボディ 2D に適用されてその動作を制御します。制約の中には動作を制限するものがあります (例えば、リジッドボディが特定の線上あるいは特定の位置に留まるようにするものなど)。また一部の制約は “駆動的” で、リジッドボディゲームオブジェクトが特定の動作をするようにアクティブな作用を及ぼします (例えば、ゲームオブジェクトに一定のスピードを維持させるなど)。
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.