A dev shows how to build a smooth, physics-based horror worm enemy by swapping heavy pill colliders for distance-constrained dots, using a distance field and spatial grid, a trick inspired by Hitman's
Key Takeaways
- Replacing rigid-body colliders with simple distance-constrained particles drastically reduces physics cost.
- Baked distance fields provide cheap collision with level geometry.
- Spatial partitioning is essential to avoid quadratic particle-to-particle collision checks.
- Simple per-particle AI goals can produce emergent, convincing enemy behavior.
What the video covers
- A single stiff worm is first made physical by adding 12 pill-shaped colliders joined by joints.
- Spawning 500 worms creates 6,000 colliders that overwhelm the CPU.
- The solution replaces pills with dots connected by a string, so dots only get pushed back when stretched too far.
- A distance field (3D grid of nearest-surface distances) bakes the level geometry so dots can be pushed out of walls cheaply with a single lookup.
- Dot-to-dot collision would require about 32 million checks per frame, so a spatial grid limits checks to nearby cells.
- Each dot's AI is reduced to one goal: crawl toward the player.
- The resulting pile can climb walls, wrap pillars, and reconverge when exploded.
- The technique is credited to Hitman's approach for dead bodies, applied here to a horror enemy.
Chapters
- 00:00The Terrifying Enemy and the Hitman Trick
- 00:15Adding Physics with Pill Colliders
- 00:23Performance Problem at 500 Worms
- 00:32Switching to Dots and Distance Constraints
- 00:44Preventing Clipping with a Distance Field
- 00:54Pushing Dots Out of Geometry
- 01:05Spatial Grid for Collision Optimization
- 01:18Giving Worms Simple AI and the Final Nightmare
Full Transcript — Download SRT & Markdown
Speaker A
This horror game enemy is terrifying, and those [music] physics should be nuking your frame rate. But you used a trick from a 26-year-old Hitman game to make it completely smooth. You start by adding a single worm, but on its own, it's completely
Speaker A
stiff. You decide to add physics by making the worm a junkie, and cramming 12 pills into its body, each connected with a joint and with its own collider.
Speaker A
But when you spawn 500 worms, you see an [music] immediate problem. 6,000 pill colliders all spinning and bumping into each other just gave your CPU a stroke.
Speaker A
You need a different physics approach. So, you send your worm to rehab and replace the pills with dots [music] connected by a string. The dots can't tip or spin, so your CPU only has to shove a dot back if it moves too far
Speaker A
from its neighbors. To stop the worms from no clipping into the floor, you bake the level into a distance field, a 3D grid, where every spot in the level knows how close the nearest surface is.
Speaker A
Each dot looks up one number, [music] and if it's negative, it's inside something, so you push it out. The worms are still clipping into each other, which means every dot also needs [music] to check every other dot, but that's 32
Speaker A
million checks per frame. To save your CPU, you chop the level into a grid and make each dot only check other dots in nearby cells. Now you're running smoothly. But what about the AI? Worms are idiots, so you give every dot of
Speaker A
every worm only one goal. Crawl toward the player. Now the pile can climb walls, wrap around pillars, and converge back together when you try to explode it. Congrats. You've created a nightmare with the same trick Hitman used for its
Speaker A
dead bodies.
Topics:gamedevindiegameunrealenginehorrorgamingphysicsprocedural animationdistance fieldHitmanshortsindiedev











