PhysicalBone3D

package
v0.0.0-...-357ca8a Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 20, 2025 License: MIT Imports: 30 Imported by: 0

Documentation

Overview

The PhysicalBone3D node is a physics body that can be used to make bones in a Skeleton3D react to physics.

Note: In order to detect physical bones with raycasts, the SkeletonModifier3D.Active property of the parent PhysicalBoneSimulator3D must be true and the Skeleton3D's bone must be assigned to PhysicalBone3D correctly; it means that GetBoneId should return a valid id (>= 0).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Advanced

type Advanced = class

Advanced exposes a 1:1 low-level instance of the class, undocumented, for those who know what they are doing.

type Any

type Any interface {
	gd.IsClass
	AsPhysicalBone3D() Instance
}

type DampMode

type DampMode int //gd:PhysicalBone3D.DampMode
const (
	// In this mode, the body's damping value is added to any value set in areas or the default value.
	DampModeCombine DampMode = 0
	// In this mode, the body's damping value replaces any value set in areas or the default value.
	DampModeReplace DampMode = 1
)

type Expanded

type Expanded = MoreArgs

type Extension

type Extension[T gdclass.Interface] struct{ gdclass.Extension[T, Instance] }

Extension can be embedded in a new struct to create an extension of this class. T should be the type that is embedding this [Extension]See Interface for methods that can be overridden by T.

func (*Extension[T]) AsCollisionObject3D

func (self *Extension[T]) AsCollisionObject3D() CollisionObject3D.Instance

func (*Extension[T]) AsNode

func (self *Extension[T]) AsNode() Node.Instance

func (*Extension[T]) AsNode3D

func (self *Extension[T]) AsNode3D() Node3D.Instance

func (*Extension[T]) AsObject

func (self *Extension[T]) AsObject() [1]gd.Object

func (*Extension[T]) AsPhysicalBone3D

func (self *Extension[T]) AsPhysicalBone3D() Instance

func (*Extension[T]) AsPhysicsBody3D

func (self *Extension[T]) AsPhysicsBody3D() PhysicsBody3D.Instance

type ID

type ID Object.ID

ID is a typed object ID (reference) to an instance of this class, use it to store references to objects with unknown lifetimes, as an ID will not panic on use if the underlying object has been destroyed.

func (ID) Instance

func (id ID) Instance() (Instance, bool)

type Implementation

type Implementation = implementation

Implementation implements Interface with empty methods.

type Instance

type Instance [1]gdclass.PhysicalBone3D

Instance of the class with convieniently typed arguments and results.

var Nil Instance

Nil is a nil/null instance of the class. Equivalent to the zero value.

func New

func New() Instance

func (Instance) AngularDamp

func (self Instance) AngularDamp() Float.X

Damps the body's rotation. By default, the body will use the ProjectSettings "physics/3d/default_angular_damp" project setting or any value override set by an Area3D the body is in. Depending on AngularDampMode, you can set AngularDamp to be added to or to replace the body's damping value.

See ProjectSettings "physics/3d/default_angular_damp" for more details about damping.

func (Instance) AngularDampMode

func (self Instance) AngularDampMode() DampMode

Defines how AngularDamp is applied.

func (Instance) AngularVelocity

func (self Instance) AngularVelocity() Vector3.XYZ

The PhysicalBone3D's rotational velocity in radians per second.

func (Instance) ApplyCentralImpulse

func (self Instance) ApplyCentralImpulse(impulse Vector3.XYZ)

Applies a directional impulse without affecting rotation.

An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_integrate_forces" functions otherwise).

This is equivalent to using ApplyImpulse at the body's center of mass.

func (Instance) ApplyImpulse

func (self Instance) ApplyImpulse(impulse Vector3.XYZ)

Applies a positioned impulse to the PhysicsBone3D.

An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_integrate_forces" functions otherwise).

'position' is the offset from the PhysicsBone3D origin in global coordinates.

func (Instance) AsCollisionObject3D

func (self Instance) AsCollisionObject3D() CollisionObject3D.Instance

func (Instance) AsNode

func (self Instance) AsNode() Node.Instance

func (Instance) AsNode3D

