PhysicsDirectBodyState3D
Provides direct access to a physics body in the PhysicsServer3D.
Provides direct access to a physics body in the PhysicsServer3D.
Provides direct access to a physics body in the PhysicsServer3D, allowing safe changes to physics properties. This object is passed via the direct state callback of RigidBody3D, and is intended for changing the direct state of that body. See RigidBody3D._IntegrateForces.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Properties16
AngularVelocityProperty
public Vector3 AngularVelocity { get; set; }The body's rotational velocity in radians per second.
CenterOfMassProperty
public Vector3 CenterOfMass { get; }The body's center of mass position relative to the body's center in the global coordinate system.
CenterOfMassLocalProperty
public Vector3 CenterOfMassLocal { get; }The body's center of mass position in the body's local coordinate system.
CollisionLayerProperty
public uint CollisionLayer { get; set; }The body's collision layer.
CollisionMaskProperty
public uint CollisionMask { get; set; }The body's collision mask.
InverseInertiaProperty
public Vector3 InverseInertia { get; }The inverse of the inertia of the body.
InverseInertiaTensorProperty
public Basis InverseInertiaTensor { get; }The inverse of the inertia tensor of the body.
InverseMassProperty
public float InverseMass { get; }The inverse of the mass of the body.
LinearVelocityProperty
public Vector3 LinearVelocity { get; set; }The body's linear velocity in units per second.
PrincipalInertiaAxesProperty
public Basis PrincipalInertiaAxes { get; }SleepingProperty
public bool Sleeping { get; set; }If true, this body is currently sleeping (not active).
StepProperty
public float Step { get; }The timestep (delta) used for the simulation.
TotalAngularDampProperty
public float TotalAngularDamp { get; }The rate at which the body stops rotating, if there are not any other forces moving it.
TotalGravityProperty
public Vector3 TotalGravity { get; }The total gravity vector being currently applied to this body.
TotalLinearDampProperty
public float TotalLinearDamp { get; }The rate at which the body stops moving, if there are not any other forces moving it.
TransformProperty
public Transform3D Transform { get; set; }The body's transformation matrix.
Methods50
AddConstantCentralForcevoid
public void AddConstantCentralForce(Vector3? force = default);Adds a constant directional force without affecting rotation that keeps being applied over time until cleared with constant_force = Vector3(0, 0, 0).
This is equivalent to using PhysicsDirectBodyState3D.AddConstantForce at the body's center of mass.
| Name | Type | Default |
|---|---|---|
force | Vector3? | default |
forceIf the parameter is null, then the default value is new Vector3(0.0f, 0.0f, 0.0f).
AddConstantForcevoid
public void AddConstantForce(Vector3 force, Vector3? position = default);Adds a constant positioned force to the body that keeps being applied over time until cleared with constant_force = Vector3(0, 0, 0).
position is the offset from the body origin in global coordinates.
| Name | Type | Default |
|---|---|---|
force | Vector3 | — |
position | Vector3? | default |
positionIf the parameter is null, then the default value is new Vector3(0.0f, 0.0f, 0.0f).
AddConstantTorquevoid
public void AddConstantTorque(Vector3 torque);Adds a constant rotational force without affecting position that keeps being applied over time until cleared with constant_torque = Vector3(0, 0, 0).
| Name | Type | Default |
|---|---|---|
torque | Vector3 | — |
ApplyCentralForcevoid
public void ApplyCentralForce(Vector3? force = default);Applies a directional force without affecting rotation. A force is time dependent and meant to be applied every physics update.
This is equivalent to using PhysicsDirectBodyState3D.ApplyForce at the body's center of mass.
| Name | Type | Default |
|---|---|---|
force | Vector3? | default |
forceIf the parameter is null, then the default value is new Vector3(0.0f, 0.0f, 0.0f).
ApplyCentralImpulsevoid
public void ApplyCentralImpulse(Vector3? impulse = default);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 "_force" functions otherwise).
This is equivalent to using PhysicsDirectBodyState3D.ApplyImpulse at the body's center of mass.
| Name | Type | Default |
|---|---|---|
impulse | Vector3? | default |
impulseIf the parameter is null, then the default value is new Vector3(0.0f, 0.0f, 0.0f).
ApplyForcevoid
public void ApplyForce(Vector3 force, Vector3? position = default);Applies a positioned force to the body. A force is time dependent and meant to be applied every physics update.
position is the offset from the body origin in global coordinates.
| Name | Type | Default |
|---|---|---|
force | Vector3 | — |
position | Vector3? | default |
positionIf the parameter is null, then the default value is new Vector3(0.0f, 0.0f, 0.0f).
ApplyImpulsevoid
public void ApplyImpulse(Vector3 impulse, Vector3? position = default);Applies a positioned impulse to the body.
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 "_force" functions otherwise).
position is the offset from the body 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).
ApplyTorquevoid
public void ApplyTorque(Vector3 torque);Applies a rotational force without affecting position. A force is time dependent and meant to be applied every physics update.
Note: PhysicsDirectBodyState3D.InverseInertia is required for this to work. To have PhysicsDirectBodyState3D.InverseInertia, an active CollisionShape3D must be a child of the node, or you can manually set PhysicsDirectBodyState3D.InverseInertia.
| Name | Type | Default |
|---|---|---|
torque | Vector3 | — |
ApplyTorqueImpulsevoid
public void ApplyTorqueImpulse(Vector3 impulse);Applies a rotational impulse to the body without affecting the position.
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 "_force" functions otherwise).
Note: PhysicsDirectBodyState3D.InverseInertia is required for this to work. To have PhysicsDirectBodyState3D.InverseInertia, an active CollisionShape3D must be a child of the node, or you can manually set PhysicsDirectBodyState3D.InverseInertia.
| Name | Type | Default |
|---|---|---|
impulse | Vector3 | — |
GetAngularVelocityVector3
public Vector3 GetAngularVelocity();Vector3GetCenterOfMassVector3
public Vector3 GetCenterOfMass();Vector3GetCenterOfMassLocalVector3
public Vector3 GetCenterOfMassLocal();Vector3GetCollisionLayeruint
public uint GetCollisionLayer();uintGetCollisionMaskuint
public uint GetCollisionMask();uintGetConstantForceVector3
public Vector3 GetConstantForce();Returns the body's total constant positional forces applied during each physics update.
See PhysicsDirectBodyState3D.AddConstantForce and PhysicsDirectBodyState3D.AddConstantCentralForce.
Vector3GetConstantTorqueVector3
public Vector3 GetConstantTorque();Returns the body's total constant rotational forces applied during each physics update.
See PhysicsDirectBodyState3D.AddConstantTorque.
Vector3GetContactColliderRid
public Rid GetContactCollider(int contactIdx);Returns the collider's Rid.
| Name | Type | Default |
|---|---|---|
contactIdx | int | — |
RidGetContactColliderIdulong
public ulong GetContactColliderId(int contactIdx);Returns the collider's object id.
| Name | Type | Default |
|---|---|---|
contactIdx | int | — |
ulongGetContactColliderObjectReckfellObject
public ReckfellObject GetContactColliderObject(int contactIdx);Returns the collider object.
| Name | Type | Default |
|---|---|---|
contactIdx | int | — |
ReckfellObjectGetContactColliderPositionVector3
public Vector3 GetContactColliderPosition(int contactIdx);Returns the position of the contact point on the collider in the global coordinate system.
| Name | Type | Default |
|---|---|---|
contactIdx | int | — |
Vector3GetContactColliderShapeint
public int GetContactColliderShape(int contactIdx);Returns the collider's shape index.
| Name | Type | Default |
|---|---|---|
contactIdx | int | — |
intGetContactColliderVelocityAtPositionVector3
public Vector3 GetContactColliderVelocityAtPosition(int contactIdx);Returns the linear velocity vector at the collider's contact point.
| Name | Type | Default |
|---|---|---|
contactIdx | int | — |
Vector3GetContactCountint
public int GetContactCount();Returns the number of contacts this body has with other bodies.
Note: By default, this returns 0 unless bodies are configured to monitor contacts. See RigidBody3D.ContactMonitor.
intGetContactImpulseVector3
public Vector3 GetContactImpulse(int contactIdx);Impulse created by the contact.
| Name | Type | Default |
|---|---|---|
contactIdx | int | — |
Vector3GetContactLocalNormalVector3
public Vector3 GetContactLocalNormal(int contactIdx);Returns the local normal at the contact point.
| Name | Type | Default |
|---|---|---|
contactIdx | int | — |
Vector3GetContactLocalPositionVector3
public Vector3 GetContactLocalPosition(int contactIdx);Returns the position of the contact point on the body in the global coordinate system.
| Name | Type | Default |
|---|---|---|
contactIdx | int | — |
Vector3GetContactLocalShapeint
public int GetContactLocalShape(int contactIdx);Returns the local shape index of the collision.
| Name | Type | Default |
|---|---|---|
contactIdx | int | — |
intGetContactLocalVelocityAtPositionVector3
public Vector3 GetContactLocalVelocityAtPosition(int contactIdx);Returns the linear velocity vector at the body's contact point.
| Name | Type | Default |
|---|---|---|
contactIdx | int | — |
Vector3GetInverseInertiaVector3
public Vector3 GetInverseInertia();Vector3GetInverseInertiaTensorBasis
public Basis GetInverseInertiaTensor();BasisGetInverseMassfloat
public float GetInverseMass();floatGetLinearVelocityVector3
public Vector3 GetLinearVelocity();Vector3GetPrincipalInertiaAxesBasis
public Basis GetPrincipalInertiaAxes();BasisGetSpaceStatePhysicsDirectSpaceState3D
public PhysicsDirectSpaceState3D GetSpaceState();Returns the current state of the space, useful for queries.
PhysicsDirectSpaceState3DGetStepfloat
public float GetStep();floatGetTotalAngularDampfloat
public float GetTotalAngularDamp();floatGetTotalGravityVector3
public Vector3 GetTotalGravity();Vector3GetTotalLinearDampfloat
public float GetTotalLinearDamp();floatGetTransformTransform3D
public Transform3D GetTransform();Transform3DGetVelocityAtLocalPositionVector3
public Vector3 GetVelocityAtLocalPosition(Vector3 localPosition);Returns the body's velocity at the given relative position.
local_position is the offset from the body origin in global coordinates.
| Name | Type | Default |
|---|---|---|
localPosition | Vector3 | — |
Vector3IntegrateForcesvoid
public void IntegrateForces();Updates the body's linear and angular velocity by applying gravity and damping for the equivalent of one physics tick.
IsSleepingbool
public bool IsSleeping();boolSetAngularVelocityvoid
public void SetAngularVelocity(Vector3 velocity);| Name | Type | Default |
|---|---|---|
velocity | Vector3 | — |
SetCollisionLayervoid
public void SetCollisionLayer(uint layer);| Name | Type | Default |
|---|---|---|
layer | uint | — |
SetCollisionMaskvoid
public void SetCollisionMask(uint mask);| Name | Type | Default |
|---|---|---|
mask | uint | — |
SetConstantForcevoid
public void SetConstantForce(Vector3 force);Sets the body's total constant positional forces applied during each physics update.
See PhysicsDirectBodyState3D.AddConstantForce and PhysicsDirectBodyState3D.AddConstantCentralForce.
| Name | Type | Default |
|---|---|---|
force | Vector3 | — |
SetConstantTorquevoid
public void SetConstantTorque(Vector3 torque);Sets the body's total constant rotational forces applied during each physics update.
See PhysicsDirectBodyState3D.AddConstantTorque.
| Name | Type | Default |
|---|---|---|
torque | Vector3 | — |
SetLinearVelocityvoid
public void SetLinearVelocity(Vector3 velocity);| Name | Type | Default |
|---|---|---|
velocity | Vector3 | — |
SetSleepStatevoid
public void SetSleepState(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetTransformvoid
public void SetTransform(Transform3D transform);| Name | Type | Default |
|---|---|---|
transform | Transform3D | — |