Skip to content

Class: Rigidbody2DComponent ​

Unity's Rigidbody2D: puts the entity under 2D physics. Colliders on this entity and on its descendants (down to the next Rigidbody2D) form its shape. Physics2DSystem owns the body; it writes the simulated pose into the entity's world transform, and a Transform edit (a script, an animation) teleports a dynamic body or drives a kinematic one there.

Everything is in pixels and radians: positions px, velocities px/s, forces kg·px/s². Physics2DSettings.pixelsPerMeter maps them for the solver. Before the body exists (the first physics step after the component is added) velocity writes and forces are held and applied when it's created, so OnStart can launch it.

Extends ​

Constructors ​

Constructor ​

ts
new Rigidbody2DComponent(): Rigidbody2DComponent;

Returns ​

Rigidbody2DComponent

Inherited from ​

Component.constructor

Properties ​

PropertyModifierTypeDefault valueInherited from
angularDampingpublicnumberundefined-
bodyTypepublicRigidbodyType2Dundefined-
collisionDetectionpublicCollisionDetectionMode2Dundefined-
dirtypublicbooleantrueComponent.dirty
enabledpublicbooleantrueComponent.enabled
fixedRotationpublicbooleanundefined-
gravityScalepublicnumberundefined-
interpolationpublicRigidbodyInterpolation2Dundefined-
linearDampingpublicnumberundefined-
masspublicnumberundefined-
sleepModepublicRigidbodySleepMode2Dundefined-
useAutoMasspublicbooleanundefined-

Accessors ​

actualMass ​

Get Signature ​

ts
get actualMass(): number;

---- State ---- The simulated mass (kg) — mass, or the colliders' density × area with useAutoMass.

Returns ​

number


angularVelocity ​

Get Signature ​

ts
get angularVelocity(): number;

Radians per second, counter-clockwise.

Returns ​

number

Set Signature ​

ts
set angularVelocity(w): void;
Parameters ​
ParameterType
wnumber
Returns ​

void


inertia ​

Get Signature ​

ts
get inertia(): number;

Kg·px² about the body's origin.

Returns ​

number


isSimulated ​

Get Signature ​

ts
get isSimulated(): boolean;

The body exists — Play / Run is on, a 2D physics backend is set and a physics step has passed.

Returns ​

boolean


position ​

Get Signature ​

ts
get position(): PhysicsVec2;

---- Pose (world space) ---- Where the body is, in world pixels — or where it will start.

Returns ​

PhysicsVec2


rotation ​

Get Signature ​

ts
get rotation(): number;
Returns ​

number


velocity ​

Get Signature ​

ts
get velocity(): PhysicsVec2;
Returns ​

PhysicsVec2

Set Signature ​

ts
set velocity(v): void;
Parameters ​
ParameterType
vPhysicsVec2
Returns ​

void


worldCenterOfMass ​

Get Signature ​

ts
get worldCenterOfMass(): PhysicsVec2;
Returns ​

PhysicsVec2

Methods ​

AddForce() ​

ts
AddForce(
   fx, 
   fy, 
   mode?
): void;

Parameters ​

ParameterTypeDefault value
fxnumberundefined
fynumberundefined
modeForceMode2D'force'

Returns ​

void


AddForceAtPosition() ​

ts
AddForceAtPosition(
   fx, 
   fy, 
   px, 
   py, 
   mode?
): void;

At a world point — off-centre, it spins the body too.

Parameters ​

ParameterTypeDefault value
fxnumberundefined
fynumberundefined
pxnumberundefined
pynumberundefined
modeForceMode2D'force'

Returns ​

void


AddTorque() ​

ts
AddTorque(torque, mode?): void;

Counter-clockwise, kg·px²/s² (or kg·px²/s as an impulse).

Parameters ​

ParameterTypeDefault value
torquenumberundefined
modeForceMode2D'force'

Returns ​

void


GetPointVelocity() ​

ts
GetPointVelocity(x, y): PhysicsVec2;

Velocity (px/s) of a world point carried by the body.

Parameters ​

ParameterType
xnumber
ynumber

Returns ​

PhysicsVec2


IsAwake() ​

ts
IsAwake(): boolean;

Returns ​

boolean


IsSleeping() ​

ts
IsSleeping(): boolean;

Returns ​

boolean


MovePosition() ​

ts
MovePosition(x, y): void;

A kinematic body travels there over the next step, pushing what's in the way (Unity MovePosition). A dynamic body is teleported.

Parameters ​

ParameterType
xnumber
ynumber

Returns ​

void


MoveRotation() ​

ts
MoveRotation(angle): void;

Parameters ​

ParameterType
anglenumber

Returns ​

void


SetVelocity() ​

ts
SetVelocity(x, y): void;

Parameters ​

ParameterType
xnumber
ynumber

Returns ​

void


Sleep() ​

ts
Sleep(): void;

Returns ​

void


Teleport() ​

ts
Teleport(
   x, 
   y, 
   angle?
): void;

Moves the body there at once, without sweeping through what's in between.

Parameters ​

ParameterType
xnumber
ynumber
angle?number

Returns ​

void


WakeUp() ​

ts
WakeUp(): void;

Returns ​

void

© 2026 PlayAdGentic