Realot StudioDocs
Components

Rigidbody2D

Realot Studio Rigidbody2D component reference: fields, script API, behavior and examples.

View as Markdownllms.txt
ScopeThis page documents the Rigidbody2D component in Realot Studio. Runtime fields are serialized scene data; the Script API section lists only members intentionally exposed to game scripts.
Where to find it in the editorInspector (right) → Add Component → Rigidbody 2D. Pair with Collider 2D for a colliding body. Edit → Physics Layers… controls named layer slots.

#What it does

2D physics body backed by the engine physics runtime. Dynamic, Kinematic and Static bodies have different script controls.

Component setup & editor toolsRigidbody2D gives an entity a Rapier 2D body. Collider2D is normally paired with it when physical contact is required.

#How to add and use Rigidbody2D

Editor path: Select the target entity in the Hierarchy (left side) → look at the Inspector (right side) → click Add Component at the bottom of the Inspector → search for Rigidbody2D → click the component row. The Add Component picker is a centered modal with a search box; it only lists components not already attached.

For components with a dedicated editor tool, the tool is opened or activated from the location described below. Do not assume that adding the component alone activates its editor; some systems require a separate window, panel, or viewport tool.

#Component setup & editor tools

  • Select entity → Inspector → Add Component → Rigidbody 2D. After adding it, the Rigidbody2D section exposes body type, gravity/damping, velocity/drive values, rotation locking, and controller/ground state fields.

#What you should see after adding it

The component appears as its own section in the Inspector. Its serialized settings are listed in the Component data table below. If a field is conditional, it appears only when the relevant mode/type is selected. If a field is a runtime state field (for example grounded or resolved velocity), treat it as read-only diagnostic state unless the API reference explicitly documents it as writable.

#How to read the settings

For every setting below, the documentation distinguishes type, default, meaning, and tuning direction where behavior is known. When a value represents a direction, use the engine's coordinate convention documented in Coordinate system; do not substitute Unity/Godot conventions.

#Component data

FieldTypePurposeDefault
bodyTypeBodyType enum: Dynamic | Kinematic | StaticDynamic | Kinematic | Static.Dynamic
simulatedbooleanWhether the body participates in physics simulation.true
massnumberDynamic-only1
autoMassbooleanInspector field stored on this component.true
gravityScalenumberGravity multiplier.1
linearDampingnumberLinear damping.0
angularDampingnumberAngular damping.0
lockRotationbooleanDynamic + Kinematicfalse
velocityXnumberworking velocity — for Dynamic this is read back FROM Rapier each frame (unless driveVelocityX below is set by a controller this same frame); for Kinematic this is the velocity the caller/script sets to drive the body (consumed by PhysicsWorld as a kinematic move).0
velocityYnumberY velocity.0
angularVelocitynumberAngular velocity.0
driveVelocityXnullable valueSet (transiently, one frame at a time) by runtime/systems/ControllerSystem.js to drive a DYNAMIC body's horizontal speed via Rapier's setLinvel while leaving the Y axis (and therefore Rapier's own gravity/impulse integration) alone.null
driveVelocityYnullable valueSet (transiently, one frame) by ControllerSystem to override a DYNAMIC body's Y velocity this physics step — used both for a one-shot jump kick (Character Controller/Platformer) and for continuous Y drive (Top-Down, which has no gravity to preserve).null
driveAngularVelocitynullable valueSet (transiently, one frame) by ControllerSystem to drive a DYNAMIC body's angular velocity (e.g.null
groundedbooleanRead-only contact state: written every physics step from Rapier contact manifolds.false
resolvedVelocityXnumberKINEMATIC-only, read-only: written every physics step with the ACTUAL movement that the kinematic target-motion query resolved after blocking/sliding against obstacles.0
resolvedVelocityYnumberInspector field stored on this component.0
pendingForceXnumberDYNAMIC-only force/impulse queue: pushed by the scripting API's DynamicRigidbodyAPI (see scripting/components/RigidbodyAPI.js) via .addForce()/.addImpulse()/.addTorque() and drained by PhysicsWorld._syncEntity every physics step, exactly like driveVelocityX/Y above — plain, serializable data (RULES.txt section 4)…0
pendingForceYnumberInspector field stored on this component.0
pendingImpulseXnumberInspector field stored on this component.0
pendingImpulseYnumberInspector field stored on this component.0
pendingTorquenumberInspector field stored on this component.0
pendingAngularImpulsenumberInspector field stored on this component.0

#Tuning behavior

These are the practical direction-of-change rules for the most important controls on this component.

SettingWhat changing it does
massHigher mass makes the body harder to accelerate from the same force/impulse. It does not make gravity itself stronger.
gravityScale1 is the normal engine gravity response for Dynamic bodies; 2 doubles it; 0 disables gravity contribution.
linearDampingHigher values remove linear velocity faster; 0 leaves the body with no linear damping.
angularDampingHigher values remove rotational velocity faster.

#Automatic mass and force at a point

  • autoMass (default true): a Dynamic body computes its mass from the attached collider geometry and density. Uncheck it in the Inspector to use the mass value instead.
  • angularDamping: resistance to spinning, separate from linear damping.
  • addForceAtPoint(...) in the script API pushes the body at a world point, so it also creates torque.

#Script API

MemberKindDescription
addAngularImpulse(t)MethodThe `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
addForce(x, y)MethodThe `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
addForceAtPoint(x, y, pointX, pointY)MethodThe `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
addImpulse(x, y)MethodThe `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
addTorque(t)MethodThe `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
angularDampingProperty (read/write)Angular damping.
gravityScaleProperty (read/write)Gravity multiplier.
groundAngleProperty (read-only)The `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
groundAngleLimitProperty (read/write)The `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
groundedProperty (read-only)The `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
isGroundedProperty (read-only)The `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
isOnCeilingProperty (read-only)The `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
isOnSlopeProperty (read-only)The `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
isOnWallProperty (read-only)The `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
linearDampingProperty (read/write)Linear damping.
massProperty (read/write)Dynamic mass.
move(dx, dy)MethodThe `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
resolvedVelocityProperty (read-only)The `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
slopeMinAngleProperty (read/write)The `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).
typeProperty (read/write)Dynamic | Kinematic | Static; switching type is supported at runtime.
velocityProperty (read/write){x,y} velocity.
velocityXProperty (read/write)Horizontal velocity.
velocityYProperty (read/write)Vertical velocity.
wallAngleLimitProperty (read/write)The `this.rigidbody` sub-object exposed to user scripts (see scripting/ScriptAPI.js).

#Notes & behavior

  • Kinematic-only methods are meaningful for Kinematic bodies; Dynamic-only force methods apply to Dynamic bodies.
  • Position assignment through this.x/this.y is treated as a physics teleport target for non-static bodies.

#Examples

js
this.rigidbody.addImpulse(0, -350);
js
this.rigidbody.velocityX = 200;
js
this.rigidbody.move(100 * time.deltaTime, 0);
Need the full workflow?Components: complete workflow covers adding, configuring, testing, combining, and removing components.