Provides direct access to a physics body in the godot.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 godot.RigidBody._IntegrateForces
.
Variables
angularVelocity:Vector3
The body's rotational velocity in axis-angle format. The magnitude of the vector is the rotation rate in radians per second.
read onlytotalAngularDamp:Single
The rate at which the body stops rotating, if there are not any other forces moving it.
read onlytotalLinearDamp:Single
The rate at which the body stops moving, if there are not any other forces moving it.
Methods
addCentralForce(force:Vector3):Void
Adds a constant directional force without affecting rotation.
This is equivalent to add_force(force, Vector3(0,0,0))
.
addForce(force:Vector3, position:Vector3):Void
Adds a positioned force to the body. Both the force and the offset from the body origin are in global coordinates.
applyCentralImpulse(j:Vector3):Void
Applies a single directional impulse without affecting rotation.
This is equivalent to apply_impulse(Vector3(0, 0, 0), impulse)
.
applyImpulse(position:Vector3, j:Vector3):Void
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(j:Vector3):Void
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.
getContactColliderVelocityAtPosition(contactIdx:Int):Vector3
Returns the linear velocity vector at the collider's contact point.
getContactCount():Int
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 godot.RigidBody.contactMonitor
.
getContactImpulse(contactIdx:Int):Single
Impulse created by the contact. Only implemented for Bullet physics.
getVelocityAtLocalPosition(localPosition:Vector3):Vector3
Returns the body's velocity at the given relative position, including both translation and rotation.