Hinge Joint
Rigidbody

Mesh Collider

The Mesh Collider takes a Mesh Asset and builds its Collider based on that Mesh. It is more accurate for collision detection than using primitives for complicated Meshes. Mesh Colliders that are marked as Convex can collide with other Mesh Colliders.

プロパティー

プロパティー 機能
Convex Enable the checkbox to make the Mesh Collider collide with other Mesh Colliders. Convex Mesh Colliders are limited to 255 triangles.
Is Trigger Enable this checkbox to make Unity use this Collider for triggering events, and the physics engine ignore it.
Cooking Options Mesh Cooking オプションを有効または無効にします。このオプションは、物理エンジンがメッシュを処理する方法に影響を与えます。
None 以下の Cooking Options をすべて無効にします。
Everything 以下の Cooking Options をすべて有効にします。
Cook for Faster Simulation 物理エンジンが、高速なシミュレーションに適したメッシュを生成します。これを有効にすると、ランタイムのパフォーマンスに最適なメッシュが得られるように、いくつかの追加ステップが実行されます。これは、物理演算クエリと接触生成のパフォーマンスに影響します。この設定を無効にすると、物理エンジンは処理時間を短くし、できるだけ早く結果を出します。その結果、生成されたメッシュコライダーは最適でない場合があります。
Enable Mesh Cleaning Makes the physics engine clean Meshes. When enabled, the cooking process tries to eliminate degenerate triangles of the Mesh, as well as other geometrical artifacts. This results in a Mesh that is better suited for use in collision detection and tends to produce more accurate hit points.
Weld Colocated Vertices 物理エンジンがメッシュ内の等しい頂点を削除します。有効にすると、物理エンジンは同じ位置の頂点を 1 つにまとめます。これは、ランタイムに発生する衝突のフィードバックにとって重要です。
Material 使用する 物理マテリアル への参照。物理マテリアルによりコライダーが他と衝突したとき、どのように相互作用するかが決定されます。
Mesh 衝突判定に使用するメッシュ。

詳しい説明

The Mesh Collider builds its collision representation from the Mesh attached to the GameObject, and reads the properties of the attached Transform to set its position and scale correctly. The benefit of this is that you can make the shape of the Collider exactly the same as the shape of the visible Mesh for the GameObject, which creates more precise and authentic collisions. However, this precision comes with a higher processing overhead than collisions involving primitive colliders (such as Sphere, Box, and Capsule), so it is best to use Mesh Colliders sparingly.

Faces in collision meshes are one-sided. This means GameObjects can pass through them from one direction, but collide with them from the other.

Details about underlying algorithms and data structures used by mesh colliders can be found at PhysX documentation.

メッシュの調整

Mesh cooking changes a normal Mesh into a Mesh that you can use in the physics engine. Cooking builds the spatial search structures for the physics queries, such as Physics.Raycast, as well as supporting structures for the contacts generation. Unity cooks all Meshes before using them in collision detection. This can happen at import time (Import Settings > Model > Generate Colliders) or at run time.

When you generate Meshes at run time (for example, for procedural surfaces), it’s useful to set the Cooking Options to produce results faster, and disable the additional data cleaning steps of cleaning. The downside is that you need to generate no degenerate triangles and no co-located vertices, but the cooking works faster.

If you disable Enable Mesh Cleaning or Weld Colocated Vertices, you need to ensure you aren’t using data that those algorithms would otherwise filter. Make sure you don’t have any co-located vertices if you have disabled Weld Colocated Vertices, and when you enable Enable Mesh Cleaning, make sure there are no tiny triangles whose area is close to zero, no thin triangles, and no huge triangles whose area is close to infinity.

Note: When you set the Cooking Options to any other value than the default settings, it means the Mesh Collider must use a Mesh that has an isReadable value of true.

制限

メッシュコライダーには、いくつかの制限があります。

GameObjects that have a Rigidbody component only support Mesh Colliders that have Convex option enabled: the physics engine can only simulate convex mesh colliders.

メッシュコライダーが正しく機能するためには、以下のいずれかの状況でメッシュを読み書き可能にする必要があります。

  • The Mesh Collider’s Transform has negative scaling (for example, (–1, 1, 1)) and the Mesh is convex.
  • The Mesh Collider’s transform is skewed or sheared (for example, when a rotated transform has a scaled parent transform).
  • The Mesh Collider’s Cooking Options flags are set to any value other than the default.

You should not modify mesh geometry that is used for colliders because the physics engine has to rebuild an internal mesh collision acceleration structure every time you change the mesh. This causes a substantial performance overhead. For meshes that need to collide and change at runtime, it is often better to approximate the mesh shape with primitive colliders like capsules, spheres and boxes.

Optimization tip: If a Mesh Collider only uses a Mesh, you can disable Normals in Import Settings, because the physics system doesn’t need them.


  • 2018.3でMesh Colliderの制限を更新

  • 2018–10–12 Page amended

  • Mesh Cooking Options は 2017.3 で追加NewIn20173

  • バージョン 2018.1 の更新機能

  • 読み込み/書き込み可能な設定に関する制限を 2017.3 で更新

  • Inflate Convex Meshは、2018.3 で非推奨に。なぜなら、新しい凸状の計算アルゴリズム (Quickhull) が入力メッシュの不完全さに対してより寛容であるため。

Hinge Joint
Rigidbody