Skip to content

SoftBody3D

Inherits: MeshInstance3D < GeometryInstance3D < VisualInstance3D < Entity3D < Entity < Object

A deformable 3D physics mesh.

A deformable 3D physics mesh. Used to create elastic or deformable objects such as cloth, rubber, or other flexible materials.

Additionally, SoftBody3D is subject to wind forces defined in Area3D (see Area3D.wind_source_path, Area3D.wind_force_magnitude, and Area3D.wind_attenuation_factor).

Note: It’s recommended to use Jolt Physics when using SoftBody3D instead of OrblitPhysics3D, as Jolt Physics’ soft body implementation is faster and more reliable. Jolt Physics is the default for projects created with Orblit 4.6 or later. For projects created with older Orblit versions, you can switch the physics engine using the ProjectSettings.physics/spatial/physics_engine project setting.

Type Name Default
int collision_layer 1
int collision_mask 1
float damping_coefficient 0.01
DisableMode disable_mode 0
float drag_coefficient 0.0
float linear_stiffness 0.5
EntityPath parent_collision_ignore EntityPath("")
int point_count
float pressure_coefficient 0.0
bool ray_pickable true
float shrinking_factor 0.0
int simulation_precision 5
float total_mass 1.0
Returns Method
void add_collision_exception_with(body: Entity)
void apply_central_force(force: Vector3)
void apply_central_impulse(impulse: Vector3)
void apply_force(point_index: int, force: Vector3)
void apply_impulse(point_index: int, impulse: Vector3)
Array[PhysicsBody3D] get_collision_exceptions()
bool get_collision_layer_value(layer_number: int) const
bool get_collision_mask_value(layer_number: int) const
RID get_physics_rid() const
Vector3 get_point_transform(point_index: int)
bool is_point_pinned(point_index: int) const
void remove_collision_exception_with(body: Entity)
void set_collision_layer_value(layer_number: int, value: bool)
void set_collision_mask_value(layer_number: int, value: bool)
void set_point_pinned(point_index: int, pinned: bool, attachment_path: EntityPath = EntityPath(""), insert_at: int = -1)

DisableMode

enum DisableMode

DISABLE_MODE_REMOVE = 0

When Entity.run_mode is set to Entity.RUN_MODE_DISABLED, remove from the physics simulation to stop all physics interactions with this SoftBody3D.

Automatically re-added to the physics simulation when the Entity is processed again.

DISABLE_MODE_KEEP_ACTIVE = 1

When Entity.run_mode is set to Entity.RUN_MODE_DISABLED, do not affect the physics simulation.

collision_layer

int collision_layer = 1

The physics layers this SoftBody3D is in. Collision objects can exist in one or more of 32 different layers. See also collision_mask.

Note: Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See Collision layers and masks in the documentation for more information.

collision_mask

int collision_mask = 1

The physics layers this SoftBody3D scans. Collision objects can scan one or more of 32 different layers. See also collision_layer.

Note: Object A can detect a contact with object B only if object B is in any of the layers that object A scans. See Collision layers and masks in the documentation for more information.

damping_coefficient

float damping_coefficient = 0.01

The body’s damping coefficient. Higher values will slow down the body more noticeably when forces are applied.

disable_mode

DisableMode disable_mode = 0

Defines the behavior in physics when Entity.run_mode is set to Entity.RUN_MODE_DISABLED.

drag_coefficient

float drag_coefficient = 0.0

The body’s drag coefficient. Higher values increase this body’s air resistance.

Note: This value is currently unused by Orblit’s default physics implementation.

linear_stiffness

float linear_stiffness = 0.5

Higher values will result in a stiffer body, while lower values will increase the body’s ability to bend. The value can be between 0.0 and 1.0 (inclusive).

parent_collision_ignore

EntityPath parent_collision_ignore = EntityPath("")

EntityPath to a CollisionObject3D this SoftBody3D should avoid clipping.

point_count

int point_count

The number of vertices (points) on the soft body mesh.

pressure_coefficient

float pressure_coefficient = 0.0

The pressure coefficient of this soft body. Simulate pressure build-up from inside this body. Higher values increase the strength of this effect.

ray_pickable

bool ray_pickable = true

If true, the SoftBody3D will respond to RayCast3Ds.

shrinking_factor

float shrinking_factor = 0.0

Scales the rest lengths of SoftBody3D’s edge constraints. Positive values shrink the mesh, while negative values expand it. For example, a value of 0.1 shortens the edges of the mesh by 10%, while -0.1 expands the edges by 10%.

Note: shrinking_factor is best used on surface meshes with pinned points.

simulation_precision

int simulation_precision = 5

Increasing this value will improve the resulting simulation, but can affect performance. Use with care.

total_mass

float total_mass = 1.0

The SoftBody3D’s mass.

add_collision_exception_with

void add_collision_exception_with(body: Entity)

Adds a body to the list of bodies that this body can’t collide with.

apply_central_force

void apply_central_force(force: Vector3)

Distributes and applies a force to all points. A force is time dependent and meant to be applied every physics update.

apply_central_impulse

void apply_central_impulse(impulse: Vector3)

Distributes and applies an impulse to all points.

An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the “_force” functions otherwise).

apply_force

void apply_force(point_index: int, force: Vector3)

Applies a force to a point. A force is time dependent and meant to be applied every physics update.

apply_impulse

void apply_impulse(point_index: int, impulse: Vector3)

Applies an impulse to a point.

An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the “_force” functions otherwise).

get_collision_exceptions

Array[PhysicsBody3D] get_collision_exceptions()

Returns an array of nodes that were added as collision exceptions for this body.

get_collision_layer_value

bool get_collision_layer_value(layer_number: int) const

Returns whether or not the specified layer of the collision_layer is enabled, given a layer_number between 1 and 32.

get_collision_mask_value

bool get_collision_mask_value(layer_number: int) const

Returns whether or not the specified layer of the collision_mask is enabled, given a layer_number between 1 and 32.

get_physics_rid

RID get_physics_rid() const

Returns the internal RID used by the PhysicsSystem3D for this body.

get_point_transform

Vector3 get_point_transform(point_index: int)

Returns local translation of a vertex in the surface array.

is_point_pinned

bool is_point_pinned(point_index: int) const

Returns true if vertex is set to pinned.

remove_collision_exception_with

void remove_collision_exception_with(body: Entity)

Removes a body from the list of bodies that this body can’t collide with.

set_collision_layer_value

void set_collision_layer_value(layer_number: int, value: bool)

Based on value, enables or disables the specified layer in the collision_layer, given a layer_number between 1 and 32.

set_collision_mask_value

void set_collision_mask_value(layer_number: int, value: bool)

Based on value, enables or disables the specified layer in the collision_mask, given a layer_number between 1 and 32.

set_point_pinned

void set_point_pinned(point_index: int, pinned: bool, attachment_path: EntityPath = EntityPath(""), insert_at: int = -1)

Sets the pinned state of a surface vertex. When set to true, the optional attachment_path can define a Entity3D the pinned vertex will be attached to.