func (self Instance) AsNode3D() Node3D.Instance

func (Instance) AsObject

func (self Instance) AsObject() [1]gd.Object

func (Instance) AsPhysicalBone3D

func (self Instance) AsPhysicalBone3D() Instance

func (Instance) AsPhysicsBody3D

func (self Instance) AsPhysicsBody3D() PhysicsBody3D.Instance

func (Instance) BodyOffset

func (self Instance) BodyOffset() Transform3D.BasisOrigin

Sets the body's transform.

func (Instance) Bounce

func (self Instance) Bounce() Float.X

The body's bounciness. Values range from 0 (no bounce) to 1 (full bounciness).

Note: Even with Bounce set to 1.0, some energy will be lost over time due to linear and angular damping. To have a PhysicalBone3D that preserves all its energy over time, set Bounce to 1.0, LinearDampMode to DampModeReplace, LinearDamp to 0.0, AngularDampMode to DampModeReplace, and AngularDamp to 0.0.

func (Instance) CanSleep

func (self Instance) CanSleep() bool

If true, the body is deactivated when there is no movement, so it will not take part in the simulation until it is awakened by an external force.

func (Instance) CustomIntegrator

func (self Instance) CustomIntegrator() bool

If true, the standard force integration (like gravity or damping) will be disabled for this body. Other than collision response, the body will only move as determined by the IntegrateForces method, if that virtual method is overridden.

Setting this property will call the method PhysicsServer3D.BodySetOmitForceIntegration internally.

func (Instance) Friction

func (self Instance) Friction() Float.X

The body's friction, from 0 (frictionless) to 1 (max friction).

func (Instance) GetBoneId

func (self Instance) GetBoneId() int

Returns the unique identifier of the PhysicsBone3D.

func (Instance) GetSimulatePhysics

func (self Instance) GetSimulatePhysics() bool

Returns true if the PhysicsBone3D is allowed to simulate physics.

func (Instance) GravityScale

func (self Instance) GravityScale() Float.X

This is multiplied by ProjectSettings "physics/3d/default_gravity" to produce this body's gravity. For example, a value of 1.0 will apply normal gravity, 2.0 will apply double the gravity, and 0.5 will apply half the gravity to this body.

func (Instance) ID

func (self Instance) ID() ID

func (Instance) IsSimulatingPhysics

func (self Instance) IsSimulatingPhysics() bool

Returns true if the PhysicsBone3D is currently simulating physics.

func (Instance) JointOffset

func (self Instance) JointOffset() Transform3D.BasisOrigin

Sets the joint's transform.

func (Instance) JointRotation

func (self Instance) JointRotation() Vector3.XYZ

Sets the joint's rotation in radians.

func (Instance) JointType

func (self Instance) JointType() JointType

Sets the joint type.

func (Instance) LinearDamp

func (self Instance) LinearDamp() Float.X

Damps the body's movement. By default, the body will use ProjectSettings "physics/3d/default_linear_damp" or any value override set by an Area3D the body is in. Depending on LinearDampMode, LinearDamp may be added to or replace the body's damping value.

See ProjectSettings "physics/3d/default_linear_damp" for more details about damping.

func (Instance) LinearDampMode

func (self Instance) LinearDampMode() DampMode

Defines how LinearDamp is applied.

func (Instance) LinearVelocity

func (self Instance) LinearVelocity() Vector3.XYZ

The body's linear velocity in units per second. Can be used sporadically, but don't set this every frame, because physics may run in another thread and runs at a different granularity. Use IntegrateForces as your process loop for precise control of the body state.

func (Instance) Mass

func (self Instance) Mass() Float.X

The body's mass.

func (Instance) MoreArgs

func (self Instance) MoreArgs() MoreArgs

MoreArgs enables certain functions to be called with additional 'optional' arguments.

func (Instance) SetAngularDamp

func (self Instance) SetAngularDamp(value Float.X)

SetAngularDamp sets the property returned by [GetAngularDamp].

func (Instance) SetAngularDampMode

func (self Instance) SetAngularDampMode(value DampMode)

SetAngularDampMode sets the property returned by [GetAngularDampMode].

