- addCentralForce
void addCentralForce(Vector2 force)
Adds a constant directional force without affecting rotation.
- addForce
void addForce(Vector2 offset, Vector2 force)
Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.
- addTorque
void addTorque(double torque)
Adds a constant rotational force.
- applyCentralImpulse
void applyCentralImpulse(Vector2 impulse)
Applies a directional impulse without affecting rotation.
- applyImpulse
void applyImpulse(Vector2 offset, Vector2 impulse)
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
void applyTorqueImpulse(double impulse)
Applies a rotational impulse to the body.
- getAngularVelocity
double getAngularVelocity()
- getContactCollider
RID getContactCollider(long contact_idx)
Returns the collider's RID.
- getContactColliderId
long getContactColliderId(long contact_idx)
Returns the collider's object id.
- getContactColliderObject
GodotObject getContactColliderObject(long contact_idx)
Returns the collider object. This depends on how it was created (will return a scene node if such was used to create it).
- getContactColliderPosition
Vector2 getContactColliderPosition(long contact_idx)
Returns the contact position in the collider.
- getContactColliderShape
long getContactColliderShape(long contact_idx)
Returns the collider's shape index.
- getContactColliderShapeMetadata
Variant getContactColliderShapeMetadata(long contact_idx)
Returns the collided shape's metadata. This metadata is different from GodotObject.getMeta, and is set with Physics2DServer.shapeSetData.
- getContactColliderVelocityAtPosition
Vector2 getContactColliderVelocityAtPosition(long contact_idx)
Returns the linear velocity vector at the collider's contact point.
- getContactCount
long 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.contactMonitor.
- getContactLocalNormal
Vector2 getContactLocalNormal(long contact_idx)
Returns the local normal at the contact point.
- getContactLocalPosition
Vector2 getContactLocalPosition(long contact_idx)
Returns the local position of the contact point.
- getContactLocalShape
long getContactLocalShape(long contact_idx)
Returns the local shape index of the collision.
- getInverseInertia
double getInverseInertia()
- getInverseMass
double getInverseMass()
- getLinearVelocity
Vector2 getLinearVelocity()
- getSpaceState
Physics2DDirectSpaceState getSpaceState()
Returns the current state of the space, useful for queries.
- getStep
double getStep()
- getTotalAngularDamp
double getTotalAngularDamp()
- getTotalGravity
Vector2 getTotalGravity()
- getTotalLinearDamp
double getTotalLinearDamp()
- getTransform
Transform2D getTransform()
- integrateForces
void integrateForces()
Calls the built-in force integration code.
- isSleeping
bool isSleeping()
- opAssign
typeof(null) opAssign(typeof(null) n)
- opEquals
bool opEquals(Physics2DDirectBodyState other)
- opEquals
bool opEquals(typeof(null) n)
- setAngularVelocity
void setAngularVelocity(double velocity)
- setLinearVelocity
void setLinearVelocity(Vector2 velocity)
- setSleepState
void setSleepState(bool enabled)
- setTransform
void setTransform(Transform2D transform)
- toHash
size_t toHash()
- angularVelocity
double angularVelocity [@property getter]
double angularVelocity [@property setter]
The body's rotational velocity.
- inverseInertia
double inverseInertia [@property getter]
The inverse of the inertia of the body.
- inverseMass
double inverseMass [@property getter]
The inverse of the mass of the body.
- linearVelocity
Vector2 linearVelocity [@property getter]
Vector2 linearVelocity [@property setter]
The body's linear velocity.
- sleeping
bool sleeping [@property getter]
bool sleeping [@property setter]
If true, this body is currently sleeping (not active).
- step
double step [@property getter]
The timestep (delta) used for the simulation.
- totalAngularDamp
double totalAngularDamp [@property getter]
The rate at which the body stops rotating, if there are not any other forces moving it.
- totalGravity
Vector2 totalGravity [@property getter]
The total gravity vector being currently applied to this body.
- totalLinearDamp
double totalLinearDamp [@property getter]
The rate at which the body stops moving, if there are not any other forces moving it.
- transform
Transform2D transform [@property getter]
Transform2D transform [@property setter]
The body's transformation matrix.
Direct access object to a physics body in the Physics2DServer.
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._integrateForces.