Talos docs

JointMotorState

Since 0.6

{@link Joint.motor}, as it stands.

Plain text

Signature

export interface JointMotorState {
  mode: JointMotorMode
  /** rad/s or m/s (velocity); radians or metres from the joint's rest pose (position). */
  target: number
  /** The most the motor pushes: N·m on a hinge, N on a slide. */
  maxForce: number
  /** Acceleration-based pull per radian or metre of position error, 1/s². */
  stiffness: number
  /** Acceleration-based pull towards the target speed, 1/s. */
  damping: number
}

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

Members

MemberSignatureDescription
modemode: JointMotorMode
targettarget: numberrad/s or m/s (velocity); radians or metres from the joint's rest pose (position).
maxForcemaxForce: numberThe most the motor pushes: N·m on a hinge, N on a slide.
stiffnessstiffness: numberAcceleration-based pull per radian or metre of position error, 1/s².
dampingdamping: numberAcceleration-based pull towards the target speed, 1/s.

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