player walks through solid objects gamemaker

Player Phase: Walk Through Walls in GameMaker - Solid Object Collision Fix

By Robert Thompson
AD

Encountering a situation where a player walks through solid objects in GameMaker can disrupt the entire sense of immersion and logic within your game. This specific issue, often stemming from simple oversights in collision logic, turns a carefully crafted platform into a mere suggestion rather than a barrier. Whether you are building a precise platformer or a top-down adventure, maintaining physical integrity is essential for a professional feel.

The Core Culprit: Collision Detection Logic

The most common reason a player walks through solid objects GameMaker stems from a failure in the collision detection sequence. GameMaker processes code line by line during an event, and if the logic is not structured correctly, the engine might check for a wall after the player has already moved past it. This usually happens when movement is calculated in the Step event rather than being handled by the physics buffer or prior to the position change.

Understanding the Physics Buffer

GameMaker includes a built-in physics buffer that stores the previous position of an instance. When you use place_meeting or collision_circle after moving the player, you are often checking the new, invalid position. To fix the issue where the player walks through solid objects, you must utilize move_contact_solid or move back to the stored previous position stored in previous_x and previous_y variables to revert the movement if a collision is detected.

AD
an image of a man walking through a tunnel with pipes in the background and text that reads
an image of a man walking through a tunnel with pipes in the background and text that reads
an image of people walking down the street at night
an image of people walking down the street at night
an old computer game with different types of animals
an old computer game with different types of animals

Troubleshooting the Move Event

If you are experiencing the player walks through solid objects specifically when moving left or right, the issue likely resides in the Horizontal Speed calculation. Hardcoding movement or failing to account for diagonal collisions can create gaps in detection. Ensure that your horizontal velocity is being checked against the object mask precisely, and that the mask itself is not larger than the visible sprite, creating invisible collision zones that the engine fails to register correctly.

Cause Solution
Movement applied after position change Move logic to the Begin Step or use previous_x rollback
Object mask too small or misaligned Adjust the mask to fit the collision bounds tightly
Using Step event for collision response Use Move Contact Solid or Physics Bodies

Leveraging Built-in Functions

Instead of writing complex nested loops to check for collisions, rely on GameMaker's native resolution functions. The function move_solid (available in the extension library or custom code) automates the rollback process. Alternatively, using the physics world functions like physics_world_set_rollback() ensures that the engine calculates the exact moment of impact, preventing the player from clipping through walls entirely.

Kubes / World Builder - unity toolπŸŒπŸ’—
Kubes / World Builder - unity toolπŸŒπŸ’—
Pixel game
Pixel game
Min-Taylor
Min-Taylor

Object Layering and Depth Checks

Another subtle reason for collision failure involves the depth rendering order. If your solid object exists on a lower depth than the player object, and you have strict layer culling settings, the engine might skip the collision check entirely. Adjusting the depth variable or ensuring the solid object is placed earlier in the draw order can resolve these invisibleε£εž’ that appear in the code but not on the screen.

Best Practices for Robust Collision

To future-proof your game and eliminate the player walks through solid objects bug permanently, adopt a strict structure. Always modify the position in the Step event while checking for collisions in the End Step event, or utilize the built-in physics fixtures. Keeping your mask images clean and aligned, and regularly testing with high-speed movement, will catch these errors before they reach the final build.

AD
an animated image of a city with arches and trees
an animated image of a city with arches and trees
πŸ§™βœ¨ Unleash Your Magical Powers! Wizard of Legend 2 Demo Gameplay! πŸ”₯🌟
πŸ§™βœ¨ Unleash Your Magical Powers! Wizard of Legend 2 Demo Gameplay! πŸ”₯🌟
GRIEFER and Player!
GRIEFER and Player!
Tile Stack πŸ§±πŸ§©πŸ˜• iOS Gameplay Walkthrough | Mobile Game
Tile Stack πŸ§±πŸ§©πŸ˜• iOS Gameplay Walkthrough | Mobile Game
a red light drawing of a person holding a hammer and a wrench in his hand
a red light drawing of a person holding a hammer and a wrench in his hand
the game asset is shown in black and white
the game asset is shown in black and white
an image of a game screen with the title
an image of a game screen with the title
How To Push An Object With Animations | Movable Objects - Unreal Engine 4 Tutorial
How To Push An Object With Animations | Movable Objects - Unreal Engine 4 Tutorial
ioruko on Instagram: "BOOM! headshot πŸ”« Follow our game in Discord (link in bio) -Last Ditch Effort game developed by Moonwell Games - #pixelart #pixel_art #pixelartanimation #pixelgame #pixelartgame #gamedev #indiedev #gamedevelopment #gamedeveloper #indiegame #actiongame #boom #videogames #lastditcheffortgame #moonwellgames #γƒ‰γƒƒγƒˆη΅΅" Load Pixel Art, Headshot Game, Top Down Shooter Pixel Art Gameplay, Pixel Art Explosion Animation, Pixel Shot, Headshot Video Game, Pixel Art Attack, Pixel Art Fps Game, Game Over Pixel Art Gif
ioruko on Instagram: "BOOM! headshot πŸ”« Follow our game in Discord (link in bio) -Last Ditch Effort game developed by Moonwell Games - #pixelart #pixel_art #pixelartanimation #pixelgame #pixelartgame #gamedev #indiedev #gamedevelopment #gamedeveloper #indiegame #actiongame #boom #videogames #lastditcheffortgame #moonwellgames #γƒ‰γƒƒγƒˆη΅΅" Load Pixel Art, Headshot Game, Top Down Shooter Pixel Art Gameplay, Pixel Art Explosion Animation, Pixel Shot, Headshot Video Game, Pixel Art Attack, Pixel Art Fps Game, Game Over Pixel Art Gif
4 Ways to Code 2D Player Movement in Unity (You SHOULD know these!)
4 Ways to Code 2D Player Movement in Unity (You SHOULD know these!)
Playing Fist of Fury
Playing Fist of Fury
the game asset is displayed in green and black
the game asset is displayed in green and black
Object States | Game Maker Studio 2
Object States | Game Maker Studio 2
some type of game asset set up in the dark
some type of game asset set up in the dark
an image of the game's interface with different colors and symbols on it, including arrows
an image of the game's interface with different colors and symbols on it, including arrows
SCHiM: Creating a Game with Shadow Mechanics
SCHiM: Creating a Game with Shadow Mechanics
climber
climber
Get more from Sokpop Collective on Patreon
Get more from Sokpop Collective on Patreon
RPG Maker, Resource Thread
RPG Maker, Resource Thread
AD