Talos docs

Hit

Since 0.6

Result of a raycast or shape cast.

Plain text

Signature

export interface Hit {
  entity: EntityHandle
  point: Vec3
  normal: Vec3
  distance: number
}

Import: import type { Hit } from "@argus/api"

Members

MemberSignatureDescription
entityentity: EntityHandle
pointpoint: Vec3
normalnormal: Vec3
distancedistance: 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