15 · Combat · 2D and 3D

Knockback

A hit should push, not just subtract health.

If an enemy takes a hit and keeps walking into you, the attack feels like it did nothing. A short push away from the hit, which then slows down, sells the impact and gives the player space. Tuning the push is half of what makes combat feel heavy or light.

←→ moveF or Space attackK knockback on/offTap the scene to attack, ◀ ▶ to move

Try this: Hit the slime with knockback off: it sticks to you. Turn it on and push it into the wall.

Hits 0Times it touched you 0

Attack the slime as it comes in.

Prompt bit

Works for 2D or 3D in any engine (Unity, Unreal, Godot, web). Paste the short one for a quick fix, or the detailed one when you want it done properly.

Add knockback on hit: set the target's velocity to the direction from attacker to target times a force, let friction bring it to rest over about 0.2 s, and pause its AI meanwhile so it cannot walk straight back into the attack.

42 words · one sentence to paste as is

Where it's used

Common mistakes

Adding knockback on top of existing velocity (results stack wildly), letting AI keep steering during the push so it barely moves, ignoring collisions so enemies are pushed through walls, and using the attacker's facing instead of the attacker-to-target direction.

Writing this with an AI assistant? See our best AI coding assistants for game developers.

Missing a concept? Request one.

Related concepts

New concepts, in your inbox.

One short email when we add new concepts, plus our weekly roundup of AI tools for game devs. Unsubscribe any time.