Log inGet started
World

Builtin Library

Branchmain
Branchesmainpublish
Commit8d45df8664

README.md

ecs.GravityField

Spec for ecs.GravityField, which maps to the native GravityField: a pull toward a point, an axis, a surface or along a direction that every dynamic body it covers takes as its gravity inside each physics substep. The GravityField component drives it; this is the typed value the generic ecs verbs build and read.

Fields

  • shape: string?: the GravityFieldShape variant name, "Point" (toward the entity), "Axis" (toward the entity's Y axis, or a segment of it length long), "Direction" (along direction inside the box halfExtents), "Surface" (toward the nearest point of the entity's colliders), "Path" (toward the nearest point of the line through points).
  • strength: number?: the pull at radius, in m/s². Negative pushes away.
  • falloff: string?: the GravityFalloff variant name, "Constant", "Linear" (to nothing at range), "InverseSquare" (past radius) or "Curve".
  • radius: number?, range: number?: where the falloff starts, and how far the field reaches (0: everywhere).
  • halfExtents: { x, y, z }?, direction: { x, y, z }?: a direction field's box and pull, in the entity's own frame.
  • length: number?: an axis field's segment length (0: the whole line).
  • priority: number?, combine: string?: "Priority" fields of the highest priority acting at a place are its gravity; "Add" fields add on top.
  • groups: number?: the collision groups the field acts on, as a bitmask.
  • curve: { number }?: a curve falloff's distance, scale pairs one after another.
  • points: { number }?: a path field's points, x, y, z one after another, in the entity's own frame.
  • enabled: boolean?: whether the field acts.

Usage

ecs.insertSync(id, ecs.GravityField{ shape = "Point", strength = 9.81, falloff = "InverseSquare", radius = 5 })
ecs.set(id, ecs.GravityField{ enabled = false })