AuthorPlacement
Since 0.6
Where an entity goes, relative to its parent.
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
| Member | Signature | Description |
|---|---|---|
parent | parent?: AuthorHandle | string | A handle from this script, or the id of any entity of the scene. |
position | position?: AuthorVec3 | Offset from the parent, in metres. |
rotation | rotation?: [number, number, number, number] | A quaternion, [x, y, z, w]. |
scale | scale?: AuthorVec3 | Size multiplier on each axis. |
transform | transform?: { position?: AuthorVec3; rotation?: [number, number, number, number]; scale?: AuthorVec3 } | Instead of position, rotation and scale. |
name | name?: string | The 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