Hit
Since 0.6
Result of a raycast or shape cast.
Signature
export interface Hit {
entity: EntityHandle
point: Vec3
normal: Vec3
distance: number
}
Import: import type { Hit } from "@argus/api"
Members
| Member | Signature | Description |
|---|---|---|
entity | entity: EntityHandle | |
point | point: Vec3 | |
normal | normal: Vec3 | |
distance | distance: number |
Example
The tested fixture fixtures/host/door.ts.
import type { Behavior } from "@argus/api"
// docs/API.md, "Joints": a door on a hinge that swings open while the player is near and closes
// behind them. Typechecked by packages/api's tests.
export default {
update(ctx) {
const player = ctx.world.find("player")
const near = player !== null && ctx.entity.distanceTo(player) < 2
ctx.joint?.setMotor(near ? Math.PI / 2 : 0, { mode: "position", maxForce: 200 })
},
} satisfies Behavior