BusCollision
Since 0.6
Payload of the engine-published "collision" bus event.
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
| Member | Signature | Description |
|---|---|---|
a | a: EntityHandle | |
aId | aId: string | |
b | b: EntityHandle | |
bId | bId: string | |
point | point: Vec3 | |
normal | normal: Vec3 | |
impulse | impulse: 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