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.
Checking the stable version of the documentation...
SkeletonModification2DFABRIK
實驗性: This class may be changed or removed in future versions.
繼承: SkeletonModification2D < Resource < RefCounted < Object
使用 FABRIK 操縱一系列 Bone2D 到達某個目標的修改器。
說明
This SkeletonModification2D uses an algorithm called Forward And Backward Reaching Inverse Kinematics, or FABRIK, to rotate a bone chain so that it reaches a target.
FABRIK works by knowing the positions and lengths of a series of bones, typically called a "bone chain". It first starts by running a forward pass, which places the final bone at the target's position. Then all other bones are moved towards the tip bone, so they stay at the defined bone length away. Then a backwards pass is performed, where the root/first bone in the FABRIK chain is placed back at the origin. Then all other bones are moved so they stay at the defined bone length away. This positions the bone chain so that it reaches the target when possible, but all of the bones stay the correct length away from each other.
Because of how FABRIK works, it often gives more natural results than those seen in SkeletonModification2DCCDIK.
Note: The FABRIK modifier has fabrik_joints, which are the data objects that hold the data for each joint in the FABRIK chain. This is different from Bone2D nodes! FABRIK joints hold the data needed for each Bone2D in the bone chain used by FABRIK.
To help control how the FABRIK joints move, a magnet vector can be passed, which can nudge the bones in a certain direction prior to solving, giving a level of control over the final result.
屬性
|
||
|
方法
get_fabrik_joint_bone2d_node(joint_idx: int) const |
|
get_fabrik_joint_bone_index(joint_idx: int) const |
|
get_fabrik_joint_magnet_position(joint_idx: int) const |
|
get_fabrik_joint_use_target_rotation(joint_idx: int) const |
|
void |
set_fabrik_joint_bone2d_node(joint_idx: int, bone2d_nodepath: NodePath) |
void |
set_fabrik_joint_bone_index(joint_idx: int, bone_idx: int) |
void |
set_fabrik_joint_magnet_position(joint_idx: int, magnet_position: Vector2) |
void |
set_fabrik_joint_use_target_rotation(joint_idx: int, use_target_rotation: bool) |
屬性說明
int fabrik_data_chain_length = 0 🔗
FABRIK 修改中 FABRIK 關節的數量。
NodePath target_nodepath = NodePath("") 🔗
FABRIK 修改器的目標節點的 NodePath。FABRIK 鏈會嘗試將骨骼鏈轉向這個節點。
方法說明
NodePath get_fabrik_joint_bone2d_node(joint_idx: int) const 🔗
返回分配給位於 joint_idx 的 FABRIK 關節的 Bone2D 節點。
int get_fabrik_joint_bone_index(joint_idx: int) const 🔗
返回分配給位於 joint_idx 的 FABRIK 關節的 Bone2D 節點的索引。
Vector2 get_fabrik_joint_magnet_position(joint_idx: int) const 🔗
返回位於 joint_idx 的關節的磁吸位置向量。
bool get_fabrik_joint_use_target_rotation(joint_idx: int) const 🔗
返回關節是否正在使用目標的旋轉,而不是允許 FABRIK 旋轉關節。此選項僅適用於鏈中的末端/最終關節。
void set_fabrik_joint_bone2d_node(joint_idx: int, bone2d_nodepath: NodePath) 🔗
設定分配給位於 joint_idx 的 FABRIK 關節的 Bone2D 節點。
void set_fabrik_joint_bone_index(joint_idx: int, bone_idx: int) 🔗
設定位於 joint_idx 的 FABRIK 關節的骨骼索引 bone_idx。可能時,這也會根據連結骨架所提供的資料來更新 FABRIK 關節的 bone2d_node。
void set_fabrik_joint_magnet_position(joint_idx: int, magnet_position: Vector2) 🔗
設定位於 joint_idx 的關節的磁吸位置向量。
void set_fabrik_joint_use_target_rotation(joint_idx: int, use_target_rotation: bool) 🔗
設定位於 joint_idx 的關節是否正在使用目標節點的旋轉,而不是讓 FABRIK 旋轉關節。
注意:這個選項僅適用於鏈中的末端/最終關節。對於所有其他節點,這個選項將被忽略。