Physics Body whose position is determined through physics simulation in 3D space.
    public class RigidBody : PhysicsBody

This is the node that implements full 3D physics. This means that you do not control a RigidBody directly. Instead you can apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, collision, bouncing, rotating, etc.

A RigidBody has 4 behavior Modes: Rigid, Static, Character, and Kinematic.

Note: Don’t change a RigidBody’s position every frame or very often. Sporadic changes work fine, but physics runs at a different granularity (fixed hz) than usual rendering (process callback) and maybe even in a separate thread, so changing this from a process loop will yield strange behavior. If you need to directly affect the body’s state, use _IntegrateForces(Godot.PhysicsDirectBodyState), which allows you to directly access the physics state.

If you need to override the default physics behavior, you can write a custom force integration. See CustomIntegrator.

Inheritance Chain

Derived Classes

Constructors

    public RigidBody()

Signals

    "body_entered" (Object body)

Emitted when a body enters into contact with this one. Contact monitor and contacts reported must be enabled for this to work.

    "body_exited" (Object body)

Emitted when a body shape exits contact with this one. Contact monitor and contacts reported must be enabled for this to work.

    "body_shape_entered" (int body_id, Object body, int body_shape, int local_shape)

Emitted when a body enters into contact with this one. Contact monitor and contacts reported must be enabled for this to work.

This signal not only receives the body that collided with this one, but also its RID (body_id), the shape index from the colliding body (body_shape), and the shape index from this body (local_shape) the other body collided with.

    "body_shape_exited" (int body_id, Object body, int body_shape, int local_shape)

Emitted when a body shape exits contact with this one. Contact monitor and contacts reported must be enabled for this to work.

This signal not only receives the body that stopped colliding with this one, but also its RID (body_id), the shape index from the colliding body (body_shape), and the shape index from this body (local_shape) the other body stopped colliding with.

    "sleeping_state_changed" ()

Emitted when the body changes its sleeping state. Either by sleeping or waking up.

Properties

    public float AngularDamp { get; set; }

Damps RigidBody’s rotational forces.

    public Vector3 AngularVelocity { get; set; }

RigidBody’s rotational velocity.

    public bool AxisLockAngularX { get; set; }

    public bool AxisLockAngularY { get; set; }

    public bool AxisLockAngularZ { get; set; }

    public bool AxisLockLinearX { get; set; }

    public bool AxisLockLinearY { get; set; }

    public bool AxisLockLinearZ { get; set; }

    public float Bounce { get; set; }

RigidBody’s bounciness.

    public bool CanSleep { get; set; }

If true the RigidBody will not calculate forces and will act as a static body while there is no movement. It will wake up when forces are applied through other collisions or when the apply_impulse method is used.

    public bool ContactMonitor { get; set; }

If true, the RigidBody will emit signals when it collides with another RigidBody.

    public int ContactsReported { get; set; }

The maximum contacts to report. Bodies can keep a log of the contacts with other bodies, this is enabled by setting the maximum amount of contacts reported to a number greater than 0.

    public bool ContinuousCd { get; set; }

If true continuous collision detection is used.

Continuous collision detection tries to predict where a moving body will collide, instead of moving it and correcting its movement if it collided. Continuous collision detection is more precise, and misses less impacts by small, fast-moving objects. Not using continuous collision detection is faster to compute, but can miss small, fast-moving objects.

    public bool CustomIntegrator { get; set; }

If true internal force integration will be disabled (like gravity or air friction) for this body. Other than collision response, the body will only move as determined by the _IntegrateForces(Godot.PhysicsDirectBodyState) function, if defined.

    public float Friction { get; set; }

The body friction, from 0 (frictionless) to 1 (max friction).

    public float GravityScale { get; set; }

This is multiplied by the global 3D gravity setting found in “Project > Project Settings > Physics > 3d” to produce RigidBody’s gravity. E.g. a value of 1 will be normal gravity, 2 will apply double gravity, and 0.5 will apply half gravity to this object.

    public float LinearDamp { get; set; }

RigidBody’s linear damp. Default value: -1, cannot be less than -1. If this value is different from -1, any linear damp derived from the world or areas will be overridden.

    public Vector3 LinearVelocity { get; set; }

RigidBody’s linear velocity. Can be used sporadically, but DON’T SET THIS IN EVERY FRAME, because physics may run in another thread and runs at a different granularity. Use _IntegrateForces(Godot.PhysicsDirectBodyState) as your process loop for precise control of the body state.

    public float Mass { get; set; }

