Talos docs

BusCollision

Since 0.6

Payload of the engine-published "collision" bus event.

Plain text

Both sides are named rather than other, because {@link Behavior.onCollision} is called once per participant and its other is an answer only a participant can give. A subscriber to this is neither of them, so it gets a and b with their scene ids and decides for itself which one it cares about.

Signature

export interface BusCollision {
  a: EntityHandle
  aId: string
  b: EntityHandle
  bId: string
  point: Vec3
  normal: Vec3
  impulse: number
}

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

Members

MemberSignatureDescription
aa: EntityHandle
aIdaId: string
bb: EntityHandle
bIdbId: string
pointpoint: Vec3
normalnormal: Vec3
impulseimpulse: number

Example

The tested fixture fixtures/app/agent.ts.

import type { Behavior } from "@argus/api"

// Sends a nav agent to `props.target` once, then reports arrival through ctx.state so the
// test can read it without polling the crowd directly.
export default {
  init(ctx) {
    ctx.state.arrived = false
    ctx.nav?.goTo(ctx.props.target as [number, number, number])
  },
  update(ctx) {
    if (ctx.nav?.arrived) ctx.state.arrived = true
  },
} satisfies Behavior