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...
SkeletonModification2DTwoBoneIK
實驗性: This class may be changed or removed in future versions.
繼承: SkeletonModification2D < Resource < RefCounted < Object
這種修改器會讓兩個骨骼按照餘弦定理進行旋轉,最終抵達目標。
說明
這種 SkeletonModification2D 所使用的演算法一般稱之為 TwoBoneIK。這種演算法的原理是利用餘弦定理和骨骼的長度來推算骨骼目前的旋轉量和構成三角形所需的旋轉量,三角形由第一根骨骼、第二根骨骼以及目標構成。因為這種演算法的原理是構成三角形,所以僅能對兩根骨骼進行操作。
TwoBoneIK 適用於手臂、腿部,其實任何能夠用兩根骨頭彎向某個目標來代表的關節均能使用。求解器比 SkeletonModification2DFABRIK 更輕量,但也能得到類似的比較自然的結果。
屬性
|
||
|
||
|
||
|
方法
get_joint_one_bone2d_node() const |
|
get_joint_one_bone_idx() const |
|
get_joint_two_bone2d_node() const |
|
get_joint_two_bone_idx() const |
|
void |
set_joint_one_bone2d_node(bone2d_node: NodePath) |
void |
set_joint_one_bone_idx(bone_idx: int) |
void |
set_joint_two_bone2d_node(bone2d_node: NodePath) |
void |
set_joint_two_bone_idx(bone_idx: int) |
屬性說明
bool flip_bend_direction = false 🔗
If true, the bones in the modification will bend outward as opposed to inwards when contracting. If false, the bones will bend inwards when contracting.
float target_maximum_distance = 0.0 🔗
該目標可以到達的最大距離。如果目標比這個距離更遠,則該修改將如同它就在這個最大距離處一樣求解。當設定為 0 時,則該修改將不受距離限制地求解。
float target_minimum_distance = 0.0 🔗
該目標可以到達的最小距離。如果目標比這個距離更近,則該修改將如同它就在這個最小距離處一樣求解。當設定為 0 時,則該修改將不受距離限制地求解。
NodePath target_nodepath = NodePath("") 🔗
作為 TwoBoneIK 修改目標的節點的 NodePath。該節點是彎曲 Bone2D 節點時該修改將使用的節點。
方法說明
NodePath get_joint_one_bone2d_node() const 🔗
返回 TwoBoneIK 修改器中作為第一個骨骼的 Bone2D 節點。
int get_joint_one_bone_idx() const 🔗
返回 TwoBoneIK 修改器中作為第一個骨骼的 Bone2D 節點的索引。
NodePath get_joint_two_bone2d_node() const 🔗
返回 TwoBoneIK 修改器中作為第二個骨骼的 Bone2D 節點。
int get_joint_two_bone_idx() const 🔗
返回 TwoBoneIK 修改器中作為第二個骨骼的 Bone2D 節點的索引。
void set_joint_one_bone2d_node(bone2d_node: NodePath) 🔗
設定 TwoBoneIK 修改器中作為第一個骨骼的 Bone2D 節點。
void set_joint_one_bone_idx(bone_idx: int) 🔗
設定 TwoBoneIK 修改器中作為第一個骨骼的 Bone2D 節點的索引。
void set_joint_two_bone2d_node(bone2d_node: NodePath) 🔗
設定 TwoBoneIK 修改器中作為第二個骨骼的 Bone2D 節點。
void set_joint_two_bone_idx(bone_idx: int) 🔗
設定 TwoBoneIK 修改器中作為第二個骨骼的 Bone2D 節點的索引。