Class Bone2D
- Namespace
- Godot
- Assembly
- GodotSharp.dll
A hierarchy of Bone2Ds can be bound to a Skeleton2D to control and animate other Node2D nodes.
You can use Bone2D and Skeleton2D nodes to animate 2D meshes created with the Polygon2D UV editor.
Each bone has a Rest transform that you can reset to with ApplyRest(). These rest poses are relative to the bone's parent.
If in the editor, you can set the rest pose of an entire skeleton using a menu option, from the code, you need to iterate over the bones to set their individual rest poses.
public class Bone2D : Node2D, IDisposable
- Inheritance
-
Bone2D
- Implements
- Inherited Members
Constructors
Bone2D()
public Bone2D()
Properties
Rest
Rest transform of the bone. You can reset the node's transforms to this value using ApplyRest().
public Transform2D Rest { get; set; }
Property Value
Methods
ApplyRest()
public void ApplyRest()
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.
public bool GetAutocalculateLengthAndAngle()
Returns
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 Transform.
public float GetBoneAngle()
Returns
GetIndexInSkeleton()
Returns the node's index as part of the entire skeleton. See Skeleton2D.
public int GetIndexInSkeleton()
Returns
GetLength()
Returns the length of the bone in the Bone2D node.
public float GetLength()
Returns
GetSkeletonRest()
Returns the node's RestTransform2D if it doesn't have a parent, or its rest pose relative to its parent.
public Transform2D GetSkeletonRest()
Returns
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.
Returns
SetAutocalculateLengthAndAngle(bool)
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.
public void SetAutocalculateLengthAndAngle(bool autoCalculate)
Parameters
autoCalculate
bool
SetBoneAngle(float)
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 Transform.
public void SetBoneAngle(float angle)
Parameters
angle
float
SetLength(float)
Sets the length of the bone in the Bone2D.
public void SetLength(float length)
Parameters
length
float