STEP 18 OF 67 · YOU ARE THE GAMEPLAY PROGRAMMER

Make one combat interaction work

Attack input, timing, hit detection, damage and recovery. The animation is only the picture; code decides when the hit lands and what it does.

How to do it

  1. Press attack, play the swing, check for a hit during the active frames only.
  2. Apply damage, then a short recovery before the next attack.
  3. Test it on a simple target dummy.
How AI speeds this up

Ask Duke to write the hit-detection code from your rules and explain the timing.

Example from a sample game

Ashfall: sword hit window frames 8-14, 25 damage, 0.4 s recovery.

Before you move on

In Duke Forger, this step's gate checks:

Words to know

Hit detection
The code that decides whether an attack actually touched its target.
Hitbox
An invisible shape used to detect hits.
Do step 18 on your own game

Included in Creator, Academy and Studio. Duke drafts it with you and checks it before step 19 opens.

Start free