Struct PhysicsDirectBodyState

Direct access object to a physics body in the PhysicsServer.

struct PhysicsDirectBodyState ;

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.

Properties

NameTypeDescription
angularVelocity[get, set] Vector3The body's rotational velocity.
centerOfMass[get] Vector3
inverseInertia[get] Vector3The inverse of the inertia of the body.
inverseMass[get] doubleThe inverse of the mass of the body.
linearVelocity[get, set] Vector3The body's linear velocity.
principalInertiaAxes[get] Basis
sleeping[get, set] boolIf true, this body is currently sleeping (not active).
step[get] doubleThe timestep (delta) used for the simulation.
totalAngularDamp[get] doubleThe rate at which the body stops rotating, if there are not any other forces moving it.
totalGravity[get] Vector3The total gravity vector being currently applied to this body.
totalLinearDamp[get] doubleThe rate at which the body stops moving, if there are not any other forces moving it.
transform[get, set] TransformThe body's transformation matrix.

Methods

NameDescription
addCentralForce Adds a constant directional force without affecting rotation. This is equivalent to add_force(force, Vector3(0,0,0)).
addForce Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.
addTorque Adds a constant rotational force without affecting position.
applyCentralImpulse Applies a single directional impulse without affecting rotation. This is equivalent to apply_impulse(Vector3(0, 0, 0), impulse).
applyImpulse 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.
applyTorqueImpulse 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.
getAngularVelocity
getCenterOfMass
getContactCollider Returns the collider's RID.
getContactColliderId Returns the collider's object id.
getContactColliderObject Returns the collider object.
getContactColliderPosition Returns the contact position in the collider.
getContactColliderShape Returns the collider's shape index.
getContactColliderVelocityAtPosition Returns the linear velocity vector at the collider's contact point.
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.
getContactImpulse Impulse created by the contact. Only implemented for Bullet physics.
getContactLocalNormal Returns the local normal at the contact point.
getContactLocalPosition Returns the local position of the contact point.
getContactLocalShape Returns the local shape index of the collision.
getInverseInertia
getInverseMass
getLinearVelocity
getPrincipalInertiaAxes
getSpaceState Returns the current state of the space, useful for queries.
getStep
getTotalAngularDamp
getTotalGravity
getTotalLinearDamp
getTransform
integrateForces Calls the built-in force integration code.
isSleeping
setAngularVelocity
setLinearVelocity
setSleepState
setTransform