Builtin Library
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 itlengthlong),"Direction"(alongdirectioninside the boxhalfExtents),"Surface"(toward the nearest point of the entity's colliders),"Path"(toward the nearest point of the line throughpoints).strength: number?: the pull atradius, in m/s². Negative pushes away.falloff: string?: the GravityFalloff variant name,"Constant","Linear"(to nothing atrange),"InverseSquare"(pastradius) 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'sdistance, scalepairs one after another.points: { number }?: a path field's points,x, y, zone 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 })