Table of Contents

Class SpringBoneSimulator3D

Namespace
Godot
Assembly
GodotSharp.dll

This SkeletonModifier3D can be used to wiggle hair, cloth, and tails. This modifier behaves differently from PhysicalBoneSimulator3D as it attempts to return the original pose after modification.

If you setup SetRootBone(int, int) and SetEndBone(int, int), it is treated as one bone chain. Note that it does not support a branched chain like Y-shaped chains.

When a bone chain is created, an array is generated from the bones that exist in between and listed in the joint list.

Several properties can be applied to each joint, such as SetJointStiffness(int, int, float), SetJointDrag(int, int, float), and SetJointGravity(int, int, float).

For simplicity, you can set values to all joints at the same time by using a Curve. If you want to specify detailed values individually, set SetIndividualConfig(int, bool) to true.

For physical simulation, SpringBoneSimulator3D can have children as self-standing collisions that are not related to PhysicsServer3D, see also SpringBoneCollision3D.

Warning: A scaled SpringBoneSimulator3D will likely not behave as expected. Make sure that the parent Skeleton3D and its bones are not scaled.

public class SpringBoneSimulator3D : SkeletonModifier3D, IDisposable
Inheritance
SpringBoneSimulator3D
Implements
Inherited Members

Constructors

SpringBoneSimulator3D()

public SpringBoneSimulator3D()

Properties

SettingCount

The number of settings.

public int SettingCount { get; set; }

Property Value

int

Methods

AreAllChildCollisionsEnabled(int)

Returns true if the all child SpringBoneCollision3Ds are contained in the collision list at index in the settings.

public bool AreAllChildCollisionsEnabled(int index)

Parameters

index int

Returns

bool

ClearCollisions(int)

Clears all collisions from the collision list at index in the settings when AreAllChildCollisionsEnabled(int) is false.

public void ClearCollisions(int index)

Parameters

index int

ClearExcludeCollisions(int)

Clears all exclude collisions from the collision list at index in the settings when AreAllChildCollisionsEnabled(int) is true.

public void ClearExcludeCollisions(int index)

Parameters

index int

ClearSettings()

Clears all settings.

public void ClearSettings()

GetCenterBone(int)

Returns the center bone index of the bone chain.

public int GetCenterBone(int index)

Parameters

index int

Returns

int

GetCenterBoneName(int)

Returns the center bone name of the bone chain.

public string GetCenterBoneName(int index)

Parameters

index int

Returns

string

GetCenterFrom(int)

Returns what the center originates from in the bone chain.

public SpringBoneSimulator3D.CenterFrom GetCenterFrom(int index)

Parameters

index int

Returns

SpringBoneSimulator3D.CenterFrom

GetCenterNode(int)

Returns the center node path of the bone chain.

public NodePath GetCenterNode(int index)

Parameters

index int

Returns

NodePath

GetCollisionCount(int)

Returns the collision count of the bone chain's collision list when AreAllChildCollisionsEnabled(int) is false.

public int GetCollisionCount(int index)

Parameters

index int

Returns

int

GetCollisionPath(int, int)

Returns the node path of the SpringBoneCollision3D at collision in the bone chain's collision list when AreAllChildCollisionsEnabled(int) is false.

public NodePath GetCollisionPath(int index, int collision)

Parameters

index int
collision int

Returns

NodePath

GetDrag(int)

Returns the drag force damping curve of the bone chain.

public float GetDrag(int index)

Parameters

index int

Returns

float

GetDragDampingCurve(int)

Returns the drag force damping curve of the bone chain.

public Curve GetDragDampingCurve(int index)

Parameters

index int

Returns

Curve

GetEndBone(int)

Returns the end bone index of the bone chain.

public int GetEndBone(int index)

Parameters

index int

Returns

int

GetEndBoneDirection(int)

Returns the end bone's tail direction of the bone chain when IsEndBoneExtended(int) is true.

public SpringBoneSimulator3D.BoneDirection GetEndBoneDirection(int index)

Parameters

index int

Returns

SpringBoneSimulator3D.BoneDirection

GetEndBoneLength(int)

Returns the end bone's tail length of the bone chain when IsEndBoneExtended(int) is true.

public float GetEndBoneLength(int index)

Parameters

index int

Returns

float

GetEndBoneName(int)

Returns the end bone name of the bone chain.

public string GetEndBoneName(int index)

Parameters

index int

Returns

string

GetExcludeCollisionCount(int)

Returns the exclude collision count of the bone chain's exclude collision list when AreAllChildCollisionsEnabled(int) is true.

