Capsule Collider 2D コンポーネントは 2D 物理プリミティブのひとつで、縦横両方向に引き伸ばすことが可能です。カプセル形には頂点による角がなく、他のコライダーの角に簡単に引っかかりにくい滑らかな一続きの輪郭を持っています。カプセル形は固体であるため、あるカプセル内に完全に入った別の Collider 2D は全て、そのカプセルと接していると見なされ、時間と共に強制的に外に出されます。
プロパティー | 機能 |
---|---|
Material | Capsule Collider 2D の使用する物理マテリアルを設定します。この設定は、全てのリジッドボディ 2D やグローバル物理コライダーをオーバーライドします。 |
Is Trigger | Capsule Collider 2D にイベントをトリガーさせたい場合はオンにしてください。このボックスをオンにすると、物理エンジンはこのコライダーを無視します。 |
Used by Effector | 添付された エフェクターのどれかがこの Capsule Collider 2D を使用する場合はオンにしてください。 |
Offset | Capsule Collider 2D ジオメトリのローカルのオフセットを設定します。 |
Size | ボックスのサイズを指定できます。その Capsule Collider 2D によって占められる領域を定義します。 |
Direction | Vertical または Horizontal に設定してください。カプセルの向く方向を設定するものです。具体的には、半円形の両端の向く方向を定義します。 |
Capsule Collider 2D を定義する設定は Size と Direction です。 Size と Direction の両プロパティは、 Capsule Collider 2D の、ワールド空間ではなくローカル空間の X (水平方向)と Y (垂直方向)を参照します。
Capsule Collider 2D のセットアップ方法として代表的なのは、 Size を Direction に合わせる方法です。例えば、 Capsule Collider 2D の Direction が Vertical であれば、 X の Size は 0.5、 Y の Size は 1 です。これにより、この垂直方向のカプセルは、(太くなるのではなく)背が高くなります。
下記の例で、黄色い線で表されているのが X と Y です。
Capsule Collider 2D の形状は様々に調整できます。以下で、いくつかの例をご覧ください。
Size プロパティの X __ と Y__ が同じである場合は常に、 Capsule Collider 2D はほぼ円形になります。
物理エンジン(Box 2D を含む)の既知の問題のひとつは、複数のコライダーに渡って移動する際に、(たとえそれらのコライダーの位置が数値的に完全に合わさっている場合でも、) 両コライダー間のコリジョンが、その 1 つまたは両方のコライダーによって登録されてしてしまうことです。これによりコライダーが遅くなったり停止してしまうことがあります。
Capsule Collider 2D はこの問題を緩和することはできますが、完全な解決にはなりません。より良い解決方法は、 1 つのサーフェス(表面)に 1 つのコライダーを使用することです([例] Edge Collider 2D)。
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.