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 may result in 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 function. See CustomIntegrator.

Inheritance Chain

Derived Classes

Constructors

    public RigidBody()

Signals

    "body_entered" (Node 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" (Node 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, Node 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, Node 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; }

Lock the body’s rotation in the X axis.

    public bool AxisLockAngularY { get; set; }

Lock the body’s rotation in the Y axis.

    public bool AxisLockAngularZ { get; set; }

Lock the body’s rotation in the Z axis.

    public bool AxisLockLinearX { get; set; }

Lock the body’s movement in the X axis.

    public bool AxisLockLinearY { get; set; }

Lock the body’s movement in the Y axis.

    public bool AxisLockLinearZ { get; set; }

Lock the body’s movement in the Z axis.

    public float Bounce { get; set; }

The body’s bounciness. Values range from 0 (no bounce) to 1 (full bounciness).

Deprecated, use PhysicsMaterial.Bounce instead via PhysicsMaterialOverride.

    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 fewer 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’s friction, from 0 (frictionless) to 1 (max friction).

Deprecated, use PhysicsMaterial.Friction instead via PhysicsMaterialOverride.

    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. For example, 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; }

The body’s linear damp. Cannot be less than -1.0. If this value is different from -1.0, any linear damp derived from the world or areas will be overridden.

    public Vector3 LinearVelocity { get; set; }

The body’s linear velocity. Can be used sporadically, but don’t set this 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; }

The body’s mass.

    public ModeEnum Mode { get; set; }

The body mode. See Mode for possible values.

    public PhysicsMaterial PhysicsMaterialOverride { get; set; }

    public bool Sleeping { get; set; }

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

    public float Weight { get; set; }

The body’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 the CustomIntegrator property allows you to disable the default behavior and do fully custom force integration for a body.

    public void AddCentralForce(Vector3 force)

Adds a constant directional force without affecting rotation.

This is equivalent to add_force(force, Vector3(0,0,0)).

    public void AddForce(Vector3 force, Vector3 position)

Adds a constant force (i.e. acceleration).

    public void AddTorque(Vector3 torque)

Adds a constant rotational force (i.e. a motor) without affecting position.

    public void ApplyCentralImpulse(Vector3 impulse)

Applies a directional impulse without affecting rotation.

