Class reference

SoftBody3D

Inherits MeshInstance3D

A deformable 3D physics mesh.

Description

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 the default GodotPhysics3D, as Jolt Physics' soft body implementation is faster and more reliable. You can switch the physics engine using the ProjectSettings.physics/3d/physics_engine project setting.

Properties

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.

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.

float damping_coefficient = 0.01

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

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 Redot's default physics implementation.

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).

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.

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.

int simulation_precision = 5

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

float total_mass = 1.0

The SoftBody3D's mass.

Methods

void add_collision_exception_with(Node body)

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

void apply_central_force(Vector3 force)

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

void apply_central_impulse(Vector3 impulse)

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).

void apply_force(int point_index, Vector3 force)

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

void apply_impulse(int point_index, Vector3 impulse)

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).

PhysicsBody3D[] get_collision_exceptions()

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

bool get_collision_layer_value(int layer_number) const

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

bool get_collision_mask_value(int layer_number) const

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

Vector3 get_point_transform(int point_index)

Returns local translation of a vertex in the surface array.

bool is_point_pinned(int point_index) const

Returns true if vertex is set to pinned.

void remove_collision_exception_with(Node body)

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

void set_collision_layer_value(int layer_number, bool value)

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

void set_collision_mask_value(int layer_number, bool value)

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

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

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

Constants

Tutorials

Source revision 5592dc3a7a61
Connection interrupted. Reload×

Rejoining the server...

Rejoin failed... trying again in seconds.

Failed to rejoin.
Please retry or reload the page.

The session has been paused by the server.

Failed to resume the session.
Please retry or reload the page.