Table of Contents

Class Skeleton3D

Namespace
Godot
Assembly
GodotSharp.dll

Skeleton3D provides an interface for managing a hierarchy of bones, including pose, rest and animation (see Animation). It can also use ragdoll physics.

The overall transform of a bone with respect to the skeleton is determined by bone pose. Bone rest defines the initial transform of the bone pose.

Note that "global pose" below refers to the overall transform of the bone with respect to skeleton, so it is not the actual global/world transform of the bone.

public class Skeleton3D : Node3D, IDisposable
Inheritance
Skeleton3D
Implements
Inherited Members

Constructors

Skeleton3D()

public Skeleton3D()

Fields

NotificationUpdateSkeleton

Notification received when this skeleton's pose needs to be updated.

This notification is received before the related PoseUpdated signal.

public const long NotificationUpdateSkeleton = 50

Field Value

long

Properties

AnimatePhysicalBones

public bool AnimatePhysicalBones { get; set; }

Property Value

bool

MotionScale

Multiplies the 3D position track animation.

Note: Unless this value is 1.0, the key value in animation will not match the actual position value.

public float MotionScale { get; set; }

Property Value

float

ShowRestOnly

If true, forces the bones in their default rest pose, regardless of their values. In the editor, this also prevents the bones from being edited.

public bool ShowRestOnly { get; set; }

Property Value

bool

Methods

AddBone(string)

Adds a bone, with name name. GetBoneCount() will become the bone index.

public void AddBone(string name)

Parameters

name string

ClearBones()

Clear all the bones in this skeleton.

public void ClearBones()

ClearBonesGlobalPoseOverride()

Removes the global pose override on all bones in the skeleton.

public void ClearBonesGlobalPoseOverride()

CreateSkinFromRestTransforms()

public Skin CreateSkinFromRestTransforms()

Returns

Skin

FindBone(string)

Returns the bone index that matches name as its name.

public int FindBone(string name)

Parameters

name string

Returns

int

ForceUpdateAllBoneTransforms()

Force updates the bone transforms/poses for all bones in the skeleton.

Deprecated. Do not use.

[Obsolete("This method is deprecated.")]
public void ForceUpdateAllBoneTransforms()

ForceUpdateBoneChildTransform(int)

Force updates the bone transform for the bone at boneIdx and all of its children.

public void ForceUpdateBoneChildTransform(int boneIdx)

Parameters

boneIdx int

GetBoneChildren(int)

Returns an array containing the bone indexes of all the child node of the passed in bone, boneIdx.

public int[] GetBoneChildren(int boneIdx)

Parameters

boneIdx int

Returns

int[]

GetBoneCount()

Returns the number of bones in the skeleton.

public int GetBoneCount()

Returns

int

GetBoneGlobalPose(int)

Returns the overall transform of the specified bone, with respect to the skeleton. Being relative to the skeleton frame, this is not the actual "global" transform of the bone.

public Transform3D GetBoneGlobalPose(int boneIdx)

Parameters

boneIdx int

Returns

Transform3D

GetBoneGlobalPoseNoOverride(int)

Returns the overall transform of the specified bone, with respect to the skeleton, but without any global pose overrides. Being relative to the skeleton frame, this is not the actual "global" transform of the bone.

public Transform3D GetBoneGlobalPoseNoOverride(int boneIdx)

Parameters

boneIdx int

Returns

Transform3D

GetBoneGlobalPoseOverride(int)

Returns the global pose override transform for boneIdx.

public Transform3D GetBoneGlobalPoseOverride(int boneIdx)

Parameters

boneIdx int

Returns

Transform3D

GetBoneGlobalRest(int)

Returns the global rest transform for boneIdx.

public Transform3D GetBoneGlobalRest(int boneIdx)

Parameters

boneIdx int

Returns

Transform3D

GetBoneName(int)

Returns the name of the bone at index boneIdx.

public string GetBoneName(int boneIdx)

Parameters

boneIdx int

Returns

string

GetBoneParent(int)

Returns the bone index which is the parent of the bone at boneIdx. If -1, then bone has no parent.

Note: The parent bone returned will always be less than boneIdx.

public int GetBoneParent(int boneIdx)

Parameters

boneIdx int

Returns

int

GetBonePose(int)

Returns the pose transform of the specified bone.

public Transform3D GetBonePose(int boneIdx)

Parameters

boneIdx int

Returns

Transform3D

GetBonePosePosition(int)

Returns the pose position of the bone at boneIdx. The returned Vector3 is in the local coordinate space of the Skeleton3D node.

public Vector3 GetBonePosePosition(int boneIdx)

Parameters

boneIdx int

Returns

Vector3

GetBonePoseRotation(int)

Returns the pose rotation of the bone at boneIdx. The returned Quaternion is local to the bone with respect to the rotation of any parent bones.

public Quaternion GetBonePoseRotation(int boneIdx)

Parameters

boneIdx int

Returns

Quaternion

GetBonePoseScale(int)

Returns the pose scale of the bone at boneIdx.

public Vector3 GetBonePoseScale(int boneIdx)

Parameters

boneIdx int

Returns

Vector3

GetBoneRest(int)

Returns the rest transform for a bone boneIdx.

public Transform3D GetBoneRest(int boneIdx)

Parameters

boneIdx int

Returns

Transform3D

GetParentlessBones()

Returns an array with all of the bones that are parentless. Another way to look at this is that it returns the indexes of all the bones that are not dependent or modified by other bones in the Skeleton.

public int[] GetParentlessBones()

Returns

int[]

GetVersion()

