Skip to main content

RigidBody2D

Inherits: PhysicsBody2D < CollisionObject2D < Node2D < CanvasItem < Node < Object

Description

A 2D physics body that is moved by a physics simulation. RigidBody2D implements full 2D physics. It cannot be controlled directly; instead, you must apply forces to it (gravity, impulses, etc.).

Properties

float
default:"1.0"
The body’s mass.
Vector2
default:"Vector2(0, 0)"
The body’s linear velocity in pixels per second.
float
default:"0.0"
The body’s rotational velocity in radians per second.
float
default:"1.0"
Multiplies the gravity applied to the body.
bool
default:"false"
If true, the body is frozen and forces are not applied.

Methods

apply_central_impulse

Applies a directional impulse without affecting rotation.
Vector2
The impulse vector to apply

apply_impulse

Applies a positioned impulse to the body.

apply_force

Applies a positioned force to the body.

apply_torque

Applies a rotational force without affecting position.

Signals

body_entered(body: Node)

Emitted when a body enters into contact with this one.

body_exited(body: Node)

Emitted when a body exits contact with this one.

Example Usage