SkeletonModification2DJiggle
A modification that jiggles Bone2D
nodes as they move towards a target.
class SkeletonModification2DJiggle
This modification moves a series of bones, typically called a bone chain, towards a target. What makes this modification special is that it calculates the velocity and acceleration for each bone in the bone chain, and runs a very light physics-like calculation using the inputted values. This allows the bones to overshoot the target and “jiggle” around. It can be configured to act more like a spring, or sway around like cloth might.
This modification is useful for adding additional motion to things like hair, the edges of clothing, and more. It has several settings to that allow control over how the joint moves when the target moves.
Superclasses
class SkeletonModification2D
Base class for resources that operate on
Bone2D
s in aSkeleton2D
.
Citizens in SwiftGodot
Conformances
protocol CustomStringConvertible
A type with a customized textual representation.
protocol Equatable
A type that can be compared for value equality.
protocol Hashable
A type that can be hashed into a
Hasher
to produce an integer hash value.protocol Identifiable<ID>
A class of types whose instances hold the value of an entity with stable identity.
protocol VariantRepresentable
Types that conform to VariantRepresentable can be stored directly in
Variant
with no conversion. These include all of the Variant types from Godot (for exampleGString
,Rect
,Plane
), Godot objects (those that subclass SwiftGodot.Object) as well as the built-in Swift types UInt8, Int64 and Double.protocol VariantStorable
Types that conform to VariantStorable can be stored in a Variant and can be extracted back out of a Variant.
Type members
Instance members
var damping: Double
The default amount of damping applied to the Jiggle joints, if they are not overridden. Higher values lead to more of the calculated velocity being applied.
var gravity: Vector2
The default amount of gravity applied to the Jiggle joints, if they are not overridden.
var jiggleDataChainLength: Int32
The amount of Jiggle joints in the Jiggle modification.
var mass: Double
The default amount of mass assigned to the Jiggle joints, if they are not overridden. Higher values lead to faster movements and more overshooting.
var stiffness: Double
The default amount of stiffness assigned to the Jiggle joints, if they are not overridden. Higher values act more like springs, quickly moving into the correct position.
var targetNodepath: NodePath
The NodePath to the node that is the target for the Jiggle modification. This node is what the Jiggle chain will attempt to rotate the bone chain to.
var useGravity: Bool
Whether the gravity vector,
gravity
, should be applied to the Jiggle joints, assuming they are not overriding the default settings.func getCollisionMask(
) -> Int32 Returns the collision mask used by the Jiggle modifier when collisions are enabled.
func getJiggleJointBone2dNode(jointIdx: Int32
) -> NodePath Returns the
Bone2D
node assigned to the Jiggle joint atjointIdx
.func getJiggleJointBoneIndex(jointIdx: Int32
) -> Int32 Returns the index of the
Bone2D
node assigned to the Jiggle joint atjointIdx
.func getJiggleJointDamping(jointIdx: Int32
) -> Double Returns the amount of damping of the Jiggle joint at
jointIdx
.func getJiggleJointGravity(jointIdx: Int32
) -> Vector2 Returns a
Vector2
representing the amount of gravity the Jiggle joint atjointIdx
is influenced by.func getJiggleJointMass(jointIdx: Int32
) -> Double Returns the amount of mass of the jiggle joint at
jointIdx
.func getJiggleJointOverride(jointIdx: Int32
) -> Bool Returns a boolean that indicates whether the joint at
jointIdx
is overriding the default Jiggle joint data defined in the modification.func getJiggleJointStiffness(jointIdx: Int32
) -> Double Returns the stiffness of the Jiggle joint at
jointIdx
.func getJiggleJointUseGravity(jointIdx: Int32
) -> Bool Returns a boolean that indicates whether the joint at
jointIdx
is using gravity or not.func getUseColliders(
) -> Bool Returns whether the jiggle modifier is taking physics colliders into account when solving.
func setCollisionMask(Int32
) Sets the collision mask that the Jiggle modifier will use when reacting to colliders, if the Jiggle modifier is set to take colliders into account.
func setJiggleJointBone2dNode(jointIdx: Int32, bone2dNode: NodePath
) Sets the
Bone2D
node assigned to the Jiggle joint atjointIdx
.func setJiggleJointBoneIndex(jointIdx: Int32, boneIdx: Int32
) Sets the bone index,
boneIdx
, of the Jiggle joint atjointIdx
. When possible, this will also update thebone2d_node
of the Jiggle joint based on data provided by the linked skeleton.func setJiggleJointDamping(jointIdx: Int32, damping: Double
) Sets the amount of damping of the Jiggle joint at
jointIdx
.func setJiggleJointGravity(jointIdx: Int32, gravity: Vector2
) Sets the gravity vector of the Jiggle joint at
jointIdx
.func setJiggleJointMass(jointIdx: Int32, mass: Double
) Sets the of mass of the Jiggle joint at
jointIdx
.func setJiggleJointOverride(jointIdx: Int32, override: Bool
) Sets whether the Jiggle joint at
jointIdx
should override the default Jiggle joint settings. Setting this totrue
will make the joint use its own settings rather than the default ones attached to the modification.func setJiggleJointStiffness(jointIdx: Int32, stiffness: Double
) Sets the of stiffness of the Jiggle joint at
jointIdx
.func setJiggleJointUseGravity(jointIdx: Int32, useGravity: Bool
) Sets whether the Jiggle joint at
jointIdx
should use gravity.func setUseColliders(Bool
) If
true
, the Jiggle modifier will take colliders into account, keeping them from entering into these collision objects.