public int GetExcludeCollisionCount(int index)

Parameters

index int

Returns

int

GetExcludeCollisionPath(int, int)

Returns the node path of the SpringBoneCollision3D at collision in the bone chain's exclude collision list when AreAllChildCollisionsEnabled(int) is true.

public NodePath GetExcludeCollisionPath(int index, int collision)

Parameters

index int
collision int

Returns

NodePath

GetGravity(int)

Returns the gravity amount of the bone chain.

public float GetGravity(int index)

Parameters

index int

Returns

float

GetGravityDampingCurve(int)

Returns the gravity amount damping curve of the bone chain.

public Curve GetGravityDampingCurve(int index)

Parameters

index int

Returns

Curve

GetGravityDirection(int)

Returns the gravity direction of the bone chain.

public Vector3 GetGravityDirection(int index)

Parameters

index int

Returns

Vector3

GetJointBone(int, int)

Returns the bone index at joint in the bone chain's joint list.

public int GetJointBone(int index, int joint)

Parameters

index int
joint int

Returns

int

GetJointBoneName(int, int)

Returns the bone name at joint in the bone chain's joint list.

public string GetJointBoneName(int index, int joint)

Parameters

index int
joint int

Returns

string

GetJointCount(int)

Returns the joint count of the bone chain's joint list.

public int GetJointCount(int index)

Parameters

index int

Returns

int

GetJointDrag(int, int)

Returns the drag force at joint in the bone chain's joint list.

public float GetJointDrag(int index, int joint)

Parameters

index int
joint int

Returns

float

GetJointGravity(int, int)

Returns the gravity amount at joint in the bone chain's joint list.

public float GetJointGravity(int index, int joint)

Parameters

index int
joint int

Returns

float

GetJointGravityDirection(int, int)

Returns the gravity direction at joint in the bone chain's joint list.

public Vector3 GetJointGravityDirection(int index, int joint)

Parameters

index int
joint int

Returns

Vector3

GetJointRadius(int, int)

Returns the radius at joint in the bone chain's joint list.

public float GetJointRadius(int index, int joint)

Parameters

index int
joint int

Returns

float

GetJointRotationAxis(int, int)

Returns the rotation axis at joint in the bone chain's joint list.

public SpringBoneSimulator3D.RotationAxis GetJointRotationAxis(int index, int joint)

Parameters

index int
joint int

Returns

SpringBoneSimulator3D.RotationAxis

GetJointStiffness(int, int)

Returns the stiffness force at joint in the bone chain's joint list.

public float GetJointStiffness(int index, int joint)

Parameters

index int
joint int

Returns

float

GetRadius(int)

Returns the joint radius of the bone chain.

public float GetRadius(int index)

Parameters

index int

Returns

float

GetRadiusDampingCurve(int)

Returns the joint radius damping curve of the bone chain.

public Curve GetRadiusDampingCurve(int index)

Parameters

index int

Returns

Curve

GetRootBone(int)

Returns the root bone index of the bone chain.

public int GetRootBone(int index)

Parameters

index int

Returns

int

GetRootBoneName(int)

Returns the root bone name of the bone chain.

public string GetRootBoneName(int index)

Parameters

index int

Returns

string

GetRotationAxis(int)

Returns the rotation axis of the bone chain.

public SpringBoneSimulator3D.RotationAxis GetRotationAxis(int index)

Parameters

index int

Returns

SpringBoneSimulator3D.RotationAxis

GetStiffness(int)

Returns the stiffness force of the bone chain.

public float GetStiffness(int index)

Parameters

index int

Returns

float

GetStiffnessDampingCurve(int)

Returns the stiffness force damping curve of the bone chain.

public Curve GetStiffnessDampingCurve(int index)

Parameters

index int

Returns

Curve

HasGodotClassMethod(in godot_string_name)

Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.

protected override bool HasGodotClassMethod(in godot_string_name method)

Parameters

method godot_string_name

Name of the method to check for.

Returns

bool

HasGodotClassSignal(in godot_string_name)

Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.

protected override bool HasGodotClassSignal(in godot_string_name signal)

Parameters

signal godot_string_name

Name of the signal to check for.

Returns

bool

InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)

Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.

protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)

Parameters

method godot_string_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

IsConfigIndividual(int)

Returns true if the config can be edited individually for each joint.

public bool IsConfigIndividual(int index)

Parameters

index int

Returns

bool

IsEndBoneExtended(int)

Returns true if the end bone is extended to have the tail.

public bool IsEndBoneExtended(int index)

Parameters

index int

Returns

bool

Reset()

Resets a simulating state with respect to the current bone pose.

