Strata - v1.4.10
    Preparing search index...

    Function createAnimationMachine

    • Creates an XState machine for managing animation states.

      Parameters

      Returns StateMachine<
          {
              blendFactor: number;
              currentAnimation: string;
              isPaused: boolean;
              metadata?: Record<string, unknown>;
              playbackSpeed: number;
              previousAnimation: string | null;
              timeInState: number;
          },
          AnyEventObject,
          Record<string, AnyActorRef>,
          ProvidedActor,
          ParameterizedObject,
          ParameterizedObject,
          string,
          StateValue,
          string,
          unknown,
          NonReducibleUnknown,
          EventObject,
          MetaObject,
          any,
      >

      XState machine configured for animation state management

      const machine = createAnimationMachine({
      id: 'player',
      initial: 'idle',
      states: {
      idle: { animation: 'Idle', loop: true },
      walk: { animation: 'Walk', loop: true },
      run: { animation: 'Run', loop: true },
      jump: { animation: 'Jump', loop: false }
      },
      transitions: [
      { from: 'idle', to: 'walk', event: 'MOVE' },
      { from: 'walk', to: 'idle', event: 'STOP' },
      { from: 'walk', to: 'run', event: 'SPRINT' },
      { from: '*', to: 'jump', event: 'JUMP' }
      ],
      defaultCrossFadeDuration: 0.25
      });