JointMotorOptions
Since 0.6
{@link Joint.setMotor}'s options.
Unwritten ones keep the current motor's.
Signature
export interface JointMotorOptions {
mode?: JointMotorMode
maxForce?: number
stiffness?: number
damping?: number
}
Import: import type { JointMotorOptions } from "@argus/api"
Members
| Member | Signature | Description |
|---|---|---|
mode | mode?: JointMotorMode | |
maxForce | maxForce?: number | |
stiffness | stiffness?: number | |
damping | damping?: 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