It is useful to prevent the simulation result getting violent. For example, calling this immediately after a call to Play(StringName, double, float, bool) without a fading, or within the previous ModificationProcessed signal if it's condition changes significantly.

public void Reset()

SetCenterBone(int, int)

Sets the center bone index of the bone chain.

public void SetCenterBone(int index, int bone)

Parameters

index int
bone int

SetCenterBoneName(int, string)

Sets the center bone name of the bone chain.

public void SetCenterBoneName(int index, string boneName)

Parameters

index int
boneName string

SetCenterFrom(int, CenterFrom)

Sets what the center originates from in the bone chain.

Bone movement is calculated based on the difference in relative distance between center and bone in the previous and next frames.

For example, if the parent Skeleton3D is used as the center, the bones are considered to have not moved if the Skeleton3D moves in the world.

In this case, only a change in the bone pose is considered to be a bone movement.

public void SetCenterFrom(int index, SpringBoneSimulator3D.CenterFrom centerFrom)

Parameters

index int
centerFrom SpringBoneSimulator3D.CenterFrom

SetCenterNode(int, NodePath)

Sets the center node path of the bone chain.

public void SetCenterNode(int index, NodePath nodePath)

Parameters

index int
nodePath NodePath

SetCollisionCount(int, int)

Sets the number of collisions in the collision list at index in the settings when AreAllChildCollisionsEnabled(int) is false.

public void SetCollisionCount(int index, int count)

Parameters

index int
count int

SetCollisionPath(int, int, NodePath)

Sets the node path of the SpringBoneCollision3D at collision in the bone chain's collision list when AreAllChildCollisionsEnabled(int) is false.

public void SetCollisionPath(int index, int collision, NodePath nodePath)

Parameters

index int
collision int
nodePath NodePath

SetDrag(int, float)

Sets the drag force of the bone chain. The greater the value, the more suppressed the wiggling.

The value is scaled by SetDragDampingCurve(int, Curve) and cached in each joint setting in the joint list.

public void SetDrag(int index, float drag)

Parameters

index int
drag float

SetDragDampingCurve(int, Curve)

Sets the drag force damping curve of the bone chain.

public void SetDragDampingCurve(int index, Curve curve)

Parameters

index int
curve Curve

SetEnableAllChildCollisions(int, bool)

If sets enabled to true, the all child SpringBoneCollision3Ds are collided and SetExcludeCollisionPath(int, int, NodePath) is enabled as an exclusion list at index in the settings.

If sets enabled to false, you need to manually register all valid collisions with SetCollisionPath(int, int, NodePath).

public void SetEnableAllChildCollisions(int index, bool enabled)

Parameters

index int
enabled bool

SetEndBone(int, int)

Sets the end bone index of the bone chain.

public void SetEndBone(int index, int bone)

Parameters

index int
bone int

SetEndBoneDirection(int, BoneDirection)

Sets the end bone tail direction of the bone chain when IsEndBoneExtended(int) is true.

public void SetEndBoneDirection(int index, SpringBoneSimulator3D.BoneDirection boneDirection)

Parameters

index int
boneDirection SpringBoneSimulator3D.BoneDirection

SetEndBoneLength(int, float)

Sets the end bone tail length of the bone chain when IsEndBoneExtended(int) is true.

public void SetEndBoneLength(int index, float length)

Parameters

index int
length float

SetEndBoneName(int, string)

Sets the end bone name of the bone chain.

Note: End bone must be the root bone or a child of the root bone. If they are the same, the tail must be extended by SetExtendEndBone(int, bool) to jiggle the bone.

public void SetEndBoneName(int index, string boneName)

Parameters

index int
boneName string

SetExcludeCollisionCount(int, int)

Sets the number of exclude collisions in the exclude collision list at index in the settings when AreAllChildCollisionsEnabled(int) is true.

public void SetExcludeCollisionCount(int index, int count)

Parameters

index int
count int

SetExcludeCollisionPath(int, int, NodePath)

Sets the node path of the SpringBoneCollision3D at collision in the bone chain's exclude collision list when AreAllChildCollisionsEnabled(int) is true.

public void SetExcludeCollisionPath(int index, int collision, NodePath nodePath)

Parameters

index int
collision int
nodePath NodePath

SetExtendEndBone(int, bool)

If enabled is true, the end bone is extended to have the tail.

The extended tail config is allocated to the last element in the joint list.

In other words, if you set enabled is false, the config of last element in the joint list has no effect in the simulated result.

public void SetExtendEndBone(int index, bool enabled)

Parameters

index int
enabled bool

