PhysicalBone2D

Inherits: RigidDynamicBody2D < PhysicsBody2D < CollisionObject2D < Node2D < CanvasItem < Node < Object

A 2D node that can be used for physically aware bones in 2D.

Description

The PhysicalBone2D node is a RigidDynamicBody2D-based node that can be used to make Bone2D nodes in a Skeleton2D react to physics. This node is very similar to the PhysicalBone3D node, just for 2D instead of 3D.

Note: To have the Bone2D nodes visually follow the PhysicalBone2D node, use a SkeletonModification2DPhysicalBones modification on the Skeleton2D node with the Bone2D nodes.

Note: The PhysicalBone2D node does not automatically create a Joint2D node to keep PhysicalBone2D nodes together. You will need to create these manually. For most cases, you want to use a PinJoint2D node. The PhysicalBone2D node can automatically configure the Joint2D node once it's been created as a child node.

Methods

Joint2D

get_joint ( ) const

bool

is_simulating_physics ( ) const

Property Descriptions

  • bool auto_configure_joint

Default

true

Setter

set_auto_configure_joint(value)

Getter

get_auto_configure_joint()

If true, the PhysicalBone2D node will automatically configure the first Joint2D child node. The automatic configuration is limited to setting up the node properties and positioning the Joint2D.


  • int bone2d_index

Default

-1

Setter

set_bone2d_index(value)

Getter

get_bone2d_index()

The index of the Bone2D node that this PhysicalBone2D node is supposed to be simulating.


Default

NodePath("")

Setter

set_bone2d_nodepath(value)

Getter

get_bone2d_nodepath()

The NodePath to the Bone2D node that this PhysicalBone2D node is supposed to be simulating.


  • bool follow_bone_when_simulating

Default

false

Setter

set_follow_bone_when_simulating(value)

Getter

get_follow_bone_when_simulating()

If true, the PhysicalBone2D will keep the transform of the bone it is bound to when simulating physics.


  • bool simulate_physics

Default

false

Setter

set_simulate_physics(value)

Getter

get_simulate_physics()

If true, the PhysicalBone2D will start simulating using physics. If false, the PhysicalBone2D will follow the transform of the Bone2D node.

Note: To have the Bone2D nodes visually follow the PhysicalBone2D node, use a SkeletonModification2DPhysicalBones modification on the Skeleton2D node with the Bone2D nodes.

Method Descriptions

Returns the first Joint2D child node, if one exists. This is mainly a helper function to make it easier to get the Joint2D that the PhysicalBone2D is autoconfiguring.


  • bool is_simulating_physics ( ) const

Returns a boolean that indicates whether the PhysicalBone2D node is running and simulating using the Godot 2D physics engine. When true, the PhysicalBone2D node is using physics.