Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

SoftBody3D

繼承: MeshInstance3D < GeometryInstance3D < VisualInstance3D < Node3D < Node < Object

可形變的 3D 物理網格。

說明

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.

教學

屬性

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

NodePath

parent_collision_ignore

NodePath("")

float

pressure_coefficient

0.0

bool

ray_pickable

true

float

shrinking_factor

0.0

int

simulation_precision

5

float

total_mass

1.0

方法

void

add_collision_exception_with(body: Node)

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: Node)

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: NodePath = NodePath(""), insert_at: int = -1)


列舉

enum DisableMode: 🔗

DisableMode DISABLE_MODE_REMOVE = 0

Node.process_mode 被設定為 Node.PROCESS_MODE_DISABLED 時,從物理模擬中移除,停止與此 SoftBody3D 的所有物理互動。

當該 Node 再次被處理時,會自動重新加入到物理模擬中。

DisableMode DISABLE_MODE_KEEP_ACTIVE = 1

Node.process_mode 被設定為 Node.PROCESS_MODE_DISABLED 時,不影響物理模擬。


屬性說明

int collision_layer = 1 🔗

  • void set_collision_layer(value: int)

  • int get_collision_layer()

該 SoftBody3D 所在的實體層。碰撞物件可以存在於 32 個不同層中的一個或多個層中。另見 collision_mask

注意:只有當物件 B 位於物件 A 掃描的任意層中時,物件 A 才能偵測到與對象 B 的接觸。有關更多資訊,請參閱文件中的《碰撞層與遮罩》


int collision_mask = 1 🔗

  • void set_collision_mask(value: int)

  • int get_collision_mask()

該 SoftBody3D 掃描的實體層。碰撞物件可以掃描 32 個不同層中的一個或多個層。另見 collision_layer

注意:只有當物件 B 位於物件 A 掃描的任何層中時,物件 A 才能偵測到與對象 B 的接觸。有關更多資訊,請參閱文件中的《碰撞層與遮罩》


float damping_coefficient = 0.01 🔗

  • void set_damping_coefficient(value: float)

  • float get_damping_coefficient()

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


DisableMode disable_mode = 0 🔗

Defines the behavior in physics when Node.process_mode is set to Node.PROCESS_MODE_DISABLED.


float drag_coefficient = 0.0 🔗

  • void set_drag_coefficient(value: float)

  • float get_drag_coefficient()

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

Note: This value is currently unused by Godot's default physics implementation.


float linear_stiffness = 0.5 🔗

  • void set_linear_stiffness(value: float)

  • float get_linear_stiffness()

較高的值會導致身體更僵硬,而較低的值將增加身體的彎曲能力。該值可在0.0``1.0 ``(包含)。


NodePath parent_collision_ignore = NodePath("") 🔗

  • void set_parent_collision_ignore(value: NodePath)

  • NodePath get_parent_collision_ignore()

指向 CollisionObject3DNodePath,這個 SoftBody3D 應該避免穿過它。


float pressure_coefficient = 0.0 🔗

  • void set_pressure_coefficient(value: float)

  • float get_pressure_coefficient()

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


bool ray_pickable = true 🔗

  • void set_ray_pickable(value: bool)

  • bool is_ray_pickable()

如果為 true,則該 SoftBody3D 會回應 RayCast3D


float shrinking_factor = 0.0 🔗

  • void set_shrinking_factor(value: float)

  • float get_shrinking_factor()

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 🔗

  • void set_simulation_precision(value: int)

  • int get_simulation_precision()

增加這個值會改善模擬結果,但會影響性能。請小心使用。


float total_mass = 1.0 🔗

  • void set_total_mass(value: float)

  • float get_total_mass()

The SoftBody3D's mass.


方法說明

void add_collision_exception_with(body: Node) 🔗

將一個物體新增到這個物體不能碰撞的物體列表中。


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.


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


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.


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


Array[PhysicsBody3D] get_collision_exceptions() 🔗

返回該物體的碰撞例外節點陣列。


bool get_collision_layer_value(layer_number: int) const 🔗

返回 collision_layer 中是否啟用了指定的層,給定的 layer_number 應在 1 和 32 之間。


bool get_collision_mask_value(layer_number: int) const 🔗

返回 collision_mask 中是否啟用了指定的層,給定的 layer_number 應在 1 和 32 之間。


RID get_physics_rid() const 🔗

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


Vector3 get_point_transform(point_index: int) 🔗

返回表面陣列中頂點的局部平移。


bool is_point_pinned(point_index: int) const 🔗

如果頂點設定為固定,則返回 true


void remove_collision_exception_with(body: Node) 🔗

將一個物體從該物體不能碰撞的物體列表中移除。


void set_collision_layer_value(layer_number: int, value: bool) 🔗

根據 value,啟用或禁用 collision_layer 中指定的層,給定的 layer_number 應在 1 和 32 之間。


void set_collision_mask_value(layer_number: int, value: bool) 🔗

根據 value,啟用或禁用 collision_mask 中指定的層,給定的 layer_number 應在 1 和 32 之間。


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

設定表面頂點的固定狀態。當設定為 true 時,可選的 attachment_path 可以定義一個 Node3D,該固定頂點將被附加到該節點。