VehicleWater
Since 0.7
{@link Vehicle.water}: a watercraft's or an amphibious vehicle's water handling, as of the last tick.
ts // Spray from the bow at speed, and a thump when the hull slams back down. update(ctx) { const w = ctx.vehicle?.water if (!w) return if (w.bowWet && w.speed > 6) ctx.hud.set("spray", Math.round(w.speed)) if (w.slam > 0) ctx.log("slam", w.slam) }
Signature
export interface VehicleWater {
/** Forward speed relative to the water under the hull, m/s; negative going astern. */
readonly speed: number
/** How far onto the plane the hull is, 0..1. */
readonly planing: number
/** The hull's submerged share, 0..1. */
readonly immersion: number
/** How much of the handling is the water's, 0..1: 1 afloat, 0 on its wheels. */
readonly blend: number
/** True while it is upside down or on its side (tilted past about 100°), until it is back within 60° of upright. */
readonly capsized: boolean
/** The bow, world space. */
readonly bow: Vec3
/** Whether the bow is under the surface. */
readonly bowWet: boolean
/** Whether any thruster is in the water. */
readonly sternWet: boolean
/** Total thrust applied, newtons, negative in reverse. */
readonly thrust: number
/** The downward speed, m/s, of the hull hitting the water on this tick; 0 on every other tick. */
readonly slam: number
/** Slams since the vehicle was built. */
readonly slams: number
}
Import: import type { VehicleWater } from "@argus/api"
Members
| Member | Signature | Description |
|---|---|---|
speed | readonly speed: number | Forward speed relative to the water under the hull, m/s; negative going astern. |
planing | readonly planing: number | How far onto the plane the hull is, 0..1. |
immersion | readonly immersion: number | The hull's submerged share, 0..1. |
blend | readonly blend: number | How much of the handling is the water's, 0..1: 1 afloat, 0 on its wheels. |
capsized | readonly capsized: boolean | True while it is upside down or on its side (tilted past about 100°), until it is back within 60° of upright. |
bow | readonly bow: Vec3 | The bow, world space. |
bowWet | readonly bowWet: boolean | Whether the bow is under the surface. |
sternWet | readonly sternWet: boolean | Whether any thruster is in the water. |
thrust | readonly thrust: number | Total thrust applied, newtons, negative in reverse. |
slam | readonly slam: number | The downward speed, m/s, of the hull hitting the water on this tick; 0 on every other tick. |
slams | readonly slams: number | Slams since the vehicle was built. |
Example
The tested fixture fixtures/app/nudge.ts.
import type { Behavior } from "@argus/api"
// The behavior the allocation and scale benchmarks run: one primitive call per tick and
// nothing else. `translate` is a Rust call, so what this measures on the Rust side is the
// bridge, not the script — which is the point of SPEC's "orchestration, not compute" rule.
export default {
init(ctx) {
ctx.state.ticks = 0
},
update(ctx, dt) {
ctx.state.ticks = (ctx.state.ticks as number) + 1
ctx.entity.translate([0, 0, (ctx.props.speed as number) * dt])
},
} satisfies Behavior