Quick answer: mp_grid is a snapshot, not a live map. Call mp_grid_clear_all and re-add obstacles after the world changes, or clear individual cells with mp_grid_clear_cell.

A dungeon crawler destroys a wall to open a path. The wall instance is removed, but enemy NPCs still can’t pathfind through. mp_grid still considers the cell blocked from the initial build.

Rebuild Strategy

// when a wall is destroyed
var cx = floor(wall.x / CELL_SIZE);
var cy = floor(wall.y / CELL_SIZE);
mp_grid_clear_cell(global.grid, cx, cy);

instance_destroy(wall);

Pre-emptively clear the cell before destroying the instance.

Full Rebuild

// nuclear option after major world change
mp_grid_clear_all(global.grid);
mp_grid_add_instances(global.grid, oWall, false);
mp_grid_add_instances(global.grid, oDoor_Closed, false);

Costlier but simple. Use after batch changes (room generation, big destruction). For a 100×100 grid, fast enough.

Verify Path Builds

path = path_add();
if (mp_grid_path(global.grid, path, x, y, target.x, target.y, true)) {
    path_start(path, 2, path_action_stop, false);
} else {
    show_debug_message("No path");
}

mp_grid_path returns false if no path exists. Always handle the failure case.

Don't Add Dynamic Units

Adding enemy/player instances to the grid means they block their own pathfinding. Reserve the grid for static obstacles. For dynamic avoidance, use separation steering or runtime collision checks.

Verifying

Destroy a wall. Enemy NPC immediately routes through the new opening. Block a path elsewhere; enemy reroutes around. Rebuild cost stays in budget for grid size.

“mp_grid snapshots a moment. After change, snapshot again.”

For dynamic worlds (destructible terrain), maintain a dirty flag — only rebuild when geometry changed in the last frame.