TrackTrigger
TrackTrigger marks a region of a track in track coordinates and reports a TrackMover that rides through it. A rock’s hit box, a coin, and a finish line across the whole width are each one. Unreal calls this a trigger volume, Godot an Area3D, and Roblox fires Touched. Those three test a physics body, and a mover has none, so the step tests the mover’s own coordinates instead.
Its props are in TrackTriggerProps.
The region
Section titled “The region”The region is a box in track coordinates:
startandend: metres along the centerline.leftandright: metres across, positive to the right of travel.bottomandtop: metres above the surface, against the mover’sheight. A mover that jumps higher thantopclears the region.
A bound left out is open, so a finish line names only start and end. The test reads the mover’s point and not its size: to hit a rider a metre wide, pad the region by half a metre each side. One report covers every mover, so a second mover entering while the first stands in the region is not an entry. Only a mover on the trigger’s own track counts.
What it reports
Section titled “What it reports”The step writes the report on the entity’s TrackTriggerTrait:
inside: a mover stands in the region.entered: true on the step a mover came in while none stood in the region, and false after.exited: true on the step the last mover left.
A fast mover can pass a thin region inside one step. The test covers the ground the mover’s speed carried it over during the step, so that pass reports both entered and exited on one step, with inside false. Setting a mover’s distance moves it without passing the ground between, so a reset to the start enters nothing on the way back. Across and up, the test reads where the step ended.
A trigger marked lap counts a lap of the mounted Round on each entry.
A game’s system that runs after the move reads entered to act once per pass. A rider sits inside a rock’s box for several steps, and entered fires on the first of them only. The report is data, so a headless test steps a course and reads it without a screen.
Where it runs
Section titled “Where it runs”Client. The test runs in the step’s move block, straight after the move, on the coordinates it wrote. What an entry does, such as a stun, a coin or a finish, is the game’s own system.
import { Entity, Track, TrackTrigger } from "@daniel-zarinski/engine";
const run = new Track([ { x: 0, y: 0, z: 0, width: 6 }, { x: 0, y: -10, z: -80, width: 6 },]);
export function Course() { return ( <> {/* A rock 40 m down, a metre wide, cleared by a jump over 0.4 m. */} <Entity name="Rock"> <TrackTrigger track={run} start={39.5} end={40.5} left={-1} right={1} top={0.4} /> </Entity> {/* The finish: the last 10 m, across the whole width. */} <Entity name="Finish"> <TrackTrigger track={run} start={70} end={80} /> </Entity> </> );}