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. In that case, this is called only once per frame in a deferred process.

public const long NotificationUpdateSkeleton = 50

Field Value

long

Properties

AnimatePhysicalBones

If you follow the recommended workflow and explicitly have PhysicalBoneSimulator3D as a child of Skeleton3D, you can control whether it is affected by raycasting without running PhysicalBonesStartSimulation(Array<StringName>), by its Active.

However, for old (deprecated) configurations, Skeleton3D has an internal virtual PhysicalBoneSimulator3D for compatibility. This property controls the internal virtual PhysicalBoneSimulator3D's Active.

[Obsolete("This property is deprecated.")]
public bool AnimatePhysicalBones { get; set; }

Property Value

bool

ModifierCallbackModeProcess

Sets the processing timing for the Modifier.

public Skeleton3D.ModifierCallbackModeProcessEnum ModifierCallbackModeProcess { get; set; }

Property Value

Skeleton3D.ModifierCallbackModeProcessEnum

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 new bone with the given name. Returns the new bone's index, or -1 if this method fails.

Note: Bone names should be unique, non empty, and cannot include the : and / characters.

public int AddBone(string name)

Parameters

name string

Returns

int

ClearBones()

Clear all the bones in this skeleton.

public void ClearBones()

ClearBonesGlobalPoseOverride()

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

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

CreateSkinFromRestTransforms()

public Skin CreateSkinFromRestTransforms()

Returns

Skin

FindBone(string)

Returns the bone index that matches name as its name. Returns -1 if no bone with this name exists.

public int FindBone(string name)

Parameters

name string

Returns

int

ForceUpdateAllBoneTransforms()

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

[Obsolete("This method should only be called internally.")]
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.

Note: This is the global pose you set to the skeleton in the process, the final global pose can get overridden by modifiers in the deferred process, if you want to access the final global pose, use ModificationProcessed.

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.

[Obsolete("This method is deprecated.")]
public Transform3D GetBoneGlobalPoseNoOverride(int boneIdx)

Parameters

boneIdx int

Returns

Transform3D

GetBoneGlobalPoseOverride(int)

Returns the global pose override transform for boneIdx.

[Obsolete("This method is deprecated.")]
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.

Note: This is the pose you set to the skeleton in the process, the final pose can get overridden by modifiers in the deferred process, if you want to access the final pose, use ModificationProcessed.

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

GetConcatenatedBoneNames()

Returns all bone names concatenated with commas (,) as a single StringName.

It is useful to set it as a hint for the enum property.

public StringName GetConcatenatedBoneNames()

Returns

StringName

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.

[Obsolete("This method is deprecated.")]
public void PhysicalBonesAddCollisionException(Rid exception)

Parameters

exception Rid

PhysicalBonesRemoveCollisionException(Rid)

Removes a collision exception to the physical bone.

Works just like the RigidBody3D node.

[Obsolete("This method is deprecated.")]
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.

[Obsolete("This method is deprecated.")]
public void PhysicalBonesStartSimulation(Array<StringName> bones = null)

Parameters

bones Array<StringName>

PhysicalBonesStopSimulation()

Tells the PhysicalBone3D nodes in the Skeleton to stop simulating.

[Obsolete("This method is deprecated.")]
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

SetBoneGlobalPose(int, Transform3D)

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

Note: If other bone poses have been changed, this method executes a dirty poses recalculation and will cause performance to deteriorate. If you know that multiple global poses will be applied, consider using SetBonePose(int, Transform3D) with precalculation.

public void SetBoneGlobalPose(int boneIdx, Transform3D pose)

Parameters

boneIdx int
pose Transform3D

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.

[Obsolete("This method is deprecated.")]
public void SetBoneGlobalPoseOverride(int boneIdx, Transform3D pose, float amount, bool persistent = false)

Parameters

boneIdx int
pose Transform3D
amount float
persistent bool

SetBoneName(int, string)

Sets the bone name, name, for the bone at boneIdx.

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

SetBonePose(int, Transform3D)

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

public void SetBonePose(int boneIdx, Transform3D pose)

Parameters

boneIdx int
pose Transform3D

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

BoneListChanged

public event Action BoneListChanged

Event Type

Action

PoseUpdated

Emitted when the pose is updated.

Note: During the update process, this signal is not fired, so modification by SkeletonModifier3D is not detected.

public event Action PoseUpdated

Event Type

Action

ShowRestOnlyChanged

Emitted when the value of ShowRestOnly changes.

public event Action ShowRestOnlyChanged

Event Type

Action

SkeletonUpdated

Emitted when the final pose has been calculated will be applied to the skin in the update process.

This means that all SkeletonModifier3D processing is complete. In order to detect the completion of the processing of each SkeletonModifier3D, use ModificationProcessed.

public event Action SkeletonUpdated

Event Type

Action