How to fix common game engine mistakes

One player says the character falls through a staircase; another says it happens after a long jump. It is the same fault. The physics step is tied to the render frame, so a slow frame moves the body further than a collision check expects, and the next check happens when the body is already inside the wall. Most engine bugs arrive as a family of symptoms like that, so the first useful skill is recognising the family before you touch the code.

Make the fault repeatable before you read the code

A bug you can trigger on demand is halfway fixed. Add a debug key that forces a fixed frame time, then run the same action at sixteen milliseconds per frame and at sixty. If only one of them breaks, the bug lives in the assumption that frames are uniform, and you can stop reading the rest of the engine.

Write down the frame number when it happens. A fault that always lands on the same frame is a logic error; one that lands on an arbitrary frame is usually timing or memory, and those two need different tools.

Symptom: physics changes with the frame rate

This is the classic. Movement, gravity, and collision are stepped once per rendered frame, so a fast machine gets fine-grained checks and a slow machine gets long jumps. The repair is a fixed simulation step, with the renderer interpolating between the last two states so motion still looks smooth.

Mind the leftovers. Cooldowns, timers, and animation speeds usually still read the raw frame delta. Search for that value and make each use state which clock it belongs to: the simulation clock or the display clock.

Symptom: objects update in the wrong order

  • The camera reads a position before the player has written it, so the scene trails a frame behind the input.
  • Collision response runs before the transform update, so bodies are pushed from last frame’s coordinates.
  • An audio trigger fires before the event that should have caused it.

Ordering bugs survive unit tests because each system is correct on its own. Write the frame order in one place — input, simulation, collision, transforms, render — and make every system obey that contract instead of calling a neighbour directly.

Symptom: memory climbs every level

If the live count rises after each load and never comes back down, something is holding a reference. The usual suspects are caches that never evict, event listeners registered once per load, and GPU buffers uploaded but never released. Log live counts per resource type at every level boundary; the one that climbs is your leak, and the rest of the engine can be left alone.

Symptom: the editor is fine but the shipped build is not

Different paths, different uninitialised memory, different file layout. Test the packaged build on a clean machine and from a different working directory, because relative paths and debug-only initialisation are the two things that hide until release. If it only fails there, stop debugging the tool and start debugging the package.

None of these fixes needs a rewrite. They need one reproducible case each, a log that tells you which clock or which order you are looking at, and the discipline to repair the contract rather than the screenshot.