Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

Skeleton3D

繼承: Node3D < Node < Object

包含骨骼層級結構的節點,用於建立 3D 骨骼動畫。

說明

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.

教學

屬性

bool

animate_physical_bones

true

ModifierCallbackModeProcess

modifier_callback_mode_process

1

float

motion_scale

1.0

bool

show_rest_only

false

方法

int

add_bone(name: String)

void

advance(delta: float)

void

clear_bones()

void

clear_bones_global_pose_override()

Skin

create_skin_from_rest_transforms()

int

find_bone(name: String) const

void

force_update_all_bone_transforms()

void

force_update_bone_child_transform(bone_idx: int)

PackedInt32Array

get_bone_children(bone_idx: int) const

int

get_bone_count() const

Transform3D

get_bone_global_pose(bone_idx: int) const

Transform3D

get_bone_global_pose_no_override(bone_idx: int) const

Transform3D

get_bone_global_pose_override(bone_idx: int) const

Transform3D

get_bone_global_rest(bone_idx: int) const

Variant

get_bone_meta(bone_idx: int, key: StringName) const

Array[StringName]

get_bone_meta_list(bone_idx: int) const

String

get_bone_name(bone_idx: int) const

int

get_bone_parent(bone_idx: int) const

Transform3D

get_bone_pose(bone_idx: int) const

Vector3

get_bone_pose_position(bone_idx: int) const

Quaternion

get_bone_pose_rotation(bone_idx: int) const

Vector3

get_bone_pose_scale(bone_idx: int) const

Transform3D

get_bone_rest(bone_idx: int) const

StringName

get_concatenated_bone_names() const

PackedInt32Array

get_parentless_bones() const

int

get_version() const

bool

has_bone_meta(bone_idx: int, key: StringName) const

bool

is_bone_enabled(bone_idx: int) const

void

localize_rests()

void

physical_bones_add_collision_exception(exception: RID)

void

physical_bones_remove_collision_exception(exception: RID)

void

physical_bones_start_simulation(bones: Array[StringName] = [])

void

physical_bones_stop_simulation()

SkinReference

register_skin(skin: Skin)

void

reset_bone_pose(bone_idx: int)

void

reset_bone_poses()

void

set_bone_enabled(bone_idx: int, enabled: bool = true)

void

set_bone_global_pose(bone_idx: int, pose: Transform3D)

void

set_bone_global_pose_override(bone_idx: int, pose: Transform3D, amount: float, persistent: bool = false)

void

set_bone_meta(bone_idx: int, key: StringName, value: Variant)

void

set_bone_name(bone_idx: int, name: String)

void

set_bone_parent(bone_idx: int, parent_idx: int)

void

set_bone_pose(bone_idx: int, pose: Transform3D)

void

set_bone_pose_position(bone_idx: int, position: Vector3)

void

set_bone_pose_rotation(bone_idx: int, rotation: Quaternion)

void

set_bone_pose_scale(bone_idx: int, scale: Vector3)

void

set_bone_rest(bone_idx: int, rest: Transform3D)

void

unparent_bone_and_rest(bone_idx: int)


訊號

bone_enabled_changed(bone_idx: int) 🔗

Emitted when the bone at bone_idx is toggled with set_bone_enabled(). Use is_bone_enabled() to check the new value.


bone_list_changed() 🔗

Emitted when the list of bones changes, such as when calling add_bone(), set_bone_parent(), unparent_bone_and_rest(), or clear_bones().


pose_updated() 🔗

Emitted when the pose is updated.

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


rest_updated() 🔗

Emitted when the rest is updated.


show_rest_only_changed() 🔗

Emitted when the value of show_rest_only changes.


skeleton_updated() 🔗

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 SkeletonModifier3D.modification_processed.


列舉

enum ModifierCallbackModeProcess: 🔗

ModifierCallbackModeProcess MODIFIER_CALLBACK_MODE_PROCESS_PHYSICS = 0

Set a flag to process modification during physics frames (see Node.NOTIFICATION_INTERNAL_PHYSICS_PROCESS).

ModifierCallbackModeProcess MODIFIER_CALLBACK_MODE_PROCESS_IDLE = 1

Set a flag to process modification during process frames (see Node.NOTIFICATION_INTERNAL_PROCESS).

ModifierCallbackModeProcess MODIFIER_CALLBACK_MODE_PROCESS_MANUAL = 2

Do not process modification. Use advance() to process the modification manually.


常數

NOTIFICATION_UPDATE_SKELETON = 50 🔗

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.


屬性說明

bool animate_physical_bones = true 🔗

  • void set_animate_physical_bones(value: bool)

  • bool get_animate_physical_bones()

已棄用: 此屬性可能在未來版本中變更或移除。

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 physical_bones_start_simulation(), by its SkeletonModifier3D.active.

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


ModifierCallbackModeProcess modifier_callback_mode_process = 1 🔗

Sets the processing timing for the Modifier.


float motion_scale = 1.0 🔗

  • void set_motion_scale(value: float)

  • float get_motion_scale()

與 3D 位置軌道動畫相乘。

注意:除非這個值是 1.0,否則動畫中的鍵值將與實際位置值不配對。


bool show_rest_only = false 🔗

  • void set_show_rest_only(value: bool)

  • bool is_show_rest_only()

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.


方法說明

int add_bone(name: 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.


void advance(delta: float) 🔗

Manually advance the child SkeletonModifier3Ds by the specified time (in seconds).

Note: The delta is temporarily accumulated in the Skeleton3D, and the deferred process uses the accumulated value to process the modification.


void clear_bones() 🔗

清除這個骨架上的所有骨骼。


void clear_bones_global_pose_override() 🔗

已棄用: 此方法可能在未來版本中變更或移除。

移除骨架中所有骨骼上的全域姿勢覆蓋。


Skin create_skin_from_rest_transforms() 🔗

There is currently no description for this method. Please help us by contributing one!


int find_bone(name: String) const 🔗

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


void force_update_all_bone_transforms() 🔗

已棄用: This method should only be called internally.

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


void force_update_bone_child_transform(bone_idx: int) 🔗

強制更新索引為 bone_idx 的骨骼及其所有子項的變換/姿勢。


PackedInt32Array get_bone_children(bone_idx: int) const 🔗

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


int get_bone_count() const 🔗

返回骨架中骨骼的數量。


Transform3D get_bone_global_pose(bone_idx: int) const 🔗

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 SkeletonModifier3D.modification_processed.


Transform3D get_bone_global_pose_no_override(bone_idx: int) const 🔗

已棄用: 此方法可能在未來版本中變更或移除。

返回指定骨骼的整體變換,相對於骨架,不包含任何全域姿勢覆蓋。由於是相對於骨架的,這不是該骨骼的實際“全域”變換。


Transform3D get_bone_global_pose_override(bone_idx: int) const 🔗

已棄用: 此方法可能在未來版本中變更或移除。

返回 bone_idx 骨骼的全域姿勢覆蓋變換。


Transform3D get_bone_global_rest(bone_idx: int) const 🔗

返回 bone_idx 骨骼的全域放鬆變換。


Variant get_bone_meta(bone_idx: int, key: StringName) const 🔗

Returns the metadata with the given key for the bone at index bone_idx.


Array[StringName] get_bone_meta_list(bone_idx: int) const 🔗

Returns the list of all metadata keys for the bone at index bone_idx.


String get_bone_name(bone_idx: int) const 🔗

返回索引為 bone_idx 的骨骼的名稱。


int get_bone_parent(bone_idx: int) const 🔗

返回 bone_idx 處的骨骼的父級骨骼索引。如果為 -1,則該骨骼沒有父級。

注意:返回的父骨骼索引總是小於 bone_idx


Transform3D get_bone_pose(bone_idx: int) const 🔗

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 SkeletonModifier3D.modification_processed.


Vector3 get_bone_pose_position(bone_idx: int) const 🔗

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


Quaternion get_bone_pose_rotation(bone_idx: int) const 🔗

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


Vector3 get_bone_pose_scale(bone_idx: int) const 🔗

Returns the pose scale of the bone at bone_idx.


Transform3D get_bone_rest(bone_idx: int) const 🔗

返回骨骼 bone_idx 的放鬆變換。


StringName get_concatenated_bone_names() const 🔗

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

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


PackedInt32Array get_parentless_bones() const 🔗

返回一個包含所有無父級的骨骼的陣列。另一種看待這一點的方法是,它返回所有骨骼的索引,這些骨骼不依賴於該骨架中的其他骨骼,或不被該骨架中的其他骨骼修改。


int get_version() const 🔗

返回骨骼層次結構在該骨架中更改的次數,包括重命名。

骨架版本沒有被序列化:只能在 Skeleton3D 的單個實例中使用。

用於使 IK 解算器中的和處理骨骼的其他節點中的快取失效。


bool has_bone_meta(bone_idx: int, key: StringName) const 🔗

Returns true if the bone at index bone_idx has metadata with the given key.


bool is_bone_enabled(bone_idx: int) const 🔗

返回位於 bone_idx 的骨骼是否啟用了骨骼姿勢。


void localize_rests() 🔗

將骨架中的所有骨骼都恢復到放鬆姿勢。


void physical_bones_add_collision_exception(exception: RID) 🔗

已棄用: 此方法可能在未來版本中變更或移除。

向物理骨骼新增一個碰撞例外。

就像 RigidBody3D 節點一樣工作。


void physical_bones_remove_collision_exception(exception: RID) 🔗

已棄用: 此方法可能在未來版本中變更或移除。

移除物理骨骼的一個碰撞例外。

就像 RigidBody3D 節點一樣工作。


void physical_bones_start_simulation(bones: Array[StringName] = []) 🔗

已棄用: 此方法可能在未來版本中變更或移除。

讓 Skeleton 中的 PhysicalBone3D 節點開始模擬類比,對物理世界做出反應。

可以傳入骨骼名稱列表,只對傳入的骨骼進行模擬模擬。


void physical_bones_stop_simulation() 🔗

已棄用: 此方法可能在未來版本中變更或移除。

讓 Skeleton 中的 PhysicalBone3D 節點停止模擬模擬。


SkinReference register_skin(skin: Skin) 🔗

將給定的 Skin 綁定到 Skeleton。


void reset_bone_pose(bone_idx: int) 🔗

bone_idx 骨骼設定為放鬆姿勢。


void reset_bone_poses() 🔗

將所有骨骼都設定為放鬆姿勢。


void set_bone_enabled(bone_idx: int, enabled: bool = true) 🔗

如果為 false 則為位於 bone_idx 的骨骼禁用姿勢,如果為 true 則啟用該骨骼姿勢。


void set_bone_global_pose(bone_idx: int, pose: Transform3D) 🔗

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

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 set_bone_pose() with precalculation.


void set_bone_global_pose_override(bone_idx: int, pose: Transform3D, amount: float, persistent: bool = false) 🔗

已棄用: 此方法可能在未來版本中變更或移除。

bone_idx 處的骨骼設定全域姿勢變換 pose

amount 是套用姿勢時將使用的插值強度,persistent 決定套用的姿勢是否會保留。

注意:姿勢變換需要的是全域姿勢!要將 Node3D 的世界變換轉換為全域骨骼姿勢,請將節點的 Node3D.global_transformTransform3D.affine_inverse() 乘以所期望的世界變換。


void set_bone_meta(bone_idx: int, key: StringName, value: Variant) 🔗

Sets the metadata with the given key to value for the bone at index bone_idx.


void set_bone_name(bone_idx: int, name: String) 🔗

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


void set_bone_parent(bone_idx: int, parent_idx: int) 🔗

將骨骼索引 parent_idx 設定為 bone_idx 處骨骼的父級。如果為 -1,則該骨骼沒有父級。

注意:parent_idx 必須小於 bone_idx


void set_bone_pose(bone_idx: int, pose: Transform3D) 🔗

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


void set_bone_pose_position(bone_idx: int, position: Vector3) 🔗

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


void set_bone_pose_rotation(bone_idx: int, rotation: Quaternion) 🔗

Sets the pose rotation of the bone at bone_idx 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.


void set_bone_pose_scale(bone_idx: int, scale: Vector3) 🔗

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


void set_bone_rest(bone_idx: int, rest: Transform3D) 🔗

設定骨骼 bone_idx 的放鬆變換。


void unparent_bone_and_rest(bone_idx: int) 🔗

讓位於 bone_idx 的骨骼不再有父級,並將其放鬆位置設定為之前父級放鬆時的位置。