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.

SkeletonIK3D

已棄用: This class may be changed or removed in future versions.

繼承: SkeletonModifier3D < Node3D < Node < Object

可以將 Skeleton3D 骨骼鏈中的所有骨骼進行旋轉,從而將末端骨骼放置在正確的 3D 位置的節點。

說明

SkeletonIK3D is used to rotate all bones of a Skeleton3D bone chain a way that places the end bone at a desired 3D position. A typical scenario for IK in games is to place a character's feet on the ground or a character's hands on a currently held object. SkeletonIK uses FabrikInverseKinematic internally to solve the bone chain and applies the results to the Skeleton3D bones_global_pose_override property for all affected bones in the chain. If fully applied, this overwrites any bone transform from Animations or bone custom poses set by users. The applied amount can be controlled with the SkeletonModifier3D.influence property.

# Apply IK effect automatically on every new frame (not the current)
skeleton_ik_node.start()

# Apply IK effect only on the current frame
skeleton_ik_node.start(true)

# Stop IK effect and reset bones_global_pose_override on Skeleton
skeleton_ik_node.stop()

# Apply full IK effect
skeleton_ik_node.set_influence(1.0)

# Apply half IK effect
skeleton_ik_node.set_influence(0.5)

# Apply zero IK effect (a value at or below 0.01 also removes bones_global_pose_override on Skeleton)
skeleton_ik_node.set_influence(0.0)

屬性

float

interpolation

Vector3

magnet

Vector3(0, 0, 0)

int

max_iterations

10

float

min_distance

0.01

bool

override_tip_basis

true

StringName

root_bone

&""

Transform3D

target

Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0)

NodePath

target_node

NodePath("")

StringName

tip_bone

&""

bool

use_magnet

false

方法

Skeleton3D

get_parent_skeleton() const

bool

is_running()

void

start(one_time: bool = false)

void

stop()


屬性說明

float interpolation 🔗

  • void set_interpolation(value: float)

  • float get_interpolation()

已棄用: Use SkeletonModifier3D.influence instead.

Interpolation value for how much the IK results are applied to the current skeleton bone chain. A value of 1.0 will overwrite all skeleton bone transforms completely while a value of 0.0 will visually disable the SkeletonIK.


Vector3 magnet = Vector3(0, 0, 0) 🔗

  • void set_magnet_position(value: Vector3)

  • Vector3 get_magnet_position()

IK 鏈的次要目標位置(首先是 target 屬性或 target_node)。使用磁鐵位置(極點目標)來控制 IK 鏈的彎曲。僅當骨骼鏈具有 2 個以上的骨骼時才有效。中間鏈骨位置將與磁鐵位置進行線性插值。


int max_iterations = 10 🔗

  • void set_max_iterations(value: int)

  • int get_max_iterations()

IK解算器使用的反覆運算迴圈的數量,以產生更準確(和優雅)的骨鏈效果。


float min_distance = 0.01 🔗

  • void set_min_distance(value: float)

  • float get_min_distance()

骨骼與目標物件之間的最小距離。如果距離低於這個值,IK解算器將停止進一步的迭代。


bool override_tip_basis = true 🔗

  • void set_override_tip_basis(value: bool)

  • bool is_override_tip_basis()

如果為 true,則用 target(或者如果定義了 target_node])的旋轉覆蓋尖端骨骼的旋轉。


StringName root_bone = &"" 🔗

目前的根骨骼的名稱,即 IK 鏈中的第一條骨骼。


Transform3D target = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0) 🔗

放置尖端骨骼的 IK 鏈的第一個目標,如果 override_tip_basistrue,尖端骨骼的旋轉方式。如果 target_node 路徑可用,則使用節點變換,並忽略此屬性。


NodePath target_node = NodePath("") 🔗

IK 鏈的目標節點 NodePath。如果有的話,將使用節點目前的 Transform3D,而不是 target 屬性。


StringName tip_bone = &"" 🔗

目前尖端骨骼的名稱,IK 鏈中放置在 target 變換處的最後一個骨骼(或者已定義 target_node)。


bool use_magnet = false 🔗

  • void set_use_magnet(value: bool)

  • bool is_using_magnet()

如果為 true,指示 IK 求解器在解算器鏈時考慮次要磁鐵目標(極點目標)。使用磁鐵位置(磁極目標)來控制 IK 鏈的彎曲。


方法說明

Skeleton3D get_parent_skeleton() const 🔗

Returns the parent Skeleton3D node that was present when SkeletonIK entered the scene tree. Returns null if the parent node was not a Skeleton3D node when SkeletonIK3D entered the scene tree.


bool is_running() 🔗

如果 SkeletonIK 正將 IK 效果套用到 Skeleton3D 骨骼的連續影格上,則返回 true。如果 SkeletonIK 被停止或 start() 被使用時 one_time 參數被設定為 true,則返回 false


void start(one_time: bool = false) 🔗

開始將 IK 效果套用到每一影格的 Skeleton3D 骨骼,但只會在下一影格開始生效。如果 one_timetrue 則將立即生效,但仍會在下一影格重設。


void stop() 🔗

停止將 IK 效果套用到每影格的 Skeleton3D 骨骼,並呼叫 Skeleton3D.clear_bones_global_pose_override() 來移除所有骨骼上的現有覆蓋。