SkeletonModification2DTwoBoneIK
A modification that rotates two bones using the law of cosines to reach the target.
A modification that rotates two bones using the law of cosines to reach the target.
This SkeletonModification2D uses an algorithm typically called TwoBoneIK. This algorithm works by leveraging the law of cosines and the lengths of the bones to figure out what rotation the bones currently have, and what rotation they need to make a complete triangle, where the first bone, the second bone, and the target form the three vertices of the triangle. Because the algorithm works by making a triangle, it can only operate on two bones.
TwoBoneIK is great for arms, legs, and really any joints that can be represented by just two bones that bend to reach a target. This solver is more lightweight than SkeletonModification2DFabrik, but gives similar, natural looking results.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
SkeletonModification2DTwoBoneIKConstructor
public SkeletonModification2DTwoBoneIK();Properties4
FlipBendDirectionProperty
public bool FlipBendDirection { get; set; }If true, the bones in the modification will bend outward as opposed to inwards when contracting. If false, the bones will bend inwards when contracting.
TargetEntitypathProperty
public EntityPath TargetEntitypath { get; set; }The EntityPath to the node that is the target for the TwoBoneIK modification. This node is what the modification will use when bending the Bone2D nodes.
TargetMaximumDistanceProperty
public float TargetMaximumDistance { get; set; }The maximum distance the target can be at. If the target is farther than this distance, the modification will solve as if it's at this maximum distance. When set to 0, the modification will solve without distance constraints.
TargetMinimumDistanceProperty
public float TargetMinimumDistance { get; set; }The minimum distance the target can be at. If the target is closer than this distance, the modification will solve as if it's at this minimum distance. When set to 0, the modification will solve without distance constraints.
Methods16
GetFlipBendDirectionbool
public bool GetFlipBendDirection();boolGetJointOneBone2DEntityEntityPath
public EntityPath GetJointOneBone2DEntity();Returns the Bone2D node that is being used as the first bone in the TwoBoneIK modification.
EntityPathGetJointOneBoneIdxint
public int GetJointOneBoneIdx();Returns the index of the Bone2D node that is being used as the first bone in the TwoBoneIK modification.
intGetJointTwoBone2DEntityEntityPath
public EntityPath GetJointTwoBone2DEntity();Returns the Bone2D node that is being used as the second bone in the TwoBoneIK modification.
EntityPathGetJointTwoBoneIdxint
public int GetJointTwoBoneIdx();Returns the index of the Bone2D node that is being used as the second bone in the TwoBoneIK modification.
intGetTargetEntityEntityPath
public EntityPath GetTargetEntity();EntityPathGetTargetMaximumDistancefloat
public float GetTargetMaximumDistance();floatGetTargetMinimumDistancefloat
public float GetTargetMinimumDistance();floatSetFlipBendDirectionvoid
public void SetFlipBendDirection(bool flipDirection);| Name | Type | Default |
|---|---|---|
flipDirection | bool | — |
SetJointOneBone2DEntityvoid
public void SetJointOneBone2DEntity(EntityPath bone2DEntity);Sets the Bone2D node that is being used as the first bone in the TwoBoneIK modification.
| Name | Type | Default |
|---|---|---|
bone2DEntity | EntityPath | — |
SetJointOneBoneIdxvoid
public void SetJointOneBoneIdx(int boneIdx);Sets the index of the Bone2D node that is being used as the first bone in the TwoBoneIK modification.
| Name | Type | Default |
|---|---|---|
boneIdx | int | — |
SetJointTwoBone2DEntityvoid
public void SetJointTwoBone2DEntity(EntityPath bone2DEntity);Sets the Bone2D node that is being used as the second bone in the TwoBoneIK modification.
| Name | Type | Default |
|---|---|---|
bone2DEntity | EntityPath | — |
SetJointTwoBoneIdxvoid
public void SetJointTwoBoneIdx(int boneIdx);Sets the index of the Bone2D node that is being used as the second bone in the TwoBoneIK modification.
| Name | Type | Default |
|---|---|---|
boneIdx | int | — |
SetTargetEntityvoid
public void SetTargetEntity(EntityPath targetEntitypath);| Name | Type | Default |
|---|---|---|
targetEntitypath | EntityPath | — |
SetTargetMaximumDistancevoid
public void SetTargetMaximumDistance(float maximumDistance);| Name | Type | Default |
|---|---|---|
maximumDistance | float | — |
SetTargetMinimumDistancevoid
public void SetTargetMinimumDistance(float minimumDistance);| Name | Type | Default |
|---|---|---|
minimumDistance | float | — |