Log inGet started
Package

EcsCollider.module

Newest version

This package holds more than this page lists. See all of its files in its world.

README.md

ecs.Collider

Component spec for ecs.Collider, which maps to the native Collider — an entity's collision shape. The constructor ecs.Collider{...} builds a value the generic ecs verbs (ecs.insert / ecs.set / ecs.get) apply. size and heightfieldExtent are single Vec3 fields; children (compound shapes) and heights (heightfield grid) are arrays — all pass through verbatim.

Fields

  • shape: string? — "Box" | "Sphere" | "Capsule" | "Compound" | "Heightfield" | ...
  • size: { number }?
  • isTrigger: boolean?
  • friction: number?
  • restitution: number?
  • rollingResistance: number?: a body rolling on the surface loses speed at this many times its normal acceleration (g on level ground).
  • spinningResistance: number?: the same for a body spinning on it about the contact normal.
  • surface: string?: the surface the collider names (Physics.defineSurface); a defined surface gives it its coefficients, and contacts and casts report the name. Empty names none.
  • surfaceLayers: { string }?: a heightfield's surfaces, indexed by surfaceMap.
  • surfaceMap: { number }?: a heightfield's zero-based index into surfaceLayers per height sample, row-major as heights; a contact or cast on the field names the layer of the sample nearest the point.
  • oneWay: { number }?: the direction, in the collider's own frame, bodies pass through it along; a body meeting it from that side stands on it. Zero blocks from every side.
  • surfaceVelocity: { number }?: the velocity, m/s in the collider's own frame, its surface moves at along itself (a conveyor belt). Zero holds it still.
  • contactTag: string?: the tag the world's contact filter (Physics.setContactFilter) reads it by. Empty names none.
  • name: string?
  • children: { EcsColliderChild }? — compound child shapes.
  • heights: { number }? — heightfield grid samples.
  • heightfieldExtent: { number }?

Types

  • EcsColliderChild = { shape: string, size: { number }, offset: { number }? }

Usage

ecs.insert(id, ecs.Collider{ shape = "Box", size = { 2, 4, 0.2 } })