Returns the number of times the bone hierarchy has changed within this skeleton, including renames.

The Skeleton version is not serialized: only use within a single instance of Skeleton3D.

Use for invalidating caches in IK solvers and other nodes which process bones.

public ulong GetVersion()

Returns

ulong

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_name

Name of the method to check for.

Returns

bool

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_name

Name of the signal to check for.

Returns

bool

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_name

Name of the method to invoke.

args NativeVariantPtrArgs

Arguments to use with the invoked method.

ret godot_variant

Value returned by the invoked method.

Returns

bool

IsBoneEnabled(int)

Returns whether the bone pose for the bone at boneIdx is enabled.

public bool IsBoneEnabled(int boneIdx)

Parameters

boneIdx int

Returns

bool

LocalizeRests()

Returns all bones in the skeleton to their rest poses.

public void LocalizeRests()

PhysicalBonesAddCollisionException(Rid)

Adds a collision exception to the physical bone.

Works just like the RigidBody3D node.

public void PhysicalBonesAddCollisionException(Rid exception)

Parameters

exception Rid

PhysicalBonesRemoveCollisionException(Rid)

Removes a collision exception to the physical bone.

Works just like the RigidBody3D node.

public void PhysicalBonesRemoveCollisionException(Rid exception)

Parameters

exception Rid

PhysicalBonesStartSimulation(Array<StringName>)

Tells the PhysicalBone3D nodes in the Skeleton to start simulating and reacting to the physics world.

Optionally, a list of bone names can be passed-in, allowing only the passed-in bones to be simulated.

public void PhysicalBonesStartSimulation(Array<StringName> bones = null)

Parameters

bones Array<StringName>

PhysicalBonesStopSimulation()

Tells the PhysicalBone3D nodes in the Skeleton to stop simulating.

public void PhysicalBonesStopSimulation()

RegisterSkin(Skin)

Binds the given Skin to the Skeleton.

public SkinReference RegisterSkin(Skin skin)

Parameters

skin Skin

Returns

SkinReference

ResetBonePose(int)

Sets the bone pose to rest for boneIdx.

public void ResetBonePose(int boneIdx)

Parameters

boneIdx int

ResetBonePoses()

Sets all bone poses to rests.

public void ResetBonePoses()

SetBoneEnabled(int, bool)

Disables the pose for the bone at boneIdx if false, enables the bone pose if true.

public void SetBoneEnabled(int boneIdx, bool enabled = true)

Parameters

boneIdx int
enabled bool

SetBoneGlobalPoseOverride(int, Transform3D, float, bool)

Sets the global pose transform, pose, for the bone at boneIdx.

amount 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 global pose! To convert a world transform from a Node3D to a global bone pose, multiply the Transform3D.affine_inverse of the node's GlobalTransform by the desired world transform.

public void SetBoneGlobalPoseOverride(int boneIdx, Transform3D pose, float amount, bool persistent = false)

Parameters

boneIdx int
pose Transform3D
amount float
persistent bool

SetBoneName(int, string)

public void SetBoneName(int boneIdx, string name)

Parameters

boneIdx int
name string

SetBoneParent(int, int)

Sets the bone index parentIdx as the parent of the bone at boneIdx. If -1, then bone has no parent.

Note: parentIdx must be less than boneIdx.

public void SetBoneParent(int boneIdx, int parentIdx)

Parameters

boneIdx int
parentIdx int

SetBonePosePosition(int, Vector3)

Sets the pose position of the bone at boneIdx to position. position is a Vector3 describing a position local to the Skeleton3D node.

public void SetBonePosePosition(int boneIdx, Vector3 position)

Parameters

boneIdx int
position Vector3

SetBonePoseRotation(int, Quaternion)

Sets the pose rotation of the bone at boneIdx to rotation. rotation is a Quaternion describing a rotation in the bone's local coordinate space with respect to the rotation of any parent bones.

public void SetBonePoseRotation(int boneIdx, Quaternion rotation)

Parameters

boneIdx int
rotation Quaternion

SetBonePoseScale(int, Vector3)

Sets the pose scale of the bone at boneIdx to scale.

public void SetBonePoseScale(int boneIdx, Vector3 scale)

Parameters

boneIdx int
scale Vector3

SetBoneRest(int, Transform3D)

Sets the rest transform for bone boneIdx.

public void SetBoneRest(int boneIdx, Transform3D rest)

Parameters

boneIdx int
rest Transform3D

UnparentBoneAndRest(int)

Unparents the bone at boneIdx and sets its rest position to that of its parent prior to being reset.

public void UnparentBoneAndRest(int boneIdx)

Parameters

boneIdx int

Events

BoneEnabledChanged

Emitted when the bone at boneIdx is toggled with SetBoneEnabled(int, bool). Use IsBoneEnabled(int) to check the new value.

public event Skeleton3D.BoneEnabledChangedEventHandler BoneEnabledChanged

Event Type

Skeleton3D.BoneEnabledChangedEventHandler

BonePoseChanged

This signal is emitted when one of the bones in the Skeleton3D node have changed their pose. This is used to inform nodes that rely on bone positions that one of the bones in the Skeleton3D have changed their transform/pose.

public event Skeleton3D.BonePoseChangedEventHandler BonePoseChanged

Event Type

Skeleton3D.BonePoseChangedEventHandler

PoseUpdated

Emitted when the pose is updated, after NotificationUpdateSkeleton is received.

public event Action PoseUpdated

Event Type

Action

ShowRestOnlyChanged

Emitted when the value of ShowRestOnly changes.

public event Action ShowRestOnlyChanged

Event Type

Action