Realot StudioDocs
Components

Collider2D

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

View as Markdownllms.txt
ScopeThis page documents the Collider2D 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 → Add Component → Collider 2D. One-way platform, trigger, shape, friction, restitution, density, layer and mask settings live here.

#What it does

Physics collision shape and contact filtering. A Collider2D is also required for accurate pointer/touch hit tests.

Component setup & editor toolsCollider2D defines the collision/trigger shape used by the physics system.

#How to add and use Collider2D

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 Collider2D → 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 → Collider 2D. After adding it, edit Shape, dimensions, Offset, Trigger, Friction, Restitution, Density, Layer, and Mask in the Collider2D section. The viewport Collider gizmo shows the collision shape.

#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
shapeColliderShape enum: Box | Circle | Capsule | TriangleBox | Circle | Capsule | Triangle.Box
widthnumberBox width.1
heightnumberBox height.1
radiusnumberCircle radius.0.5
capsuleHalfHeightnumberCapsule: a "stadium" shape (rectangle with semicircle caps) — matches Rapier's ColliderDesc.capsule(halfHeight, radius), whose principal axis is Y (i.e.0.5
capsuleRadiusnumberCapsule radius.0.3
trianglePointsarrayTriangle: 3 points in the entity's LOCAL space (same space as offsetX/offsetY), user-editable via 3 draggable gizmo handles.[{x:-0.5,y:0.5}, {x:0.5,y:0.5}, {x:0,y:-0.5}]
offsetXnumberLocal X offset.0
offsetYnumberLocal Y offset.0
rotationnumberCollider-only rotation, in degrees, applied on top of the entity's own Transform.rotation.0
isTriggerbooleanTrigger-only collider.false
isOneWayPlatformbooleanOne-way platform: solid only when the other body is landing on it from above; a body approaching from below or the side passes straight through, like a Mario/Metroidvania jump-through platform.false
oneWayDirectionOneWayDirection enum: Up | DownInspector field stored on this component.Up
frictionnumberSurface friction.0.5
restitutionnumberBounciness.0
densitynumberDensity.1
layernumberCollision layer/mask — inspired by Unity's physics layer matrix.0
maskvalueLayers this collider can interact with.0xFFFF

#Tuning behavior

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

SettingWhat changing it does
restitution0 behaves as non-bouncy; increasing it produces more bounce. Keep in a physically sensible range for predictable results.
frictionHigher values resist sliding more strongly. Lower values let contacts slide more easily.
densityAffects mass/inertia when the physics world builds the body from colliders; it is not a direct “heaviness” multiplier on gravity.
offsetX / offsetYMoves the collider relative to the entity’s pivot; positive X/right and positive Y/down in world-space convention.

#Script API

MemberKindDescription
capsuleHalfHeightProperty (read-only)Capsule half-height.
capsuleRadiusProperty (read-only)Capsule radius.
densityProperty (read-only)Density.
frictionProperty (read-only)Friction.
heightProperty (read-only)Box height.
isColliding(other)MethodThe `this.collider` sub-object exposed to user scripts.
isOneWayPlatformProperty (read-only)One-way platform flag.
isTriggerProperty (read/write)Trigger-only collider.
layerProperty (read-only)Layer index 0-15.
maskProperty (read-only)16-bit interaction mask.
offsetProperty (read-only){x,y} collider offset.
oneWayDirectionProperty (read/write)The `this.collider` sub-object exposed to user scripts.
radiusProperty (read-only)Circle radius.
restitutionProperty (read-only)Restitution.
rotationProperty (read/write)The `this.collider` sub-object exposed to user scripts.
shapeProperty (read-only)Box | Circle | Capsule | Triangle.
widthProperty (read-only)Box width.

#Notes & behavior

  • Collision layers use 16 membership layers (0-15). The mask determines which layers the collider can interact with.
  • One-way platforms are intended to block from one side while allowing traversal from the non-blocking side.

#Examples

js
this.collider.isTrigger = true;
js
this.collider.layer = 2;
js
this.collider.mask = 0xFFFF;
Need the full workflow?Components: complete workflow covers adding, configuring, testing, combining, and removing components.