Direct access object to a physics body in the Physics2DServer.
    public abstract class Physics2DDirectBodyState : Object

Direct access object to a physics body in the Physics2DServer. This object is passed via the direct state callback of rigid/character bodies, and is intended for changing the direct state of that body.

Inheritance Chain


    public float AngularVelocity { get; set; }

The angular velocity of the body.

    public float InverseInertia { get; }

The inverse of the inertia of the body.

    public float InverseMass { get; }

The inverse of the mass of the body.

    public Vector2 LinearVelocity { get; set; }

The linear velocity of the body.

    public bool Sleeping { get; set; }

true if 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 Vector2 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 Transform2D Transform { get; set; }

The transformation matrix of the body.


    public void AddCentralForce(Vector2 force)

    public void AddForce(Vector2 offset, Vector2 force)

    public void AddTorque(float torque)

    public void ApplyCentralImpulse(Vector2 impulse)

    public void ApplyImpulse(Vector2 offset, Vector2 impulse)

    public void ApplyTorqueImpulse(float impulse)

    public float GetAngularVelocity()

Getter for AngularVelocity

    public RID GetContactCollider(int contactIdx)

Return the RID of the collider.

    public int GetContactColliderId(int contactIdx)

Return the object id of the collider.

    public Object GetContactColliderObject(int contactIdx)

Return the collider object, this depends on how it was created (will return a scene node if such was used to create it).

    public Vector2 GetContactColliderPosition(int contactIdx)

Return the contact position in the collider.

    public int GetContactColliderShape(int contactIdx)

Return the collider shape index.

    public object GetContactColliderShapeMetadata(int contactIdx)

Return the metadata of the collided shape. This metadata is different from Object.GetMeta(string), and is set with Physics2DServer.ShapeSetData(Godot.RID, object).

    public Vector2 GetContactColliderVelocityAtPosition(int contactIdx)

Return the linear velocity vector at contact point of the collider.

    public int GetContactCount()

Return the amount of contacts this body has with other bodies. Note that by default this returns 0 unless bodies are configured to log contacts.

    public Vector2 GetContactLocalNormal(int contactIdx)

Return the local normal (of this body) of the contact point.

    public Vector2 GetContactLocalPosition(int contactIdx)

Return the local position (of this body) of the contact point.

    public int GetContactLocalShape(int contactIdx)

Return the local shape index of the collision.

    public float GetInverseInertia()

Getter for InverseInertia

    public float GetInverseMass()

Getter for InverseMass

    public Vector2 GetLinearVelocity()

Getter for LinearVelocity

    public Physics2DDirectSpaceState GetSpaceState()

Return the current state of space, useful for queries.

    public float GetStep()

Getter for Step

    public float GetTotalAngularDamp()

Getter for TotalAngularDamp

    public Vector2 GetTotalGravity()

Getter for TotalGravity

    public float GetTotalLinearDamp()

Getter for TotalLinearDamp

    public Transform2D GetTransform()

Getter for Transform

    public void IntegrateForces()

Call the built-in force integration code.

    public bool IsSleeping()

Getter for Sleeping

    public void SetAngularVelocity(float velocity)

Setter for AngularVelocity

    public void SetLinearVelocity(Vector2 velocity)

Setter for LinearVelocity

    public void SetSleepState(bool enabled)

Setter for Sleeping

    public void SetTransform(Transform2D transform)

Setter for Transform