Cloth コンポーネントはスキンメッシュレンダラーと連動して機能し、物理演算を用いたクロス (布) のシミュレーションを行います。これはスキンメッシュと一緒に使う必要があり、キャラクターの衣服によく使われます。Cloth コンポーネントをスキンメッシュがないゲームオブジェクトに加えると、Unity は自動的にスキンメッシュ以外のメッシュを削除し、スキンメッシュを加えます。
Cloth コンポーネントをスキンメッシュに加えるには、エディターでゲームオブジェクトを選択し、インスペクターウィンドウで Add Component ボタンを押し、 Physics > Cloth の順に選択します。選択したコンポーネントがインスペクターに表示されます。
プロパティー | 機能 |
---|---|
Stretching Stiffness | クロスの伸縮率を設定します。 |
Bending Stiffness | クロスの曲げ剛性を設定します。 |
Use Tethers | 動いているクロスのパーティクルが固定されたパーティクルから、遠くに離れ過ぎるのを防ぐ制限を適用します。 |
Use Gravity | クロスに重力加速度を適用します。 |
Damping | モーションの減衰係数を設定します。 |
External Acceleration | クロスに外部から一定に加えられる加速度を設定します。 |
Random Acceleration | クロスに外部からランダムに加えられる加速度を設定します。 |
World Velocity Scale | ワールド空間でのキャラクターの動きがクロスの頂点にどのくらい影響を与えるかを設定します。 |
World Acceleration Scale | ワールド空間でのキャラクターの加速がクロスの頂点にどのくらい影響を与えるかを設定します。 |
Friction | キャラクターと衝突したときのクロスの摩擦係数を設定します。 |
Collision Mass Scale | 衝突するパーティクルの密度をどのくらい増加するかを設定します。 |
Use Continuous Collision | 衝突の安定性を向上させるために継続的な衝突を有効にします。 |
Use Virtual Particles | 衝突の安定性の向上のために、ひとつの三角形ごとにひとつの仮想パーティクルを加えます。 |
Solver Frequency | 一秒間ごとのソルバー反復の回数を設定します。 |
Sleep Threshold | クロスのスリープのしきい値を設定します。 |
Capsule Colliders | クロスインスタンスが衝突するカプセルコライダーの配列を設定します。 |
Sphere Colliders | クロスインスタンスが衝突するスフィアコライダーの配列を設定します。 |
Cloth コンポーネントはシーン内のすべてのコライダーに反応するわけではなく、ゲームオブジェクトへ力を跳ね返すわけでもありません。Cloth コンポーネントは加えられても、その他のリジッドボディに対してまったく反応せず、影響も与えません。したがって、手動でゲームオブジェクトの Cloth コンポーネントへ世界からのコライダーを加えるまでは、互いに影響することはありません。また追加後も、シミュレーションは一方的なものになります。つまり、リジッドボディに対してクロスは反応しますが、クロスが影響を与えることはありません。
また、Cloth に使用できるコライダーは 3 種類のみです。スフィア、カプセル、2 つのスフィアコライダーで構成される円錐形カプセルコライダーです。こういった制限はすべて、パフォーマンス強化のために設けられています。
You can apply constraints to specific vertices of the cloth to give them more or less freedom of movement.
In the Inspector, select Edit cloth constraints (top-left button) in the Cloth component. When the tool is active, small spheres appear in the Scene view on all vertices of the mesh. They represent the cloth particles to which you can apply constraints. The Cloth Constraints tool window also appears at the bottom right of the Scene view.
For each cloth particle, you can set and display two types of constraints: * Max Distance – the maximum distance a cloth particle can travel from its vertex position. * Surface Penetration – how deep the cloth particle can penetrate the mesh.
The color of a particle represents the relative value of its constraint within the cloth, according to the type of constraint currently selected.
プロパティー | 機能 | |
---|---|---|
Visualization | Allows you to select which constraint type and which particles to display. | |
Max Distance | Displays only the Max Distance values of the cloth particles. | |
Surface Penetration | Displays only the Surface Penetration values of the cloth particles. | |
Manipulate Backfaces | Enable this option to visualize and manipulate particles that might be hidden behind the current facing part of the cloth. | |
[ Color spectrum ] | Provides the correspondance between particle colors and constraint values for the above selected constraint type, according to the mimimum and maximum values currently applied within the whole cloth. Black always means that the particle has no constraint. | |
Constraint Size | The display size of the spheres that represent the cloth particles. Adjust this value at your convenience to ease your constraints edition. This property has no effect on the constraints themselves. |
You can use 3 different modes to edit the cloth constraint values.
Mode | 説明 |
---|---|
Select | Allows you to apply a fixed constraint value to a pre-selected group of particles. |
Paint | Allows you to apply a fixed constraint value by painting the cloth particles with a brush. |
Gradient | Allows to apply a left-to-right linear gradient of constraint values to a pre-selected group of particles. |
The tool properties and the steps that you need to perform are different according to the mode you are using. In all cases, the last step corresponds to the action that applies the constraint values.
クロスの衝突は、ゲーム内のキャラクターの衣服やさまざまな布をよりリアリスティックに動かします。Unity では、クロスは衝突を処理するいくつかのクロスのパーティクルを持ちます。以下のものに対してクロスのパーティクルを設定できます。
クロスに衝突パーティクルを設定するには、Cloth のインスペクターで Self Collision And Inter Collision ボタンを押します。
シーンビューに表示された Cloth Self Collision And Intercollision ウィンドウ
Cloth コンポーネントでスキンメッシュに自動的に表れるクロスのパーティクル。最初は、クロスのパーティクルにはコリジョンの設定がされてません。これらの使用されていないパーティクルは黒く表示されます。
セルフコリジョンやインターコリジョンを適用するには、衝突を適用する一群のパーティクルを Select ボタンから選ぶ必要があります。
衝突を適用するパーティクルを選ぶには、左クリックしてドラッグします。
選択したパーティクルは青で表示されます。
Self Collision and Intercollision にチェックを入れ、選択したパーティクルに衝突を適用します。
衝突に使用することを指定したパーティクルは緑で表示されます。
クロスのセルフコリジョンの挙動を有効にするには、Cloth インスペクターウィンドウの Self Collision セクションに移動し、Distance と Stiffness をゼロ以外の値にします。
プロパティー | 機能 |
---|---|
Distance | 各パーティクルの周りのスフィアの直径。Unity は、シミュレーション中にこれらのスフィアが重なり合わないようにします。 Distance は、2 つのパーティクル間の最短距離よりも小さく設定する必要があります。距離が大きい場合、セルフコリジョンが距離の制約に反してジッタが発生する場合があります。 |
Stiffness | パーティクル間の分離の力の強さ。クロスソルバーはこれを計算し、パーティクルを分離した状態に保つようにします。 |
セルフコリジョンとインターコリジョンは、シミュレーション時間全体のかなりの部分を占める可能性があります。衝突距離を小さく保ち、セルフコリジョンインデックスを使用して、互いに衝突するパーティクルの数を減らすことを検討してください。
セルフコリジョンでは三角形ではなく頂点が使用されるので、クロスの厚さよりもかなり大きい三角形をもつメッシュに対してセルフコリジョンが完全に機能するわけではありません。
Paint と Erase モードでは、左マウスボタンを押したまま個々のクロスのパーティクルをドラッグすることで、衝突時に使用するパーティクルを加えたり、削除したりします。
Paint または Erase モードの場合、衝突に指定されたパーティクルは緑、指定されないパーティクルは黒、ブラシの下にあるパーティクルは青です。
上で説明したセルフコリジョンのためのパーティクルを指定するのと同じ方法で、インターコリジョンのためのパーティクルを指定します。セルフコリジョンと同様に、インターコリジョンのために 1 組のパーティクルを指定します。
インターコリジョンの動作を有効にするには Physics 設定 (Edit > Project Settings を開き、Physics カテゴリを選択) を開き、Cloth InterCollision セクションで Distance と Stiffness を 0 以外の値に設定します。
Cloth intercollision の Distance と Stiffness プロパティーは、上の Self collision の Distance と Stiffness プロパティーと同じ機能を持っています。
クロスは、ゲーム世界の任意のジオメトリと単純に衝突することはできず、Capsule Colliders か Sphere Colliders 配列で指定されたコライダーとだけ相互作用します。
SphereCollider の配列は、有効な単一の SphereCollider インスタンス (2 つ目は null) か、ペアを 1 組含むことができます。前者の場合、ClothSphereColliderPair はクロスが衝突する単一のスフィアコライダーを表します。後者の場合は、円錐カプセル形で、2 つのスフィアによって定義された 1 つの円錐形を表し、円錐は 2 つを繋げます。円錐カプセル形は、キャラクターの手足をモデリングする場合に便利です。
2017–12–05 Page amended
クロスのセルフコリジョンとインターコリジョンは 2017.3 で追加NewIn20173