Work in progress

The content of this page was not yet updated for Godot 4.5 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 SoftBody3D

Los cuerpos blandos (o dinámica de cuerpos blandos) simulan el movimiento, el cambio de forma y otras propiedades físicas de los objetos deformables. Esto puede ser usado, por ejemplo, para simular la tela o para crear personajes más realistas.

Configuración básica

A SoftBody3D node is used for soft body simulations.

Crearemos un cubo de rebote para demostrar la configuración de un cuerpo blando.

Create a new scene with a Node3D node as root. Then, create a SoftBody3D 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

Establezca los parámetros para obtener el tipo de cuerpo blando al que apunta. Intenta mantener la Simulation Precision por encima de 5, de lo contrario, el cuerpo blando puede colapsar.

../../_images/softbody_cube_menu.png

Nota

Maneja algunos parámetros con cuidado, ya que algún valor puede llevar a resultados extraños. Por ejemplo, si la forma no está completamente cerrada y se establece la presión a más de 0, el cuerpo blando volará como una bolsa de plástico bajo un viento fuerte.

Ejecuta la escena para ver la simulación.

Truco

Para mejorar el resultado de la simulación, aumentar la Simulation Precision, esto dará una mejora significativa a costa del rendimiento.

Simulación de una capa

Hagamos una capa en la demo de Platformer3D.

Nota

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

Open the Player scene, add a SoftBody3D node and assign a PlaneMesh to it.

Open the PlaneMesh properties and set the size(x: 0.5 y: 1) then set Subdivide Width and Subdivide Depth to 5. Adjust the SoftBody3D's position. You should end up with something like this:

../../_images/softbody_cloak_subdivide.png

Truco

La subdivisión genera una malla más teselada para mejores simulaciones.

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

Nota

BoneAttachment3D node is to attach objects to a bone of an 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

To create pinned joints, select the upper vertices in the SoftBody3D node:

../../_images/softbody_cloak_pinned.png

The pinned joints can be found in SoftBody3D'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

Last step is to avoid clipping by adding the Kinematic Body Player to Parent Collision Ignore of the SoftBody3D.

../../_images/softbody_cloak_ignore.png

Reproduce la escena y la capa deberia simularse correctamente.

../../_images/softbody_cloak_finish.png

Esto cubre los ajustes básicos de softbody, experimenta con los parámetros para conseguir el efecto que desees al hacer tu juego.

Using Imported Meshes

The Save to File option in the Advanced Import Settings dialog allows you to save a mesh to a standalone resource file that you can then attach to SoftBody3D nodes.

You may also want to disable LOD generation or change the LOD generation options when importing a mesh for use with SoftBody3D. The default import settings will produce an LOD that merges adjacent faces that are nearly flat with respect to each other, even at very close render distances. This works well for static meshes, but is often undesirable for use with SoftBody3D if you want these faces to be able to bend and move with respect to each other, instead of being rendered as a single plane.

See Import configuration and Mesh level of detail (LOD) for more details.