Black Trigram (흑괘) - Korean Martial Arts Combat Simulator API - v0.7.9
    Preparing search index...

    Function usePlayerAnimation

    • React hook for player animation state management

      Provides frame-accurate animation control with priority system and event callbacks. Integrates seamlessly with useFrame for 60fps updates.

      Parameters

      Returns UsePlayerAnimationReturn

      Animation control interface

      // Basic usage
      const { currentState, currentFrame, update, transitionTo } = usePlayerAnimation({
      events: {
      onAnimationStart: (state) => console.log(`Started ${state}`),
      onAnimationComplete: (state) => console.log(`Completed ${state}`),
      onFrame: (frame, state) => {
      if (state === "attack" && frame === 6) {
      // Execute attack at midpoint
      executeAttack();
      }
      }
      }
      });

      // In useFrame callback
      useFrame((state, delta) => {
      const result = update(delta);
      // Update visuals based on result.state and result.frame
      });

      // Trigger animations
      const handleAttackInput = () => {
      transitionTo("attack");
      };

      const handleMovement = (isMoving: boolean) => {
      transitionTo(isMoving ? "walk" : "idle");
      };

      플레이어애니메이션훅