Talos docs

AnimationEndEvent

Since 0.6Changed in 0.7

data of the event a one-shot raises when it ends: "animation-end" unless it names its own.

Plain text

Signature

export interface AnimationEndEvent {
  /** Id of the entity whose animator it was. */
  entity: string
  /** The one-shot: a state name, or a clip name when {@link Animator.play} was given a clip. */
  state: string
  /** The clip it was playing. */
  clip: string
  /** The state that took over. */
  next: string
  /** True when something cut it short rather than the clip running out. */
  interrupted: boolean
  /** The animator layer it played on; absent for the base state machine. */
  layer?: string
}

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

Members

MemberSignatureDescription
entityentity: stringId of the entity whose animator it was.
statestate: stringThe one-shot: a state name, or a clip name when {@link Animator.play} was given a clip.
clipclip: stringThe clip it was playing.
nextnext: stringThe state that took over.
interruptedinterrupted: booleanTrue when something cut it short rather than the clip running out.
layerlayer?: stringThe animator layer it played on; absent for the base state machine.

Example

The tested fixture fixtures/app/agent.ts.

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

// Sends a nav agent to `props.target` once, then reports arrival through ctx.state so the
// test can read it without polling the crowd directly.
export default {
  init(ctx) {
    ctx.state.arrived = false
    ctx.nav?.goTo(ctx.props.target as [number, number, number])
  },
  update(ctx) {
    if (ctx.nav?.arrived) ctx.state.arrived = true
  },
} satisfies Behavior