RigidBody’s mass.

    public ModeEnum Mode { get; set; }

The body mode from the MODE_* enum. Modes include: MODE_STATIC, MODE_KINEMATIC, MODE_RIGID, and MODE_CHARACTER.

    public bool Sleeping { get; set; }

If true RigidBody is sleeping and will not calculate forces until woken up by a collision or the apply_impulse method.

    public float Weight { get; set; }

RigidBody’s weight based on its mass and the global 3D gravity. Global values are set in “Project > Project Settings > Physics > 3d”.

Methods

    public virtual void _IntegrateForces(PhysicsDirectBodyState state)

Called during physics processing, allowing you to read and safely modify the simulation state for the object. By default it works in addition to the usual physics behavior, but SetUseCustomIntegrator(bool) allows you to disable the default behavior and do fully custom force integration for a body.

    public void ApplyImpulse(Vector3 position, Vector3 impulse)

Apply a positioned impulse (which will be affected by the body mass and shape). This is the equivalent of hitting a billiard ball with a cue: a force that is applied once, and only once. Both the impulse and the position are in global coordinates, and the position is relative to the object’s origin.

    public float GetAngularDamp()

Getter for AngularDamp

    public Vector3 GetAngularVelocity()

Getter for AngularVelocity

    public bool GetAxisLock(PhysicsServer.BodyAxis axis)

    public float GetBounce()

Getter for Bounce

    public object[] GetCollidingBodies()

Return a list of the bodies colliding with this one. By default, number of max contacts reported is at 0 , see SetMaxContactsReported(int) to increase it. Note that the result of this test is not immediate after moving objects. For performance, list of collisions is updated once per frame and before the physics step. Consider using signals instead.

    public float GetFriction()

Getter for Friction

    public float GetGravityScale()

Getter for GravityScale

    public float GetLinearDamp()

Getter for LinearDamp

    public Vector3 GetLinearVelocity()

Getter for LinearVelocity

    public float GetMass()

Getter for Mass

    public int GetMaxContactsReported()

Getter for ContactsReported

    public ModeEnum GetMode()

Getter for Mode

    public float GetWeight()

Getter for Weight

    public bool IsAbleToSleep()

Getter for CanSleep

    public bool IsContactMonitorEnabled()

Getter for ContactMonitor

    public bool IsSleeping()

Getter for Sleeping

    public bool IsUsingContinuousCollisionDetection()

Getter for ContinuousCd

    public bool IsUsingCustomIntegrator()

Getter for CustomIntegrator

    public void SetAngularDamp(float angularDamp)

Setter for AngularDamp

    public void SetAngularVelocity(Vector3 angularVelocity)

Setter for AngularVelocity

    public void SetAxisLock(PhysicsServer.BodyAxis axis, bool @lock)

    public void SetAxisVelocity(Vector3 axisVelocity)

Set an axis velocity. The velocity in the given vector axis will be set as the given vector length. This is useful for jumping behavior.

    public void SetBounce(float bounce)

Setter for Bounce

    public void SetCanSleep(bool ableToSleep)

Setter for CanSleep

    public void SetContactMonitor(bool enabled)

Setter for ContactMonitor

    public void SetFriction(float friction)

Setter for Friction

    public void SetGravityScale(float gravityScale)

Setter for GravityScale

    public void SetLinearDamp(float linearDamp)

Setter for LinearDamp

    public void SetLinearVelocity(Vector3 linearVelocity)

Setter for LinearVelocity

    public void SetMass(float mass)

Setter for Mass

    public void SetMaxContactsReported(int amount)

Setter for ContactsReported

    public void SetMode(ModeEnum mode)

Setter for Mode

    public void SetSleeping(bool sleeping)

Setter for Sleeping

    public void SetUseContinuousCollisionDetection(bool enable)

Setter for ContinuousCd

    public void SetUseCustomIntegrator(bool enable)

Setter for CustomIntegrator

    public void SetWeight(float weight)

Setter for Weight

Inner Types

ModeEnum

Name Value Description
Rigid 0 Rigid body. This is the “natural” state of a rigid body. It is affected by forces, and can move, rotate, and be affected by user code.
Static 1 Static mode. The body behaves like a [StaticBody], and can only move by user code.
Character 2 Character body. This behaves like a rigid body, but can not rotate.
Kinematic 3 Kinematic body. The body behaves like a [KinematicBody], and can only move by user code.
Tags: