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
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
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
GetCenterBoneName(int)
Returns the center bone name of the bone chain.
public string GetCenterBoneName(int index)
Parameters
index
int
Returns
GetCenterFrom(int)
Returns what the center originates from in the bone chain.
public SpringBoneSimulator3D.CenterFrom GetCenterFrom(int index)
Parameters
index
int
Returns
GetCenterNode(int)
Returns the center node path of the bone chain.
public NodePath GetCenterNode(int index)
Parameters
index
int
Returns
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
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
Returns
GetDrag(int)
Returns the drag force damping curve of the bone chain.
public float GetDrag(int index)
Parameters
index
int
Returns
GetDragDampingCurve(int)
Returns the drag force damping curve of the bone chain.
public Curve GetDragDampingCurve(int index)
Parameters
index
int
Returns
GetEndBone(int)
Returns the end bone index of the bone chain.
public int GetEndBone(int index)
Parameters
index
int
Returns
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
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
GetEndBoneName(int)
Returns the end bone name of the bone chain.
public string GetEndBoneName(int index)
Parameters
index
int
Returns
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
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
Returns
GetGravity(int)
Returns the gravity amount of the bone chain.
public float GetGravity(int index)
Parameters
index
int
Returns
GetGravityDampingCurve(int)
Returns the gravity amount damping curve of the bone chain.
public Curve GetGravityDampingCurve(int index)
Parameters
index
int
Returns
GetGravityDirection(int)
Returns the gravity direction of the bone chain.
public Vector3 GetGravityDirection(int index)
Parameters
index
int
Returns
GetJointBone(int, int)
Returns the bone index at joint
in the bone chain's joint list.
public int GetJointBone(int index, int joint)
Parameters
Returns
GetJointBoneName(int, int)
Returns the bone name at joint
in the bone chain's joint list.
public string GetJointBoneName(int index, int joint)
Parameters
Returns
GetJointCount(int)
Returns the joint count of the bone chain's joint list.
public int GetJointCount(int index)
Parameters
index
int
Returns
GetJointDrag(int, int)
Returns the drag force at joint
in the bone chain's joint list.
public float GetJointDrag(int index, int joint)
Parameters
Returns
GetJointGravity(int, int)
Returns the gravity amount at joint
in the bone chain's joint list.
public float GetJointGravity(int index, int joint)
Parameters
Returns
GetJointGravityDirection(int, int)
Returns the gravity direction at joint
in the bone chain's joint list.
public Vector3 GetJointGravityDirection(int index, int joint)
Parameters
Returns
GetJointRadius(int, int)
Returns the radius at joint
in the bone chain's joint list.
public float GetJointRadius(int index, int joint)
Parameters
Returns
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
Returns
GetJointStiffness(int, int)
Returns the stiffness force at joint
in the bone chain's joint list.
public float GetJointStiffness(int index, int joint)
Parameters
Returns
GetRadius(int)
Returns the joint radius of the bone chain.
public float GetRadius(int index)
Parameters
index
int
Returns
GetRadiusDampingCurve(int)
Returns the joint radius damping curve of the bone chain.
public Curve GetRadiusDampingCurve(int index)
Parameters
index
int
Returns
GetRootBone(int)
Returns the root bone index of the bone chain.
public int GetRootBone(int index)
Parameters
index
int
Returns
GetRootBoneName(int)
Returns the root bone name of the bone chain.
public string GetRootBoneName(int index)
Parameters
index
int
Returns
GetRotationAxis(int)
Returns the rotation axis of the bone chain.
public SpringBoneSimulator3D.RotationAxis GetRotationAxis(int index)
Parameters
index
int
Returns
GetStiffness(int)
Returns the stiffness force of the bone chain.
public float GetStiffness(int index)
Parameters
index
int
Returns
GetStiffnessDampingCurve(int)
Returns the stiffness force damping curve of the bone chain.
public Curve GetStiffnessDampingCurve(int index)
Parameters
index
int
Returns
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_nameName of the method to check for.
Returns
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_nameName of the signal to check for.
Returns
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_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
IsConfigIndividual(int)
Returns true if the config can be edited individually for each joint.
public bool IsConfigIndividual(int index)
Parameters
index
int
Returns
IsEndBoneExtended(int)
Returns true if the end bone is extended to have the tail.
public bool IsEndBoneExtended(int index)
Parameters
index
int
Returns
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
SetCenterBoneName(int, string)
Sets the center bone name of the bone chain.
public void SetCenterBoneName(int index, string boneName)
Parameters
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
intcenterFrom
SpringBoneSimulator3D.CenterFrom
SetCenterNode(int, NodePath)
Sets the center node path of the bone chain.
public void SetCenterNode(int index, NodePath nodePath)
Parameters
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
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
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
SetDragDampingCurve(int, Curve)
Sets the drag force damping curve of the bone chain.
public void SetDragDampingCurve(int index, Curve curve)
Parameters
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
SetEndBone(int, int)
Sets the end bone index of the bone chain.
public void SetEndBone(int index, int bone)
Parameters
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
intboneDirection
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
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
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
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
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
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
SetGravityDampingCurve(int, Curve)
Sets the gravity amount damping curve of the bone chain.
public void SetGravityDampingCurve(int index, Curve curve)
Parameters
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
SetIndividualConfig(int, bool)
If enabled
is true, the config can be edited individually for each joint.
public void SetIndividualConfig(int index, bool enabled)
Parameters
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
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
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
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
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
intjoint
intaxis
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
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
SetRadiusDampingCurve(int, Curve)
Sets the joint radius damping curve of the bone chain.
public void SetRadiusDampingCurve(int index, Curve curve)
Parameters
SetRootBone(int, int)
Sets the root bone index of the bone chain.
public void SetRootBone(int index, int bone)
Parameters
SetRootBoneName(int, string)
Sets the root bone name of the bone chain.
public void SetRootBoneName(int index, string boneName)
Parameters
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
intaxis
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
SetStiffnessDampingCurve(int, Curve)
Sets the stiffness force damping curve of the bone chain.
public void SetStiffnessDampingCurve(int index, Curve curve)