Work in progress

The content of this page was not yet updated for Godot 4.2 and may be outdated. If you know how to improve this page or you can confirm that it's up to date, feel free to open a pull request.

Using SoftBody

Soft Body(またはSoft Bodyダイナミクス )は、変形可能なオブジェクトの動き、形状の変化、その他の物理的特性をシミュレートします。 これは、たとえば、布をシミュレートしたり、よりリアルなキャラクターを作成するために使用できます。

基本的なセットアップ

A SoftBody3D node is used for soft body simulations.

弾力のある立方体を作成して、ソフトボディのセットアップを示します。

Create a new scene with a Node3D node as root. Then, create a Softbody node. Add a CubeMesh in the mesh property of the node in the inspector and increase the subdivision of the mesh for simulation.

../../_images/softbody_cube.png

パラメーターを設定して、目的のソフトボディのタイプを取得します。Simulation Precision を5以上に維持してください。そうしないと、ソフトボディが破たんする可能性があります。

../../_images/softbody_cube_menu.png

注釈

一部の値は奇妙な結果につながる可能性があるため、一部のパラメーターは注意して処理してください。 たとえば、シェイプが完全に閉じられておらず、pressureを0より大きい値に設定すると、ソフトボディは強風の下でビニール袋のように飛び回ります。

シーンを再生してシミュレーションを表示します。

ちなみに

シミュレーションの結果を改善するために、Simulation Precision を上げると、パフォーマンスを犠牲にして大幅に改善されます。

マントのシミュレーション

Platformer3Dのデモでマントを作りましょう。

注釈

You can download the Platformer3D demo on GitHub or the Asset Library.

Player シーンを開き、SoftBody ノードを追加して PlaneMesh を割り当てます。

PlaneMesh プロパティを開き、size(x: 0.5 y: 1)を設定し、Subdivide Width と``Subdivide Depth`` を5に設定します。SoftBody の位置を調整します。次のようなことが起きてしまいます:

../../_images/softbody_cloak_subdivide.png

ちなみに

サブディビジョンでは、より優れたシミュレーションのために、よりテッセレーションされたメッシュが生成されます。

Add a BoneAttachment3D node under the skeleton node and select the Neck bone to attach the cloak to the character skeleton.

注釈

BoneAttachment3D node is to attach objects to a bone of a armature. The attached object will follow the bone's movement, weapon of a character can be attached this way.

../../_images/softbody_cloak_bone_attach.png

ピンジョイントを作成するには、SoftBody ノードの上の頂点を選択します:

../../_images/softbody_cloak_pinned.png

The pinned joints can be found in SoftBody's Attachments property, choose the BoneAttachment as the SpatialAttachment for each pinned joints, the pinned joints are now attached to the neck.

../../_images/softbody_cloak_pinned_attach.png

最後のステップは、SoftBodyParent Collision Ignore にキネマティックボディ Player を追加して、クリッピングを回避することです。

../../_images/softbody_cloak_ignore.png

シーンを再生すると、マントは正しくシミュレートされます。

../../_images/softbody_cloak_finish.png

これは、ソフトボディの基本設定をカバーし、ゲームを作成するときに目標とする効果を達成するためのパラメーターを実験できます。