VaelisDocs
v1.0.0
Components · v1.0.0

Rigidbody2D

Vaelis 1.0.0 Rigidbody2D component reference: fields, script API, behavior and examples.

View as Markdownllms.txt
ScopeThis page documents the Rigidbody2D component in Vaelis 1.0.0. 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
bodyTypeenumDynamic | Kinematic | Static.Dynamic
simulatedbooleanWhether the body participates in physics simulation.true
massnumberDynamic body mass.1
autoMassbooleanSee the Inspector field of the same name.true
gravityScalenumberGravity multiplier.1
linearDampingnumberLinear damping.0
angularDampingnumberAngular damping.0
lockRotationbooleanPrevent rotation.false
velocityXnumberX velocity.0
velocityYnumberY velocity.0
angularVelocitynumberAngular velocity.0
driveVelocityXnumber | nullSet transiently by the engine (controller/navigation input); not an authored setting. (engine-managed runtime state)null
driveVelocityYnumber | nullSet transiently by the engine (controller/navigation input); not an authored setting. (engine-managed runtime state)null
driveAngularVelocitynumber | nullSet transiently by the engine (controller/navigation input); not an authored setting. (engine-managed runtime state)null
groundedbooleanWritten by the engine each frame; not an authored setting. (engine-managed runtime state)false
resolvedVelocityXnumberWritten by the engine each frame; not an authored setting. (engine-managed runtime state)0
resolvedVelocityYnumberWritten by the engine each frame; not an authored setting. (engine-managed runtime state)0
pendingForceXnumberWritten by the engine each frame; not an authored setting. (engine-managed runtime state)0
pendingForceYnumberWritten by the engine each frame; not an authored setting. (engine-managed runtime state)0
pendingImpulseXnumberWritten by the engine each frame; not an authored setting. (engine-managed runtime state)0
pendingImpulseYnumberWritten by the engine each frame; not an authored setting. (engine-managed runtime state)0
pendingTorquenumberWritten by the engine each frame; not an authored setting. (engine-managed runtime state)0
pendingAngularImpulsenumberWritten by the engine each frame; not an authored setting. (engine-managed runtime state)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
typePropertyDynamic | Kinematic | Static; switching type is supported at runtime.
velocityProperty{x,y} velocity.
velocityXPropertyHorizontal velocity.
velocityYPropertyVertical velocity.
massPropertyDynamic mass.
gravityScalePropertyGravity multiplier.
linearDampingPropertyLinear damping.
angularDampingPropertyAngular damping.
addForce(x,y)MethodApply force to a Dynamic body.
addImpulse(x,y)MethodApply impulse to a Dynamic body.
addTorque(t)MethodApply torque.
addAngularImpulse(t)MethodApply angular impulse.
isGroundedPropertyCurrent ground contact state.
move(dx,dy)MethodKinematic movement request.
isOnCeilingPropertyKinematic contact state.
isOnWallPropertyKinematic contact state.
isOnSlopePropertyKinematic contact state.
groundAnglePropertyKinematic ground angle.
resolvedVelocityPropertyKinematic velocity after collision resolution.
addForceAtPoint(…)MethodApplies a force at a world-space point.
groundAngleLimitPropertyMaximum angle from horizontal (degrees) that counts as walkable ground for THIS body.
groundedProperty (read-only)Deprecated alias for isGrounded — kept for compatibility with existing scripts.
slopeMinAnglePropertyMinimum groundAngle (degrees) before isOnSlope becomes true.
wallAngleLimitPropertyContacts between groundAngleLimit and this angle (degrees) are "too steep" but NOT walls.

#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.