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 passed in vector.

    public Vector3 GetAngularVelocity()

Getter for AngularVelocity

    public Vector3 GetCenterOfMass()

Getter for CenterOfMass

    public RID GetContactCollider(int contactIdx)

Returns the collider’s RID.

    public int GetContactColliderId(int contactIdx)

Returns the collider’s object id.

    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 that by default this returns 0 unless bodies are configured to log 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.

    public Vector3 GetInverseInertia()

Getter for InverseInertia

    public float GetInverseMass()

Getter for InverseMass

    public Vector3 GetLinearVelocity()

Getter for LinearVelocity

    public Basis GetPrincipalInertiaAxes()

Getter for PrincipalInertiaAxes

    public PhysicsDirectSpaceState GetSpaceState()

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

    public float GetStep()

Getter for Step

    public float GetTotalAngularDamp()

Getter for TotalAngularDamp

    public Vector3 GetTotalGravity()

Getter for TotalGravity

    public float GetTotalLinearDamp()

Getter for TotalLinearDamp

    public Transform GetTransform()

Getter for Transform

    public void IntegrateForces()

Calls the built-in force integration code.

    public bool IsSleeping()

Getter for Sleeping

    public void SetAngularVelocity(Vector3 velocity)

Setter for AngularVelocity

    public void SetLinearVelocity(Vector3 velocity)

Setter for LinearVelocity

    public void SetSleepState(bool enabled)

Setter for Sleeping

    public void SetTransform(Transform transform)

Setter for Transform

Tags: