Bone2D
A bone in a 2D skeleton hierarchy.
Bone2D defines a joint transform and its saved local Rest pose. Its parent must be another Bone2D or Skeleton2D: an intermediate Entity2D breaks bone registration.
Child images can move as rigid parts. Deforming one Polygon2D also requires vertex weights and a skeleton assignment. SetLength() alone does not stretch an image or polygon.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
Bone2DConstructor
public Bone2D();Properties1
RestProperty
public Transform2D Rest { get; set; }The saved transform relative to the parent bone or Skeleton2D, not a world pose. Assignment changes the skinning rest pose; call ApplyRest() to move the current bone to it.
Methods11
ApplyRestvoid
public void ApplyRest();Copies Rest into this bone's local Transform. It does not traverse child bones or disable animation or IK; another pose writer can overwrite the result.
GetAutocalculateLengthAndAnglebool
public bool GetAutocalculateLengthAndAngle();Returns whether this Bone2D is going to autocalculate its length and bone angle using its first Bone2D child node, if one exists. If there are no Bone2D children, then it cannot autocalculate these values and will print a warning.
boolGetBoneAnglefloat
public float GetBoneAngle();Returns the angle of the bone in the Bone2D.
Note: This is different from the Bone2D's rotation. The bone's angle is the rotation of the bone shown by the gizmo, which is unaffected by the Bone2D's Entity2D.Transform.
floatGetIndexInSkeletonint
public int GetIndexInSkeleton();Returns the index in the current skeleton after updating bone setup. Without a registered Skeleton2D it reports an error and returns -1. The index can change when the hierarchy is rebuilt.
intGetLengthfloat
public float GetLength();Returns the length of the bone in the Bone2D node.
floatGetRestTransform2D
public Transform2D GetRest();Transform2DGetSkeletonRestTransform2D
public Transform2D GetSkeletonRest();Returns the rest transform in skeleton coordinates by multiplying local Rest transforms along the parent-bone chain. It is not the current animated GlobalTransform.
Transform2DSetAutocalculateLengthAndAnglevoid
public void SetAutocalculateLengthAndAngle(bool autoCalculate);When set to true, the Bone2D node will attempt to automatically calculate the bone angle and length using the first child Bone2D node, if one exists. If none exist, the Bone2D cannot automatically calculate these values and will print a warning.
| Name | Type | Default |
|---|---|---|
autoCalculate | bool | — |
SetBoneAnglevoid
public void SetBoneAngle(float angle);Sets the bone angle for the Bone2D. This is typically set to the rotation from the Bone2D to a child Bone2D node.
Note: This is different from the Bone2D's rotation. The bone's angle is the rotation of the bone shown by the gizmo, which is unaffected by the Bone2D's Entity2D.Transform.
| Name | Type | Default |
|---|---|---|
angle | float | — |
SetLengthvoid
public void SetLength(float length);Sets the length used by the bone representation and solvers. Disable automatic calculation with SetAutocalculateLengthAndAngle(false) for manual control. Length alone neither changes Polygon2D vertices nor stretches a child sprite.
| Name | Type | Default |
|---|---|---|
length | float | — |
SetRestvoid
public void SetRest(Transform2D rest);| Name | Type | Default |
|---|---|---|
rest | Transform2D | — |