SetGravity(int, float)

Sets the gravity amount of the bone chain. This value is not an acceleration, but a constant velocity of movement in SetGravityDirection(int, Vector3).

If gravity is not 0, the modified pose will not return to the original pose since it is always affected by gravity.

The value is scaled by SetGravityDampingCurve(int, Curve) and cached in each joint setting in the joint list.

public void SetGravity(int index, float gravity)

Parameters

index int
gravity float

SetGravityDampingCurve(int, Curve)

Sets the gravity amount damping curve of the bone chain.

public void SetGravityDampingCurve(int index, Curve curve)

Parameters

index int
curve Curve

SetGravityDirection(int, Vector3)

Sets the gravity direction of the bone chain. This value is internally normalized and then multiplied by SetGravity(int, float).

The value is cached in each joint setting in the joint list.

public void SetGravityDirection(int index, Vector3 gravityDirection)

Parameters

index int
gravityDirection Vector3

SetIndividualConfig(int, bool)

If enabled is true, the config can be edited individually for each joint.

public void SetIndividualConfig(int index, bool enabled)

Parameters

index int
enabled bool

SetJointDrag(int, int, float)

Sets the drag force at joint in the bone chain's joint list when IsConfigIndividual(int) is true.

public void SetJointDrag(int index, int joint, float drag)

Parameters

index int
joint int
drag float

SetJointGravity(int, int, float)

Sets the gravity amount at joint in the bone chain's joint list when IsConfigIndividual(int) is true.

public void SetJointGravity(int index, int joint, float gravity)

Parameters

index int
joint int
gravity float

SetJointGravityDirection(int, int, Vector3)

Sets the gravity direction at joint in the bone chain's joint list when IsConfigIndividual(int) is true.

public void SetJointGravityDirection(int index, int joint, Vector3 gravityDirection)

Parameters

index int
joint int
gravityDirection Vector3

SetJointRadius(int, int, float)

Sets the joint radius at joint in the bone chain's joint list when IsConfigIndividual(int) is true.

public void SetJointRadius(int index, int joint, float radius)

Parameters

index int
joint int
radius float

SetJointRotationAxis(int, int, RotationAxis)

Sets the rotation axis at joint in the bone chain's joint list when IsConfigIndividual(int) is true.

public void SetJointRotationAxis(int index, int joint, SpringBoneSimulator3D.RotationAxis axis)

Parameters

index int
joint int
axis SpringBoneSimulator3D.RotationAxis

SetJointStiffness(int, int, float)

Sets the stiffness force at joint in the bone chain's joint list when IsConfigIndividual(int) is true.

public void SetJointStiffness(int index, int joint, float stiffness)

Parameters

index int
joint int
stiffness float

SetRadius(int, float)

Sets the joint radius of the bone chain. It is used to move and slide with the SpringBoneCollision3D in the collision list.

The value is scaled by SetRadiusDampingCurve(int, Curve) and cached in each joint setting in the joint list.

public void SetRadius(int index, float radius)

Parameters

index int
radius float

SetRadiusDampingCurve(int, Curve)

Sets the joint radius damping curve of the bone chain.

public void SetRadiusDampingCurve(int index, Curve curve)

Parameters

index int
curve Curve

SetRootBone(int, int)

Sets the root bone index of the bone chain.

public void SetRootBone(int index, int bone)

Parameters

index int
bone int

SetRootBoneName(int, string)

Sets the root bone name of the bone chain.

public void SetRootBoneName(int index, string boneName)

Parameters

index int
boneName string

SetRotationAxis(int, RotationAxis)

Sets the rotation axis of the bone chain. If sets a specific axis, it acts like a hinge joint.

The value is cached in each joint setting in the joint list.

Note: The rotation axis and the forward vector shouldn't be colinear to avoid unintended rotation since SpringBoneSimulator3D does not factor in twisting forces.

public void SetRotationAxis(int index, SpringBoneSimulator3D.RotationAxis axis)

Parameters

index int
axis SpringBoneSimulator3D.RotationAxis

SetStiffness(int, float)

Sets the stiffness force of the bone chain. The greater the value, the faster it recovers to its initial pose.

If stiffness is 0, the modified pose will not return to the original pose.

The value is scaled by SetStiffnessDampingCurve(int, Curve) and cached in each joint setting in the joint list.

public void SetStiffness(int index, float stiffness)

Parameters

index int
stiffness float

SetStiffnessDampingCurve(int, Curve)

Sets the stiffness force damping curve of the bone chain.

public void SetStiffnessDampingCurve(int index, Curve curve)

Parameters

index int
curve Curve