Talos docs

ReleaseOptions

Since 0.6

Options for {@link WorldQuery.release}.

Plain text

Signature

export interface ReleaseOptions {
  /** Replaces the body's linear velocity as it is let go, m/s: a throw. Omitted, it keeps the velocity it was carried at. */
  velocity?: Vec3
}

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

Members

MemberSignatureDescription
velocityvelocity?: Vec3Replaces the body's linear velocity as it is let go, m/s: a throw. Omitted, it keeps the velocity it was carried at.

Example

The tested fixture fixtures/recipes/jump-pad-and-elevator/scenes/behaviors/jump-pad.ts.

import type { Behavior, Vec3 } from "@argus/api"

/**
 * A trigger volume that launches whatever walks onto it.
 *
 * The pad does not reach into the other entity: it says who entered and how hard to launch them,
 * and the character's own behaviour calls `ctx.controller.setVelocity`. So one pad works for the
 * player, an NPC or a crate with a controller, and a character that should not be launched simply
 * ignores the event. The same shape is a knockback volume, a geyser or a car's booster strip.
 */
interface Props {
  /** The velocity to give, m/s. Straight up by default. */
  velocity?: Vec3
}

export default {
  onTrigger(ctx, trigger) {
    if (!trigger.entering) return
    ctx.events.emit("launch", { target: trigger.other.id, velocity: ctx.props.velocity ?? [0, 9, 0] })
  },
} satisfies Behavior<Record<string, never>, Props>