Aego Русский

Attack with a hit frame

The damage of an attack belongs to one frame of its clip, not to the button press: put a gameplay event on that frame and pulse a hitbox when it arrives.

anim version=1 length=0.3 {
  frames "" {
    sprites=[asset("…swing_0"), asset("…swing_1"), asset("…swing_2")]
    durations=[0.06, 0.06, 0.18]
  }
  event t=0.1 name="Hit" payload=1 {}
}

The controller enters the attack from any state on a trigger and leaves after one pass:

transition "any" to="Hit" interrupt=true {
  cond "Attack" {}
}
transition "Hit" to="Idle" exitTime=1 duration=0.05 {}

The script presses the trigger and turns the event into damage:

func Ready() {
  hit = anim.EventID("Hit")
}

func OnAnimEvent(id int, payload float) {
  if id == hit {
    Slash.Get<Hitbox2D>().Pulse()
  }
}