Direct access object to a physics body in the PhysicsServer.
    public abstract class PhysicsDirectBodyState : Object

Provides direct access to a physics body in the PhysicsServer, allowing safe changes to physics properties. This object is passed via the direct state callback of rigid/character bodies, and is intended for changing the direct state of that body. See RigidBody._IntegrateForces(Godot.PhysicsDirectBodyState).

Inheritance Chain

Properties

    public Vector3 AngularVelocity { get; set; }

The body’s rotational velocity.

    public Vector3 CenterOfMass { get; }

    public Vector3 InverseInertia { get; }

The inverse of the inertia of the body.

    public float InverseMass { get; }

The inverse of the mass of the body.

    public Vector3 LinearVelocity { get; set; }

The body’s linear velocity.

    public Basis PrincipalInertiaAxes { get; }

    public bool Sleeping { get; set; }

If true, this body is currently sleeping (not active).

    public float Step { get; }

The timestep (delta) used for the simulation.

    public float TotalAngularDamp { get; }

The rate at which the body stops rotating, if there are not any other forces moving it.

    public Vector3 TotalGravity { get; }

The total gravity vector being currently applied to this body.

    public float TotalLinearDamp { get; }

The rate at which the body stops moving, if there are not any other forces moving it.

    public Transform Transform { get; set; }

The body’s transformation matrix.

Methods

    public void AddCentralForce(Vector3 force)

Adds a constant directional force without affecting rotation.

This is equivalent to add_force(force, Vector3(0,0,0)).

    public void AddForce(Vector3 force, Vector3 position)

Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.

    public void AddTorque(Vector3 torque)

Adds a constant rotational force without affecting position.

    public void ApplyCentralImpulse(Vector3 j)

Applies a single directional impulse without affecting rotation.

This is equivalent to apply_impulse(Vector3(0, 0, 0), impulse).

    public void ApplyImpulse(Vector3 position, Vector3 j)

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. The position uses the rotation of the global coordinate system, but is centered at the object’s origin.

    public void ApplyTorqueImpulse(Vector3 j)

Apply a torque impulse (which will be affected by the body mass and shape). This will rotate the body around the vector j passed as parameter.

    [Obsolete("GetAngularVelocity is deprecated. Use the AngularVelocity property instead.")]
    public Vector3 GetAngularVelocity()

Getter for AngularVelocity

    [Obsolete("GetCenterOfMass is deprecated. Use the CenterOfMass property instead.")]
    public Vector3 GetCenterOfMass()

Getter for CenterOfMass

    public RID GetContactCollider(int contactIdx)

Returns the collider’s RID.

    public ulong GetContactColliderId(int contactIdx)

    public Object GetContactColliderObject(int contactIdx)

Returns the collider object.

    public Vector3 GetContactColliderPosition(int contactIdx)

Returns the contact position in the collider.

    public int GetContactColliderShape(int contactIdx)

Returns the collider’s shape index.

    public Vector3 GetContactColliderVelocityAtPosition(int contactIdx)

Returns the linear velocity vector at the collider’s contact point.

    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 RigidBody.ContactMonitor.

    public float GetContactImpulse(int contactIdx)

Impulse created by the contact. Only implemented for Bullet physics.

    public Vector3 GetContactLocalNormal(int contactIdx)

Returns the local normal at the contact point.

    public Vector3 GetContactLocalPosition(int contactIdx)

Returns the local position of the contact point.

    public int GetContactLocalShape(int contactIdx)

Returns the local shape index of the collision.

    [Obsolete("GetInverseInertia is deprecated. Use the InverseInertia property instead.")]
    public Vector3 GetInverseInertia()

Getter for InverseInertia

    [Obsolete("GetInverseMass is deprecated. Use the InverseMass property instead.")]
    public float GetInverseMass()

Getter for InverseMass

    [Obsolete("GetLinearVelocity is deprecated. Use the LinearVelocity property instead.")]
    public Vector3 GetLinearVelocity()

Getter for LinearVelocity

    [Obsolete("GetPrincipalInertiaAxes is deprecated. Use the PrincipalInertiaAxes property instead.")]
    public Basis GetPrincipalInertiaAxes()

Getter for PrincipalInertiaAxes

    public PhysicsDirectSpaceState GetSpaceState()

Returns the current state of the space, useful for queries.

    [Obsolete("GetStep is deprecated. Use the Step property instead.")]
    public float GetStep()

Getter for Step

    [Obsolete("GetTotalAngularDamp is deprecated. Use the TotalAngularDamp property instead.")]
    public float GetTotalAngularDamp()

Getter for TotalAngularDamp

    [Obsolete("GetTotalGravity is deprecated. Use the TotalGravity property instead.")]
    public Vector3 GetTotalGravity()

Getter for TotalGravity

    [Obsolete("GetTotalLinearDamp is deprecated. Use the TotalLinearDamp property instead.")]
    public float GetTotalLinearDamp()

Getter for TotalLinearDamp

    [Obsolete("GetTransform is deprecated. Use the Transform property instead.")]
    public Transform GetTransform()

Getter for Transform

    public void IntegrateForces()

Calls the built-in force integration code.

    [Obsolete("IsSleeping is deprecated. Use the Sleeping property instead.")]
    public bool IsSleeping()

Getter for Sleeping

    [Obsolete("SetAngularVelocity is deprecated. Use the AngularVelocity property instead.")]
    public void SetAngularVelocity(Vector3 velocity)

Setter for AngularVelocity

    [Obsolete("SetLinearVelocity is deprecated. Use the LinearVelocity property instead.")]
    public void SetLinearVelocity(Vector3 velocity)

Setter for LinearVelocity

    [Obsolete("SetSleepState is deprecated. Use the Sleeping property instead.")]
    public void SetSleepState(bool enabled)

Setter for Sleeping

    [Obsolete("SetTransform is deprecated. Use the Transform property instead.")]
    public void SetTransform(Transform transform)

Setter for Transform

Tags: