← notes

Super Mario 64's elegant collision system

2025-12-31

Most resources on 3D collision are either too technical (Separating Axis Theorem, GJK algorithm) or not technical enough ("just use a physics engine"). There's a gap for the developer who wants something quick, dirty, and good enough for most games. Super Mario 64's approach fills that gap brilliantly.

Mario is a point collider. That's it!

Collision triangles are grouped into three types--floor, wall, or ceiling--determined solely by the Z component of the triangle's normal vector. Floors point up, ceilings point down, walls are everything in between.

Detection works by extending each triangle into a triangular prism along its normal. If Mario's point is inside this prism, he gets pushed out. Each triangle type uses different prism dimensions: walls extend further horizontally, floors and ceilings extend further vertically. This simulates Mario being taller than he is wide without any complex shape math.

The secret sauce: the prism detection uses the triangle's normal snapped to the nearest axis vector, not the actual normal. This prevents seams where triangles meet--imagine walking across a floor made of slightly angled triangles. Without snapping, you'd catch on edges constantly. The real normal is still used for collision resolution, so surfaces feel correct.

This approach is genius because it's dead simple. No SAT, no GJK. Just point-in-prism tests and push-out vectors. One of the best parts is that it works with arbitrary triangle soups! No need for Carmack-style brush systems like Quake required. I've implemented this in Lua and JavaScript for first-person shooters and it just works.

I also prefer this over capsule colliders, the common modern choice. Capsules have rounded bottoms that cause floaty behavior when walking off platform edges--bad for game feel in platformers. The prism method gives you hard edges where you want them.

Sometimes the 1996 solution is still the right one.

Credit to pannenkoek2012 on YouTube, whose videos go into incredible detail about Super Mario 64's inner workings.