This is equivalent to apply_impulse(Vector3(0,0,0), impulse).

    public void ApplyImpulse(Vector3 position, Vector3 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. The position uses the rotation of the global coordinate system, but is centered at the object’s origin.

    public void ApplyTorqueImpulse(Vector3 impulse)

Applies a torque impulse which will be affected by the body mass and shape. This will rotate the body around the impulse vector passed.

    [Obsolete("GetAngularDamp is deprecated. Use the AngularDamp property instead.")]
    public float GetAngularDamp()

Getter for AngularDamp

    [Obsolete("GetAngularVelocity is deprecated. Use the AngularVelocity property instead.")]
    public Vector3 GetAngularVelocity()

Getter for AngularVelocity

    [Obsolete("GetAxisLock is deprecated. Use the AxisLockAngularZ property instead.")]
    public bool GetAxisLock(PhysicsServer.BodyAxis axis)

    [Obsolete("GetBounce is deprecated. Use the Bounce property instead.")]
    public float GetBounce()

Getter for Bounce

    public Godot.Collections.Array GetCollidingBodies()

Returns a list of the bodies colliding with this one. By default, number of max contacts reported is at 0, see the ContactsReported property to increase it.

Note: 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.

    [Obsolete("GetFriction is deprecated. Use the Friction property instead.")]
    public float GetFriction()

Getter for Friction

    [Obsolete("GetGravityScale is deprecated. Use the GravityScale property instead.")]
    public float GetGravityScale()

Getter for GravityScale

    [Obsolete("GetLinearDamp is deprecated. Use the LinearDamp property instead.")]
    public float GetLinearDamp()

Getter for LinearDamp

    [Obsolete("GetLinearVelocity is deprecated. Use the LinearVelocity property instead.")]
    public Vector3 GetLinearVelocity()

Getter for LinearVelocity

    [Obsolete("GetMass is deprecated. Use the Mass property instead.")]
    public float GetMass()

Getter for Mass

    [Obsolete("GetMaxContactsReported is deprecated. Use the ContactsReported property instead.")]
    public int GetMaxContactsReported()

Getter for ContactsReported

    [Obsolete("GetMode is deprecated. Use the Mode property instead.")]
    public ModeEnum GetMode()

Getter for Mode

    [Obsolete("GetPhysicsMaterialOverride is deprecated. Use the PhysicsMaterialOverride property instead.")]
    public PhysicsMaterial GetPhysicsMaterialOverride()

Getter for PhysicsMaterialOverride

    [Obsolete("GetWeight is deprecated. Use the Weight property instead.")]
    public float GetWeight()

Getter for Weight

    [Obsolete("IsAbleToSleep is deprecated. Use the CanSleep property instead.")]
    public bool IsAbleToSleep()

Getter for CanSleep

    [Obsolete("IsContactMonitorEnabled is deprecated. Use the ContactMonitor property instead.")]
    public bool IsContactMonitorEnabled()

Getter for ContactMonitor

    [Obsolete("IsSleeping is deprecated. Use the Sleeping property instead.")]
    public bool IsSleeping()

Getter for Sleeping

    [Obsolete("IsUsingContinuousCollisionDetection is deprecated. Use the ContinuousCd property instead.")]
    public bool IsUsingContinuousCollisionDetection()

Getter for ContinuousCd

    [Obsolete("IsUsingCustomIntegrator is deprecated. Use the CustomIntegrator property instead.")]
    public bool IsUsingCustomIntegrator()

Getter for CustomIntegrator

    [Obsolete("SetAngularDamp is deprecated. Use the AngularDamp property instead.")]
    public void SetAngularDamp(float angularDamp)

Setter for AngularDamp

    [Obsolete("SetAngularVelocity is deprecated. Use the AngularVelocity property instead.")]
    public void SetAngularVelocity(Vector3 angularVelocity)

Setter for AngularVelocity

    [Obsolete("SetAxisLock is deprecated. Use the AxisLockAngularZ property instead.")]
    public void SetAxisLock(PhysicsServer.BodyAxis axis, bool @lock)

    public void SetAxisVelocity(Vector3 axisVelocity)

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

    [Obsolete("SetBounce is deprecated. Use the Bounce property instead.")]
    public void SetBounce(float bounce)

Setter for Bounce

    [Obsolete("SetCanSleep is deprecated. Use the CanSleep property instead.")]
    public void SetCanSleep(bool ableToSleep)

Setter for CanSleep

    [Obsolete("SetContactMonitor is deprecated. Use the ContactMonitor property instead.")]
    public void SetContactMonitor(bool enabled)

Setter for ContactMonitor

    [Obsolete("SetFriction is deprecated. Use the Friction property instead.")]
    public void SetFriction(float friction)

Setter for Friction

    [Obsolete("SetGravityScale is deprecated. Use the GravityScale property instead.")]
    public void SetGravityScale(float gravityScale)

Setter for GravityScale

    [Obsolete("SetLinearDamp is deprecated. Use the LinearDamp property instead.")]
    public void SetLinearDamp(float linearDamp)

Setter for LinearDamp

    [Obsolete("SetLinearVelocity is deprecated. Use the LinearVelocity property instead.")]
    public void SetLinearVelocity(Vector3 linearVelocity)

Setter for LinearVelocity

    [Obsolete("SetMass is deprecated. Use the Mass property instead.")]
    public void SetMass(float mass)

Setter for Mass

    [Obsolete("SetMaxContactsReported is deprecated. Use the ContactsReported property instead.")]
    public void SetMaxContactsReported(int amount)

Setter for ContactsReported

    [Obsolete("SetMode is deprecated. Use the Mode property instead.")]
    public void SetMode(ModeEnum mode)

Setter for Mode

    [Obsolete("SetPhysicsMaterialOverride is deprecated. Use the PhysicsMaterialOverride property instead.")]
    public void SetPhysicsMaterialOverride(PhysicsMaterial physicsMaterialOverride)

Setter for PhysicsMaterialOverride

    [Obsolete("SetSleeping is deprecated. Use the Sleeping property instead.")]
    public void SetSleeping(bool sleeping)

Setter for Sleeping

    [Obsolete("SetUseContinuousCollisionDetection is deprecated. Use the ContinuousCd property instead.")]
    public void SetUseContinuousCollisionDetection(bool enable)

Setter for ContinuousCd

    [Obsolete("SetUseCustomIntegrator is deprecated. Use the CustomIntegrator property instead.")]
    public void SetUseCustomIntegrator(bool enable)

Setter for CustomIntegrator

    [Obsolete("SetWeight is deprecated. Use the Weight property instead.")]
    public void SetWeight(float weight)

Setter for Weight

Inner Types

ModeEnum

Name Value Description
Rigid 0 Rigid body mode. 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 mode. This behaves like a rigid body, but can not rotate.
Kinematic 3 Kinematic body mode. The body behaves like a [KinematicBody], and can only move by user code.
Tags: