For a couple of months Fiber had enemies that could hit you and that you could hit back. It worked, but it didn’t feel like anything. This post covers how the enemies came together and the pile of small effects that make a hit feel like a hit.
One mob scene, many mobs
Stephen Cassidy built the mob system, and its core idea is that every enemy is the same scene. What makes a slime a slime is a mob resource: a data file with its sprites, stats, speed, starting behavior, patrol distance, vision and actions. A new enemy type is made entirely in the Godot editor, with no new code. The first batch was ten of them, each with its own quirks, including some that run away the moment they spot you.
Mobs run on the same state machine as the player, with states like idle, patrol, chase and attack. They find their way around with Godot’s navigation, and they notice you two ways: a vision cone in front of them, confirmed with a line-of-sight raycast so they can’t see through walls, and a small alert radius all the way round, so you can’t stand right behind one unnoticed. Stephen also gave the slimes a squash-and-stretch bounce.
Fighting back
I wired the mobs into combat, which is built on hitboxes and hurtboxes. An attack spawns a hitbox for a moment, and anything with a hurtbox that it overlaps takes damage, worked out from the attacker’s stats, the attack, and the target’s resistances. Mobs chase you until you’re in range, then switch to a melee attack state that spawns their own hitbox. They have health bars, and both sides get a slash effect when they swing, tinted red for enemies. Attacks also got a separate end delay, so how long a hitbox lasts no longer decides how long the whole attack takes.
The small stuff
With fights working, we spent the last few weeks on feel. I built the damage numbers and hitstop, and Stephen built the hit reactions. None of these are big systems on their own; together, they’re the difference between a number going down and a hit.
A lot of these ideas came from Inbound Shovel’s Game Dev Secrets series of shorts, which is where hitstop and trauma-based screenshake first clicked for me. A crit zoom from the same series is next on my list.
Damage numbers
Every hit pops a number above the target. The number’s size and color scale with the damage, and crits get their own treatment. Each number pops up, arcs off like a fountain away from the hit, and fades. The first version moved too fast to read, so it slowed down and the arc got smoother. The numbers also draw on their own layer above everything else, so they never hide behind a mob.
Getting hit
Taking damage now does three things, all only on your own screen:
- Invulnerability frames went from 0.3 seconds to 1.5, so a group of enemies can’t drain you in a blink.
- A hit flash shader pulses your sprite between red and white for as long as you’re invulnerable, so you can see exactly how long you have.
- Screenshake works on trauma: each hit adds trauma scaled by the damage, trauma decays over time, and the shake follows a power curve of the trauma, so small hits barely nudge the camera and big ones really move it.
In multiplayer, those effects only run for the player who got hit. Nobody’s camera shakes because someone else took a hit.
Hitstop
Hitstop is the biggest one. When a hit connects, the attacker and the target freeze for a split second. The freeze scales with damage:
t = clamp(damage / 100, 0, 1) duration = lerp(0.05 s, 0.15 s, t)
Freezing works by disabling processing on the attacker and the target, then putting it back afterwards. Two rules keep it from going wrong. An attack that lands several hits in the same frame only freezes the attacker once, tracked by an ID for each attack. And a new hit can lengthen a freeze that’s already running but never shorten it.
Two smaller changes went in alongside it. Dashing no longer makes you invulnerable, and Stephen gave item pickups and loot drops their own bit of juice. Next up is knockback.