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.

PhysicalBone2D

繼承: RigidBody2D < PhysicsBody2D < CollisionObject2D < Node2D < CanvasItem < Node < Object

衍生自 RigidBody2D 的節點,用於讓 Skeleton2D 中的 Bone2D 對物理作出反應。

說明

PhysicalBone2D 節點基於 RigidBody2D,可以用來使 Skeleton2D 中的 Bone2D 節點對物理作出反應。

注意:為了讓 Bone2D 節點在視覺上跟隨 PhysicalBone2D 節點,請在父級 Skeleton2D 節點上使用 SkeletonModification2DPhysicalBones 修改。

注意:PhysicalBone2D 節點不會自動建立 Joint2D 節點來讓 PhysicalBone2D 節點保持在一起。你需要手動建立這些節點。大多數情況下,你想要使用的都是 PinJoint2D 節點。建立 PhysicalBone2D 子節點後會自動配置 Joint2D 節點。

屬性

bool

auto_configure_joint

true

int

bone2d_index

-1

NodePath

bone2d_nodepath

NodePath("")

bool

follow_bone_when_simulating

false

bool

simulate_physics

false

方法

Joint2D

get_joint() const

bool

is_simulating_physics() const


屬性說明

bool auto_configure_joint = true 🔗

  • void set_auto_configure_joint(value: bool)

  • bool get_auto_configure_joint()

如果為 truePhysicalBone2D 節點會自動配置第一個 Joint2D 子節點。自動配置僅限於設定節點屬性和定位該 Joint2D


int bone2d_index = -1 🔗

  • void set_bone2d_index(value: int)

  • int get_bone2d_index()

PhysicalBone2D 節點所模擬的 Bone2D 節點的索引。


NodePath bone2d_nodepath = NodePath("") 🔗

PhysicalBone2D 所模擬的 Bone2DNodePath


bool follow_bone_when_simulating = false 🔗

  • void set_follow_bone_when_simulating(value: bool)

  • bool get_follow_bone_when_simulating()

如果為 true,則該 PhysicalBone2D 在類比物理時會保持其綁定的骨骼的變換。


bool simulate_physics = false 🔗

  • void set_simulate_physics(value: bool)

  • bool get_simulate_physics()

如果為 truePhysicalBone2D 將開始使用物理進行類比。如果為 falsePhysicalBone2D 將跟隨 Bone2D 節點的變換。

注意:要使 Bone2D 節點在視覺上跟隨 PhysicalBone2D 節點,請在具有 Bone2D 節點的 Skeleton2D 節點上使用一個 SkeletonModification2DPhysicalBones 修改。


方法說明

Joint2D get_joint() const 🔗

如果存在,則返回第一個 Joint2D 子節點。主要是輔助函式,用於簡化對 PhysicalBone2D 所自動配置的 Joint2D 的獲取。


bool is_simulating_physics() const 🔗

返回一個布林值,表示 PhysicalBone2D 節點是否處於運作狀態,正在使用 Godot 2D 物理引擎進行模擬。為 true 時,該 PhysicalBone2D 節點正在使用物理。