Struct Physics2DDirectBodyState
Direct access object to a physics body in the Physics2DServer
.
struct Physics2DDirectBodyState
;
Provides direct access to a physics body in the Physics2DServer
, 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 RigidBody2D
.
Properties
Name | Type | Description |
---|---|---|
angularVelocity [get, set]
|
double | The body's rotational velocity. |
inverseInertia [get]
|
double | The inverse of the inertia of the body. |
inverseMass [get]
|
double | The inverse of the mass of the body. |
linearVelocity [get, set]
|
Vector2 | The body's linear velocity. |
sleeping [get, set]
|
bool | If true , this body is currently sleeping (not active).
|
step [get]
|
double | The timestep (delta) used for the simulation. |
totalAngularDamp [get]
|
double | The rate at which the body stops rotating, if there are not any other forces moving it. |
totalGravity [get]
|
Vector2 | The total gravity vector being currently applied to this body. |
totalLinearDamp [get]
|
double | The rate at which the body stops moving, if there are not any other forces moving it. |
transform [get, set]
|
Transform2D | The body's transformation matrix. |
Methods
Name | Description |
---|---|
addCentralForce
|
Adds a constant directional force without affecting rotation. |
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. |
applyCentralImpulse
|
Applies a directional impulse without affecting rotation. |
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 (use the "force" functions otherwise). The offset uses the rotation of the global coordinate system, but is centered at the object's origin. |
applyTorqueImpulse
|
Applies a rotational impulse to the body. |
getAngularVelocity
|
|
getContactCollider
|
Returns the collider's RID .
|
getContactColliderId
|
Returns the collider's object id. |
getContactColliderObject
|
Returns the collider object. This depends on how it was created (will return a scene node if such was used to create it). |
getContactColliderPosition
|
Returns the contact position in the collider. |
getContactColliderShape
|
Returns the collider's shape index. |
getContactColliderShapeMetadata
|
Returns the collided shape's metadata. This metadata is different from GodotObject , and is set with Physics2DServer .
|
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 RigidBody2D .
|
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
|
|
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
|