Quick answer: Collision is computed in room coordinates and is correct — the issue is visual. Snap the camera to whole pixels with floor() and use tilemap_get_at_pixel for collision tests.
Zoom the camera in to 4× for a closer view of the pixel art. The player visibly walks off the edge of a platform but doesn’t fall — or, worse, gets stopped by an invisible wall. At default 1× zoom, everything was fine.
What’s Actually Wrong
GameMaker collision logic runs in room coordinates and doesn’t know or care about camera zoom. A 4× zoom doesn’t magnify or distort the collision shapes — they remain pixel-accurate in the room. What zoom does is amplify two visual issues:
- Sub-pixel camera position: at 4× zoom, a camera at x=120.3 instead of x=120 shifts the visible world by 0.3 pixels of room space — which renders as 1.2 pixels of screen space. The player sprite appears one pixel off from where collision happens.
- Sub-pixel sprite position: a player at x=80.5 draws on either side of pixel 80 depending on the rendering engine’s rounding. Collision uses the exact 80.5 value, producing inconsistent visual results.
Fix 1: Snap the Camera
/// In your camera controller’s Step
var target_x = obj_player.x - camera_get_view_width(view_camera[0]) / 2;
var target_y = obj_player.y - camera_get_view_height(view_camera[0]) / 2;
// Smoothly approach, then snap
camera_x = lerp(camera_x, target_x, 0.1);
camera_y = lerp(camera_y, target_y, 0.1);
camera_set_view_pos(view_camera[0], floor(camera_x), floor(camera_y));
The lerp produces a smooth follow; the floor at the end ensures the camera ends up at integer coordinates each frame. Visual stability returns.
Fix 2: Snap Sprite Positions for Rendering
If sprite positions are fractional (very common when using a velocity vector), draw at the rounded position:
/// obj_player Draw
draw_sprite(sprite_index, image_index, floor(x), floor(y));
Collision still uses the precise x and y; only the visual is snapped. The player’s movement remains smooth in the underlying numbers, but renders to whole-pixel positions every frame.
Fix 3: Use tilemap_get_at_pixel
For custom tile-based collision (instead of place_meeting against a wall object), the canonical function is:
var tile_id = tilemap_get_at_pixel(tilemap_id, x + hsp, y);
if (tile_id != 0) {
// solid tile at that position
}
This handles the tilemap’s position offset internally. Rolling your own math — tile_x = (x - tilemap.x) div tile_w — is correct only if you remember to subtract the tilemap origin and account for negative coordinates.
Fix 4: Use Application Surface Scaling
Instead of camera zoom, render at native resolution to the application surface and scale the surface for display:
/// Room Start
surface_resize(application_surface, 320, 180);
display_set_gui_size(1280, 720); // 4x
The game renders to a small surface that’s upscaled by 4× for display. No fractional coordinates in the render path; pixel art stays crisp. Camera operates at native 320×180 and never zooms.
Verifying
Draw a debug rectangle at the player’s collision bbox using the precise coordinates, and another at the snapped render position. Move the player and watch the offset. After the fixes, both rectangles overlap perfectly each frame.
Understanding the issue
This bug class falls into a pattern that's worth understanding beyond the specific case. In GameMaker Studio, the underlying behavior is shaped by how the engine layers its abstractions - the public API you call, the runtime systems that respond, and the platform-specific implementations underneath. A bug at any layer can produce symptoms that look like they originate at a different layer. Triaging effectively means recognizing which layer the symptom belongs to, even when the gameplay code is what's visible.
The specific bug described above is the kind that surfaces during integration rather than unit testing. It depends on a combination of factors: the asset configuration, the runtime state, the platform's specific behavior. In isolation, each piece looks correct; in combination, the bug emerges. This is why thorough integration testing - playing the actual game in realistic conditions - catches things that automated tests miss.
Why this happens
Bugs of this class are particularly easy to ship past internal QA because they often depend on specific runtime conditions - hardware combinations, network states, or asset configurations that QA didn't reproduce. Players hit them in the wild, file reports that are hard to repro, and the bug accumulates negative reviews while engineering tries to recreate the failure mode.
At the engine level, the behavior comes from a deliberate design decision in GameMaker. The engine team chose a particular trade-off - usually performance versus convenience, or generality versus specificity - and that trade-off has consequences when you push against it. Understanding the trade-off is what turns 'this bug is mysterious' into 'this bug is the expected consequence of this design'.
Verifying the fix
Verifying this fix in isolation is straightforward: reproduce the bug, apply the change, confirm the bug no longer reproduces. The harder verification is regression - did this fix introduce a new bug elsewhere? Run your standard regression suite, plus any tests that exercise the same code path with different inputs.
Reproducibility is the prerequisite for verification. If you can't reliably reproduce the bug pre-fix, you can't reliably verify it post-fix. Spend time getting a clean reproduction before you write any fix code. The fix is fast once you understand the reproduction; the reproduction is the slow part.
Variations to watch for
Related bug classes often share the same root cause. If you find yourself fixing this issue, look for cousins: similar symptoms in adjacent systems, the same data flow but a different value, or the same fix pattern in another module. The catalog of 'we've seen this before' becomes valuable institutional knowledge.
Adjacent bugs often share a root cause. After fixing the case you've found, spend an hour searching the codebase for similar patterns. What's the same call with different arguments? The same data flow with a different entity type? The same lifecycle issue in a sibling system? Each match is a candidate for the same fix, or a related fix that prevents future bugs of the same class.
In production
For shipping titles with a long support window, watch for this issue resurfacing after dependency updates. Engine upgrades, driver updates, OS releases - each one can resurface a bug class you thought you'd fixed because the underlying behavior changed slightly. Regression tests catch the obvious ones; player reports catch the rest.
When triaging a similar issue in production, prioritize gathering data over hypothesizing causes. A player report describes a symptom; what you need is a build SHA, a session timestamp, and ideally a screen recording or session replay. With those, the bug becomes tractable. Without them, you're guessing at hypothetical reproductions that may not match what the player actually hit.
Performance considerations
If this issue manifests under high load (many actors, many particles, many network connections), profile the post-fix code path with realistic counts. The original cost was a bug; the new cost is real work, and real work has a budget.
Diagnostic approach
The diagnostic tools available depend on your engine and platform. Use the engine's native profilers and debug overlays before reaching for external tools. The native tools have context that external tools lack - they know which subsystem owns the code, which assets are loaded, and what state the engine is in.
For GameMaker-specific diagnostics, the editor's profiler is the canonical starting point. Capture a representative frame with the symptom present; compare against a frame without the symptom; the diff often points directly at the cause. If the symptom is non-deterministic, capture multiple frames and look for the pattern - the cause is usually a state transition or a specific input value rather than a continuous effect.
Tooling and ecosystem
Third-party plugins often provide better diagnostics for their own behavior than the engine does. If the affected code is in a plugin, check the plugin's documentation for debug modes, verbose logging, or inspector tools - these can save hours of investigation when they exist.
Within GameMaker, the relevant diagnostic surfaces include the standard frame debugger, memory profiler, and engine-specific debug overlays. Each one shows a different facet of what's happening. The frame debugger reveals draw call ordering and state transitions; the memory profiler shows allocation patterns; the debug overlay reveals per-system state. Bugs that resist one tool usually surrender to another - the trick is knowing which tool to reach for first.
Edge cases and pitfalls
Platform-specific edge cases are worth enumerating explicitly. iOS handles backgrounding differently than Android; Windows handles focus changes differently than macOS. A fix that works on the development platform may not work on every target. Test on each shipping platform deliberately.
When writing a regression test for this fix, focus on the boundary conditions that surfaced the original bug. Tests that exercise the happy path catch obvious regressions; tests that exercise the boundary catch the subtler regressions that look like new bugs but are really the original returning. The latter are the tests that earn their keep over the long life of the project.
Team communication
Document the fix and its rationale in the commit message or attached engineering doc. Future engineers will encounter related issues; the rationale tells them whether your fix is reusable or specific to the case at hand. Without rationale, the fix gets reverted or copied incorrectly.
If this fix touches a system several engineers work in, a short writeup in the team's engineering channel helps. Not a full design doc - a paragraph explaining what was wrong, what's fixed, and what to watch for. Future engineers encountering similar symptoms will search for the fix; making it findable is a small investment that pays back later.
“Collision is correct. Visuals are lying. Snap camera and sprite to whole pixels.”
For pixel-art games, prefer surface upscaling over camera zoom — eliminates this entire class of bug.