# JointMotorState

> Talos 0.7 · Since 0.6

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

## Signature

```ts
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

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

## Example

The tested fixture `fixtures/host/door.ts`.

```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
```
