Talos docs

AuthorPlacement

Since 0.6

Where an entity goes, relative to its parent.

Plain text

Every field defaults (origin, no turn, unit scale).

Signature

export interface AuthorPlacement {
  /** A handle from this script, or the id of any entity of the scene. */
  parent?: AuthorHandle | string;
  /** Offset from the parent, in metres. */
  position?: AuthorVec3;
  /** A quaternion, `[x, y, z, w]`. */
  rotation?: [number, number, number, number];
  /** Size multiplier on each axis. */
  scale?: AuthorVec3;
  /** Instead of position, rotation and scale. */
  transform?: { position?: AuthorVec3; rotation?: [number, number, number, number]; scale?: AuthorVec3 };
  /** The label the editor shows; the key when absent. */
  name?: string;
}

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

Members

MemberSignatureDescription
parentparent?: AuthorHandle | stringA handle from this script, or the id of any entity of the scene.
positionposition?: AuthorVec3Offset from the parent, in metres.
rotationrotation?: [number, number, number, number]A quaternion, [x, y, z, w].
scalescale?: AuthorVec3Size multiplier on each axis.
transformtransform?: { position?: AuthorVec3; rotation?: [number, number, number, number]; scale?: AuthorVec3 }Instead of position, rotation and scale.
namename?: stringThe label the editor shows; the key when absent.

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