Skip to content

SoftBody2D ​

class in OpalScript

Deformable jelly and cloth with a textured mesh, spring connections, collisions, and pinned edges. Add directly to a sprite or shape, then choose a preset in the inspector.

Properties ​

MemberDescription
SoftBody2D.SimulationPositionRead-only world position from the latest physics step, in pixels. Unlike Transform.WorldPosition, this is the simulation pose rather than the interpolated visual pose.
SoftBody2D.SimulationRotationRead-only simulation rotation in degrees from the latest physics step.
SoftBody2D.EnabledWhether this component is enabled. Use SetEnabled to change it.
SoftBody2D.SpeedSpeed of the body's center of mass (pixels/second).
SoftBody2D.DeformationAverage relative change in mesh edge lengths. 0 is at rest; 0.1 is approximately ten percent stretch or compression.
SoftBody2D.ContactCountNumber of other scene objects currently touching this soft body.
SoftBody2D.ParticleCountNumber of particles in the running simulation.

Methods ​

MemberDescription
SoftBody2D.ApplyImpulseDistribute a world-space impulse across movable particles. Total Mass determines the resulting velocity change.
SoftBody2D.SetVelocitySet every movable particle's velocity in pixels/second.
SoftBody2D.ResetShapeRestore the mesh's starting shape and initial velocities.
SoftBody2D.SetEnabledEnable or disable this component's behavior.

See also ​