func (Instance) SetAngularVelocity

func (self Instance) SetAngularVelocity(value Vector3.XYZ)

SetAngularVelocity sets the property returned by [GetAngularVelocity].

func (Instance) SetBodyOffset

func (self Instance) SetBodyOffset(value Transform3D.BasisOrigin)

SetBodyOffset sets the property returned by [GetBodyOffset].

func (Instance) SetBounce

func (self Instance) SetBounce(value Float.X)

SetBounce sets the property returned by [GetBounce].

func (Instance) SetCanSleep

func (self Instance) SetCanSleep(value bool)

SetCanSleep sets the property returned by [IsAbleToSleep].

func (Instance) SetCustomIntegrator

func (self Instance) SetCustomIntegrator(value bool)

SetCustomIntegrator sets the property returned by [IsUsingCustomIntegrator].

func (Instance) SetFriction

func (self Instance) SetFriction(value Float.X)

SetFriction sets the property returned by [GetFriction].

func (Instance) SetGravityScale

func (self Instance) SetGravityScale(value Float.X)

SetGravityScale sets the property returned by [GetGravityScale].

func (Instance) SetJointOffset

func (self Instance) SetJointOffset(value Transform3D.BasisOrigin)

SetJointOffset sets the property returned by [GetJointOffset].

func (Instance) SetJointRotation

func (self Instance) SetJointRotation(value Vector3.XYZ)

SetJointRotation sets the property returned by [GetJointRotation].

func (Instance) SetJointType

func (self Instance) SetJointType(value JointType)

SetJointType sets the property returned by [GetJointType].

func (Instance) SetLinearDamp

func (self Instance) SetLinearDamp(value Float.X)

SetLinearDamp sets the property returned by [GetLinearDamp].

func (Instance) SetLinearDampMode

func (self Instance) SetLinearDampMode(value DampMode)

SetLinearDampMode sets the property returned by [GetLinearDampMode].

func (Instance) SetLinearVelocity

func (self Instance) SetLinearVelocity(value Vector3.XYZ)

SetLinearVelocity sets the property returned by [GetLinearVelocity].

func (Instance) SetMass

func (self Instance) SetMass(value Float.X)

SetMass sets the property returned by [GetMass].

func (*Instance) SetObject

func (self *Instance) SetObject(obj [1]gd.Object) bool

func (Instance) Virtual

func (self Instance) Virtual(name string) reflect.Value

type Interface

type Interface interface {
	// Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default, it is called before the standard force integration, but the [CustomIntegrator] property allows you to disable the standard force integration and do fully custom force integration for a body.
	//
	// [CustomIntegrator]: https://pkg.go.dev/graphics.gd/classdb/PhysicalBone3D#Instance.CustomIntegrator
	IntegrateForces(state PhysicsDirectBodyState3D.Instance)
}

type JointType

type JointType int //gd:PhysicalBone3D.JointType
const (
	// No joint is applied to the PhysicsBone3D.
	JointTypeNone JointType = 0
	// A pin joint is applied to the PhysicsBone3D.
	JointTypePin JointType = 1
	// A cone joint is applied to the PhysicsBone3D.
	JointTypeCone JointType = 2
	// A hinge joint is applied to the PhysicsBone3D.
	JointTypeHinge JointType = 3
	// A slider joint is applied to the PhysicsBone3D.
	JointTypeSlider JointType = 4
	// A 6 degrees of freedom joint is applied to the PhysicsBone3D.
	JointType6dof JointType = 5
)

type MoreArgs

type MoreArgs [1]gdclass.PhysicalBone3D

MoreArgs is a container for Instance functions with additional 'optional' arguments.

func (MoreArgs) ApplyImpulse

func (self MoreArgs) ApplyImpulse(impulse Vector3.XYZ, position Vector3.XYZ)

Applies a positioned impulse to the PhysicsBone3D.

An impulse is time-independent! Applying an impulse every frame would result in a framerate-dependent force. For this reason, it should only be used when simulating one-time impacts (use the "_integrate_forces" functions otherwise).

'position' is the offset from the PhysicsBone3D origin in global coordinates.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL