RigidBody3D

Inherits: PhysicsBody3D < CollisionObject3D < Node3D < Node < Object

Inherited By: VehicleBody3D

A 3D physics body that is moved by a physics simulation.

Description

RigidBody3D implements full 3D physics. It cannot be controlled directly, instead, you must apply forces to it (gravity, impulses, etc.), and the physics simulation will calculate the resulting movement, rotation, react to collisions, and affect other physics bodies in its path.

The body's behavior can be adjusted via lock_rotation, freeze, and freeze_mode. By changing various properties of the object, such as mass, you can control how the physics simulation acts on it.

A rigid body will always maintain its shape and size, even when forces are applied to it. It is useful for objects that can be interacted with in an environment, such as a tree that can be knocked over or a stack of crates that can be pushed around.

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

Note: Changing the 3D transform or linear_velocity of a RigidBody3D very often may lead to some unpredictable behaviors. If you need to directly affect the body, prefer _integrate_forces as it allows you to directly access the physics state.

Tutorials

Properties

float

angular_damp

0.0

DampMode

angular_damp_mode

0

Vector3

angular_velocity

Vector3(0, 0, 0)

bool

can_sleep

true

Vector3

center_of_mass

Vector3(0, 0, 0)

CenterOfMassMode

center_of_mass_mode

0

Vector3

constant_force

Vector3(0, 0, 0)

Vector3

constant_torque

Vector3(0, 0, 0)

bool

contact_monitor

false

bool

continuous_cd

false

bool

custom_integrator

false

bool

freeze

false

FreezeMode

freeze_mode

0

float

gravity_scale

1.0

Vector3

inertia

Vector3(0, 0, 0)

float

linear_damp

0.0

DampMode

linear_damp_mode

0

Vector3

linear_velocity

Vector3(0, 0, 0)

bool

lock_rotation

false

float

mass

1.0

int

max_contacts_reported

0

PhysicsMaterial

physics_material_override

bool

sleeping

false

Methods

void

_integrate_forces ( PhysicsDirectBodyState3D state ) virtual

void

add_constant_central_force ( Vector3 force )

void

add_constant_force ( Vector3 force, Vector3 position=Vector3(0, 0, 0) )

void

add_constant_torque ( Vector3 torque )

void

apply_central_force ( Vector3 force )

void

apply_central_impulse ( Vector3 impulse )

void

apply_force ( Vector3 force, Vector3 position=Vector3(0, 0, 0) )

void

apply_impulse (