SkeletonModification2DCCDIK
A modification that uses CCDIK to manipulate a series of bones to reach a target in 2D.
SkeletonModification2DCCDIK.swift:18class SkeletonModification2DCCDIK
This SkeletonModification2D
uses an algorithm called Cyclic Coordinate Descent Inverse Kinematics, or CCDIK, to manipulate a chain of bones in a Skeleton2D
so it reaches a defined target.
CCDIK works by rotating a set of bones, typically called a “bone chain”, on a single axis. Each bone is rotated to face the target from the tip (by default), which over a chain of bones allow it to rotate properly to reach the target. Because the bones only rotate on a single axis, CCDIK can look more robotic than other IK solvers.
CCDIK also fully supports angle constraints, allowing for more control over how a solution is met.
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 ccdikDataChainLength: Int32
The number of CCDIK joints in the CCDIK modification.
var targetNodepath: NodePath
The NodePath to the node that is the target for the CCDIK modification. This node is what the CCDIK chain will attempt to rotate the bone chain to.
var tipNodepath: NodePath
The end position of the CCDIK chain. Typically, this should be a child of a
Bone2D
node attached to the finalBone2D
in the CCDIK chain.func getCcdikJointBone2dNode(jointIdx: Int32
) -> NodePath Returns the
Bone2D
node assigned to the CCDIK joint atjointIdx
.func getCcdikJointBoneIndex(jointIdx: Int32
) -> Int32 Returns the index of the
Bone2D
node assigned to the CCDIK joint atjointIdx
.func getCcdikJointConstraintAngleInvert(jointIdx: Int32
) -> Bool Returns whether the CCDIK joint at
jointIdx
uses an inverted joint constraint. SeesetCcdikJointConstraintAngleInvert(jointIdx:invert:)
for details.func getCcdikJointConstraintAngleMax(jointIdx: Int32
) -> Double Returns the maximum angle constraint for the joint at
jointIdx
.func getCcdikJointConstraintAngleMin(jointIdx: Int32
) -> Double Returns the minimum angle constraint for the joint at
jointIdx
.func getCcdikJointEnableConstraint(jointIdx: Int32
) -> Bool Returns whether angle constraints on the CCDIK joint at
jointIdx
are enabled.func getCcdikJointRotateFromJoint(jointIdx: Int32
) -> Bool Returns whether the joint at
jointIdx
is set to rotate from the joint,true
, or to rotate from the tip,false
. The default is to rotate from the tip.func setCcdikJointBone2dNode(jointIdx: Int32, bone2dNodepath: NodePath
) Sets the
Bone2D
node assigned to the CCDIK joint atjointIdx
.func setCcdikJointBoneIndex(jointIdx: Int32, boneIdx: Int32
) Sets the bone index,
boneIdx
, of the CCDIK joint atjointIdx
. When possible, this will also update thebone2d_node
of the CCDIK joint based on data provided by the linked skeleton.func setCcdikJointConstraintAngleInvert(jointIdx: Int32, invert: Bool
) Sets whether the CCDIK joint at
jointIdx
uses an inverted joint constraint.func setCcdikJointConstraintAngleMax(jointIdx: Int32, angleMax: Double
) Sets the maximum angle constraint for the joint at
jointIdx
.func setCcdikJointConstraintAngleMin(jointIdx: Int32, angleMin: Double
) Sets the minimum angle constraint for the joint at
jointIdx
.func setCcdikJointEnableConstraint(jointIdx: Int32, enableConstraint: Bool
) Determines whether angle constraints on the CCDIK joint at
jointIdx
are enabled. Whentrue
, constraints will be enabled and taken into account when solving.func setCcdikJointRotateFromJoint(jointIdx: Int32, rotateFromJoint: Bool
) Sets whether the joint at
jointIdx
is set to rotate from the joint,true
, or to rotate from the tip,false
.