Skeleton2D
Groups bones, their rest pose and 2D skeleton modifiers.
Skeleton2D registers direct Bone2D chains and supplies their poses for polygon skinning. Assign Polygon2D.Skeleton, bone paths and weights: the hierarchy alone does not produce deformation.
Call GetBoneCount() and GetBone() after the skeleton enters the tree. Bone indices belong to the current skeleton layout; do not use them as persistent save identifiers. A SkeletonModificationStack2D can run gameplay IK. This API is marked experimental; recheck behavior when changing engine versions.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
Skeleton2DConstructor
public Skeleton2D();Methods8
ExecuteModificationsvoid
public void ExecuteModifications(float delta, int executionMode);Executes all the modifications on the SkeletonModificationStack2D, if the Skeleton2D has one assigned.
| Name | Type | Default |
|---|---|---|
delta | float | — |
executionMode | int | — |
GetBoneBone2D
public Bone2D GetBone(int idx);Returns a bone by its current index. Requires the skeleton in the tree and an index from 0 to GetBoneCount() - 1; an error returns null. After changing a chain, update setup through GetBoneCount() first.
| Name | Type | Default |
|---|---|---|
idx | int | — |
Bone2DGetBoneCountint
public int GetBoneCount();Returns the registered bone count and updates pending bone setup when necessary. Requires the skeleton inside the tree; otherwise reports an error and returns 0. Use after AddChild() or in _Ready().
intGetBoneLocalPoseOverrideTransform2D
public Transform2D GetBoneLocalPoseOverride(int boneIdx);Returns the local pose override transform for bone_idx.
| Name | Type | Default |
|---|---|---|
boneIdx | int | — |
Transform2DGetModificationStackSkeletonModificationStack2D
public SkeletonModificationStack2D GetModificationStack();Returns the SkeletonModificationStack2D attached to this skeleton, if one exists.
SkeletonModificationStack2DGetSkeletonRid
public Rid GetSkeleton();Returns the Rid of a Skeleton2D instance.
RidSetBoneLocalPoseOverridevoid
public void SetBoneLocalPoseOverride(int boneIdx, Transform2D overridePose, float strength, bool persistent);Sets the local pose transform, override_pose, for the bone at bone_idx.
strength is the interpolation strength that will be used when applying the pose, and persistent determines if the applied pose will remain.
Note: The pose transform needs to be a local transform relative to the Bone2D node at bone_idx!
| Name | Type | Default |
|---|---|---|
boneIdx | int | — |
overridePose | Transform2D | — |
strength | float | — |
persistent | bool | — |
SetModificationStackvoid
public void SetModificationStack(SkeletonModificationStack2D modificationStack);Replaces the modification stack. If the skeleton is inside the tree, binds the new stack to it and runs setup. For IK, enable both the stack and modifier and assign valid paths and Strength. The 2D stack API remains experimental.
| Name | Type | Default |
|---|---|---|
modificationStack | SkeletonModificationStack2D | — |
Signals and events1
BoneSetupChangedEvent
public event Action BoneSetupChanged;Emitted when the Bone2D setup attached to this skeletons changes. This is primarily used internally within the skeleton.