How to handle input timing?

To make inputs feel intuitive and satisfying, I need to be able to control when they are allowed to take effect during an animation.

For example, many games with combat allow you to chain attacks by pressing an input at certain times during the animation. The input might be held to perform a heavy attack. Also, the animation might be interrupted, say by getting hit at certain times.

It seems that there are “windows” where inputs can be accepted. If inputs aren’t constrained this way, we can get unwanted behavior. For example, the player might press the attack input as they are being hit. The hit animation state will play out, but the attack input trigger remains on, causing a delayed attack after the hit animation finishes. From the players perspective this is bad, because the game state has changed and they may wish to take a different action. It feels bad.

What is the best way to handle inputs like this?

Using AnimationEvent allow you to place specific method at specific times in the animation.

Usage is pretty similar to your drawing so I’d assume this may help you.