PhysicalBone3D
A bone physics body bound to a skeleton.
PhysicalBone3D binds a physics body to a Skeleton3D bone through PhysicalBoneSimulator3D. Set its bone name through dynamic Set("bone_name", name); there is no public C# BoneName property here. GetBoneId checks binding.
BodyOffset and JointOffset describe different frames: body placement relative to the bone and the joint connection. A collider, mass and joint do not automatically form an anatomical model. Start/stop through the simulator and coordinate physics with animation and ordinary character control.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
PhysicalBone3DConstructor
public PhysicalBone3D();Properties16
AngularDampProperty
public float AngularDamp { get; set; }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 PhysicalBone3D.AngularDampMode, you can set PhysicalBone3D.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.
AngularDampModeProperty
public PhysicalBone3D.DampMode AngularDampMode { get; set; }Defines how PhysicalBone3D.AngularDamp is applied.
AngularVelocityProperty
public Vector3 AngularVelocity { get; set; }The PhysicalBone3D's rotational velocity in radians per second.
BodyOffsetProperty
public Transform3D BodyOffset { get; set; }The physics body offset relative to its bound bone. Configure it with geometry and rest pose; moving only a visible mesh does not repair body/joint placement.
BounceProperty
public float Bounce { get; set; }The body's bounciness. Values range from 0 (no bounce) to 1 (full bounciness).
Note: Even with PhysicalBone3D.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 PhysicalBone3D.Bounce to 1.0, PhysicalBone3D.LinearDampMode to PhysicalBone3D.DampMode.Replace, PhysicalBone3D.LinearDamp to 0.0, PhysicalBone3D.AngularDampMode to PhysicalBone3D.DampMode.Replace, and PhysicalBone3D.AngularDamp to 0.0.
CanSleepProperty
public bool CanSleep { get; set; }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.
CustomIntegratorProperty
public bool CustomIntegrator { get; set; }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 PhysicalBone3D._IntegrateForces method, if that virtual method is overridden.
Setting this property will call the method PhysicsServer3D.BodySetOmitForceIntegration internally.
FrictionProperty
public float Friction { get; set; }The body's friction, from 0 (frictionless) to 1 (max friction).
GravityScaleProperty
public float GravityScale { get; set; }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.
JointOffsetProperty
public Transform3D JointOffset { get; set; }The physics joint frame. Distinct from BodyOffset; check coordinate spaces, axes and limits for the chosen joint/backend.
JointRotationProperty
public Vector3 JointRotation { get; set; }Sets the joint's rotation in radians.
JointTypeProperty
public PhysicalBone3D.JointTypeEnum JointType { get; set; }Sets the joint type.
LinearDampProperty
public float LinearDamp { get; set; }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 PhysicalBone3D.LinearDampMode, PhysicalBone3D.LinearDamp may be added to or replace the body's damping value.
See ProjectSettings.physics/3d/default_linear_damp for more details about damping.
LinearDampModeProperty
public PhysicalBone3D.DampMode LinearDampMode { get; set; }Defines how PhysicalBone3D.LinearDamp is applied.
LinearVelocityProperty
public Vector3 LinearVelocity { get; set; }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 PhysicalBone3D._IntegrateForces as your process loop for precise control of the body state.
MassProperty
public float Mass { get; set; }The body's mass.
Methods39
ApplyCentralImpulsevoid
public void ApplyCentralImpulse(Vector3 impulse);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 PhysicalBone3D.ApplyImpulse at the body's center of mass.
| Name | Type | Default |
|---|---|---|
impulse | Vector3 | — |
ApplyImpulsevoid
public void ApplyImpulse(Vector3 impulse, Vector3? position = default);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.
| Name | Type | Default |
|---|---|---|
impulse | Vector3 | — |
position | Vector3? | default |
positionIf the parameter is null, then the default value is new Vector3(0.0f, 0.0f, 0.0f).
GetAngularDampfloat
public float GetAngularDamp();floatGetAngularDampModePhysicalBone3D.DampMode
public PhysicalBone3D.DampMode GetAngularDampMode();PhysicalBone3D.DampModeGetAngularVelocityVector3
public Vector3 GetAngularVelocity();Vector3GetBodyOffsetTransform3D
public Transform3D GetBodyOffset();Transform3DGetBoneIdint
public int GetBoneId();The bound skeleton bone index; -1 indicates no binding. Check dynamic bone_name and simulator/Skeleton3D hierarchy. This is not an entity-tree child index.
intGetBouncefloat
public float GetBounce();floatGetFrictionfloat
public float GetFriction();floatGetGravityScalefloat
public float GetGravityScale();floatGetJointOffsetTransform3D
public Transform3D GetJointOffset();Transform3DGetJointRidRid
public Rid GetJointRid();Returns the joint's internal Rid from the PhysicsServer3D.
RidGetJointRotationVector3
public Vector3 GetJointRotation();Vector3GetJointTypePhysicalBone3D.JointTypeEnum
public PhysicalBone3D.JointTypeEnum GetJointType();PhysicalBone3D.JointTypeEnumGetLinearDampfloat
public float GetLinearDamp();floatGetLinearDampModePhysicalBone3D.DampMode
public PhysicalBone3D.DampMode GetLinearDampMode();PhysicalBone3D.DampModeGetLinearVelocityVector3
public Vector3 GetLinearVelocity();Vector3GetMassfloat
public float GetMass();floatGetSimulatePhysicsbool
public bool GetSimulatePhysics();Returns true if the PhysicsBone3D is allowed to simulate physics.
boolIsAbleToSleepbool
public bool IsAbleToSleep();boolIsSimulatingPhysicsbool
public bool IsSimulatingPhysics();Returns true if the PhysicsBone3D is currently simulating physics.
boolIsUsingCustomIntegratorbool
public bool IsUsingCustomIntegrator();boolSetAngularDampvoid
public void SetAngularDamp(float angularDamp);| Name | Type | Default |
|---|---|---|
angularDamp | float | — |
SetAngularDampModevoid
public void SetAngularDampMode(PhysicalBone3D.DampMode angularDampMode);| Name | Type | Default |
|---|---|---|
angularDampMode | PhysicalBone3D.DampMode | — |
SetAngularVelocityvoid
public void SetAngularVelocity(Vector3 angularVelocity);| Name | Type | Default |
|---|---|---|
angularVelocity | Vector3 | — |
SetBodyOffsetvoid
public void SetBodyOffset(Transform3D offset);| Name | Type | Default |
|---|---|---|
offset | Transform3D | — |
SetBouncevoid
public void SetBounce(float bounce);| Name | Type | Default |
|---|---|---|
bounce | float | — |
SetCanSleepvoid
public void SetCanSleep(bool ableToSleep);| Name | Type | Default |
|---|---|---|
ableToSleep | bool | — |
SetFrictionvoid
public void SetFriction(float friction);| Name | Type | Default |
|---|---|---|
friction | float | — |
SetGravityScalevoid
public void SetGravityScale(float gravityScale);| Name | Type | Default |
|---|---|---|
gravityScale | float | — |
SetJointOffsetvoid
public void SetJointOffset(Transform3D offset);| Name | Type | Default |
|---|---|---|
offset | Transform3D | — |
SetJointRotationvoid
public void SetJointRotation(Vector3 euler);| Name | Type | Default |
|---|---|---|
euler | Vector3 | — |
SetJointTypevoid
public void SetJointType(PhysicalBone3D.JointTypeEnum jointType);| Name | Type | Default |
|---|---|---|
jointType | PhysicalBone3D.JointTypeEnum | — |
SetLinearDampvoid
public void SetLinearDamp(float linearDamp);| Name | Type | Default |
|---|---|---|
linearDamp | float | — |
SetLinearDampModevoid
public void SetLinearDampMode(PhysicalBone3D.DampMode linearDampMode);| Name | Type | Default |
|---|---|---|
linearDampMode | PhysicalBone3D.DampMode | — |
SetLinearVelocityvoid
public void SetLinearVelocity(Vector3 linearVelocity);| Name | Type | Default |
|---|---|---|
linearVelocity | Vector3 | — |
SetMassvoid
public void SetMass(float mass);| Name | Type | Default |
|---|---|---|
mass | float | — |
SetUseCustomIntegratorvoid
public void SetUseCustomIntegrator(bool enable);| Name | Type | Default |
|---|---|---|
enable | bool | — |
_IntegrateForcesvoid
public virtual void _IntegrateForces(PhysicsDirectBodyState3D state);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 PhysicalBone3D.CustomIntegrator property allows you to disable the standard force integration and do fully custom force integration for a body.
| Name | Type | Default |
|---|---|---|
state | PhysicsDirectBodyState3D | — |
PhysicalBone3D.DampMode
| Value | Description |
|---|---|
Combine = 0 | In this mode, the body's damping value is added to any value set in areas or the default value. |
Replace = 1 | In this mode, the body's damping value replaces any value set in areas or the default value. |
PhysicalBone3D.JointTypeEnum
| Value | Description |
|---|---|
Cone = 2 | A cone joint is applied to the PhysicsBone3D. |
Hinge = 3 | A hinge joint is applied to the PhysicsBone3D. |
None = 0 | No joint is applied to the PhysicsBone3D. |
Pin = 1 | A pin joint is applied to the PhysicsBone3D. |
Slider = 4 | A slider joint is applied to the PhysicsBone3D. |
Type6Dof = 5 | A 6 degrees of freedom joint is applied to the PhysicsBone3D. |