appsinacup / godot-softbody2d

Godot SoftBody2D - Plugin that adds deformable 2D soft body.
MIT License
257 stars 13 forks source link
godot godot-4 godot-plugin godot4 softbody

Documentation | Discord


2D squishy softbodies for the Godot game engine.


Adds the SoftBody2D node which creates a set of RigidBody2Ds and Joint2Ds used with a Skeleton2D in order to deform the texture.

Installation

Features

You can create multiple types of softbodies with this plugin, such as:

How this plugin creates a softbody

1. Create polygon from texture around edge.
2. Optionally do the same for hole texture.
3. Create multiple regions of same size around polygon.
4. Delete the regions the polygon or inside the hole polygon.
5. Creates a `Skeleton2D` child. Creates a set of `Bone2D` nodes of the `Skeleton2D`, each having a region and assign correct weights to them.
6. Creates a set of `RigidBody2D` nodes, one for each region with a `CollisionShape2D` child, a `RemoteTransform2D` child that targets the coresponding `Bone2D` position, and a set of `Joint2D` children that connect neighbouring rigidbodies. Also for each `Bone2D` node, make it lookat another neighbour node.
7. When the joint length is too big, the joints breaks. Then, the weights for both bones are updated to no longer have weights in the other region.