Overview of SoftBody2D plugin
RigidBody2D particles connected by Joint2Ds, using a Skeleton2D to deform the texture over the particles. The plugin is built using standard Godot nodes.website·Indexed 31 days ago
https://softbody2d.appsinacup.comDocumentation for the SoftBody2D Godot plugin, which allows developers to create 2D softbodies from textures using Polygon2D. It includes technical references for the SoftBody2D node, helper classes like SoftBody2DPhysics, and guides on regions, joints, rigidbodies, and skin smoothing. The plugin supports breaking and cutting mechanics and is compatible with Godot Physics and Godot Rapier Physics.
RigidBody2D particles connected by Joint2Ds, using a Skeleton2D to deform the texture over the particles. The plugin is built using standard Godot nodes.Polygon2D and creates a 2D softbody based on a texture. It functions by generating one RigidBody2D per region (each with a CollisionShape2D), connecting neighbors with Joint2Ds, and using a Skeleton2D to deform the texture based on the physics bodies.Each region of a softbody is represented as a rigidbody. These bodies act as the softbody's particles, handling world collisions while joints maintain the structure and the texture follows their movement. The internal node hierarchy for each body is:
SoftBody2D node functions as a Polygon2D that is deformed by a Skeleton2D. It assigns one Bone2D per region. To maintain surface continuity, RemoteTransform2D nodes move each bone to its corresponding rigidbody, and vertices located on the borders between regions are weighted to both adjacent bones.joint_removed and body_detached signals to react when a SoftBody2D breaks. joint_removed provides the two connected children, and body_detached provides the child that has lost all connections. Use get_clusters() to determine if the soft body has split into multiple pieces.func _ready() -> void:
$SoftBody2D.joint_removed.connect(_on_joint_removed)
$SoftBody2D.body_detached.connect(_on_body_detached)
func _on_joint_removed(a: SoftBody2D.SoftBodyChild, _b: SoftBody2D.SoftBodyChild) -> void:
# Play a rip sound where the joint gave way.
$Rip.global_position = a.rigidbody.global_position
$Rip.play()
func _on_body_detached(child: SoftBody2D.SoftBodyChild) -> void:
# Detached bodies are frozen with their shape disabled by default.
# Enable them to let the piece live as debris.
var body := child.rigidbody as RigidBody2D
body.freeze = false
child.shape.disabled = false
func _process(_delta: float) -> void:
if $SoftBody2D.get_clusters().size() > 1:
print("the softbody is in pieces")Performance cost is determined by the total number of bodies and joints. Use the following guidelines to maintain frame rates:
Joint Reach to 1 reduces the joint count but may cause the softbody to sag and self-collide.physics/common/physics_ticks_per_second at 60. Increasing this to 120 can halve the number of softbodies the engine can handle before the frame rate drops.The choice of shape type depends on the softbody pattern to avoid excessive self-collisions: