VaelisDocs
v1.0.0
Components · v1.0.0

Collider2D

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

View as Markdownllms.txt
ScopeThis page documents the Collider2D 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 → 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
shapeenumBox | Circle | Capsule | Triangle.Box
widthnumberBox width.1
heightnumberBox height.1
radiusnumberCircle radius.0.5
capsuleHalfHeightnumberCapsule half-height.0.5
capsuleRadiusnumberCapsule radius.0.3
trianglePoints3 pointsTriangle vertices in local space.[{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
isTriggerbooleanTrigger-only collider.false
isOneWayPlatformbooleanOne-way platform behavior.false
frictionnumberSurface friction.0.5
restitutionnumberBounciness.0
densitynumberDensity.1
layer0-15Collision layer.0
mask16-bit maskLayers 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
shapePropertyBox | Circle | Capsule | Triangle.
widthPropertyBox width.
heightPropertyBox height.
radiusPropertyCircle radius.
capsuleHalfHeightPropertyCapsule half-height.
capsuleRadiusPropertyCapsule radius.
offsetProperty{x,y} collider offset.
isTriggerPropertyTrigger-only collider.
isOneWayPlatformPropertyOne-way platform flag.
frictionPropertyFriction.
restitutionPropertyRestitution.
densityPropertyDensity.
layerPropertyLayer index 0-15.
maskProperty16-bit interaction mask.
isCollidingPropertyRead-only contact state.

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