WheelContact
Since 0.6
{@link Wheel.contact}: where the tyre touches the ground.
Signature
export interface WheelContact {
/** World space. */
point: Vec3
/** The ground's normal there, unit length. */
normal: Vec3
/** What it stands on. */
entity: EntityHandle
}
Import: import type { WheelContact } from "@argus/api"
Members
| Member | Signature | Description |
|---|---|---|
point | point: Vec3 | World space. |
normal | normal: Vec3 | The ground's normal there, unit length. |
entity | entity: EntityHandle | What it stands on. |
Example
The tested fixture fixtures/recipes/drone-search/scenes/behaviors/carrier.ts.
import type { Behavior } from "@argus/api"
/** Moves a kinematic body round `props.path` (world [x, z] points) at `props.speed` m/s, facing where it goes: the
* stand-in for a boat or a truck the drone launches from, and for the contact it looks for. */
interface Props {
path: [number, number][]
speed: number
}
interface State {
next: number
}
export default {
init(ctx) {
ctx.state.next ??= 0
},
update(ctx, dt) {
const path = ctx.props.path
const goal = path[ctx.state.next % path.length]
if (goal === undefined) return
const p = ctx.entity.position
const to: [number, number, number] = [goal[0], p[1], goal[1]]
ctx.entity.lookAt(to)
if (ctx.entity.moveToward(to, ctx.props.speed * dt)) ctx.state.next = (ctx.state.next + 1) % path.length
},
} satisfies Behavior<State, Props>