SkeletonModification2D
Base class for resources that operate on Bone2D
s in a Skeleton2D
.
class SkeletonModification2D
This resource provides an interface that can be expanded so code that operates on Bone2D
nodes in a Skeleton2D
can be mixed and matched together to create complex interactions.
This is used to provide Godot with a flexible and powerful Inverse Kinematics solution that can be adapted for many different uses.
Superclasses
class Resource
Base class for serializable objects.
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 enabled: Bool
If
true
, the modification’s_execute(delta:)
function will be called by theSkeletonModificationStack2D
.var executionMode: Int32
The execution mode for the modification. This tells the modification stack when to execute the modification. Some modifications have settings that are only available in certain execution modes.
func clampAngle(Double, min: Double, max: Double, invert: Bool
) -> Double Takes an angle and clamps it so it is within the passed-in
min
andmax
range.invert
will inversely clamp the angle, clamping it to the range outside of the given bounds.func getEditorDrawGizmo(
) -> Bool Returns whether this modification will call
_drawEditorGizmo
in the Godot editor to draw modification-specific gizmos.func getIsSetup(
) -> Bool Returns whether this modification has been successfully setup or not.
func getModificationStack(
) -> SkeletonModificationStack2D? Returns the
SkeletonModificationStack2D
that this modification is bound to. Through the modification stack, you can access the Skeleton2D the modification is operating on.func setEditorDrawGizmo(Bool
) Sets whether this modification will call
_drawEditorGizmo
in the Godot editor to draw modification-specific gizmos.func setIsSetup(Bool
) Manually allows you to set the setup state of the modification. This function should only rarely be used, as the
SkeletonModificationStack2D
the modification is bound to should handle setting the modification up.
Show implementation details (3)
Hide implementation details
func _drawEditorGizmo(
) Used for drawing editor-only modification gizmos. This function will only be called in the Godot editor and can be overridden to draw custom gizmos.
func _execute(delta: Double
) Executes the given modification. This is where the modification performs whatever function it is designed to do.
func _setupModification(modificationStack: SkeletonModificationStack2D?
) Called when the modification is setup. This is where the modification performs initialization.
Subclasses
class SkeletonModification2DCCDIK
A modification that uses CCDIK to manipulate a series of bones to reach a target in 2D.
class SkeletonModification2DFABRIK
A modification that uses FABRIK to manipulate a series of
Bone2D
nodes to reach a target.class SkeletonModification2DJiggle
A modification that jiggles
Bone2D
nodes as they move towards a target.class SkeletonModification2DLookAt
A modification that rotates a
Bone2D
node to look at a target.class SkeletonModification2DPhysicalBones
A modification that applies the transforms of
PhysicalBone2D
nodes toBone2D
nodes.class SkeletonModification2DStackHolder
A modification that holds and executes a
SkeletonModificationStack2D
.class SkeletonModification2DTwoBoneIK
A modification that rotates two bones using the law of cosines to reach the target.