Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

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 ( bool value )

  • bool get_auto_configure_joint ( )

如果为 truePhysicalBone2D 节点会自动配置第一个 Joint2D 子节点。自动配置仅限于设置节点属性和定位该 Joint2D


int bone2d_index = -1

  • void set_bone2d_index ( int value )

  • int get_bone2d_index ( )

PhysicalBone2D 节点所模拟的 Bone2D 节点的索引。


NodePath bone2d_nodepath = NodePath("")

PhysicalBone2D 所模拟的 Bone2DNodePath


bool follow_bone_when_simulating = false

  • void set_follow_bone_when_simulating ( bool value )

  • bool get_follow_bone_when_simulating ( )

如果为 true,则该 PhysicalBone2D 在模拟物理时会保持其绑定的骨骼的变换。


bool simulate_physics = false

  • void set_simulate_physics ( bool value )

  • 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 节点正在使用物理。