GMS 2.3+ mp_grid_path failing when player collides

Hello, i've been experimenting with mp_grid_path and i kinda reached a cool pathfinding with it, it's making the enemy avoid the solids i have, but for some reason he just drops the path once i collide with certain walls. On the pictures you can see his draw_path on the ground and that he completely left it behind because i collided with the right wall, however just this right wall give me this problem and the left wall at the inferior part of the map.

The red blocks are my solids for collision.

Here's my code for the pathfinding:

--obj_Grid_Creator-- // Creates the grid and add the collision tiles (Create Event)

grid = mp_grid_create(0, 0, room_width/32, room_height/22, 33, 22);
mp_grid_add_instances(grid, obj_Wall_Collider, false);

--scr_Pathplan-- // Creates the path and set it to smooth and also to stop when reaching the end of the path (Script)

function scr_Pathplan(target_X, target_Y) {
mp_grid_path(grid, gridPath, x, y, target_X, target_Y, true);
path_start(gridPath, 3, path_action_stop, false);
path_set_kind(gridPath, 1);
}

--obj_Monster-- // Actual monster running the script (Create Event)
gridPath = path_add();
isChasing = false;

(Step Event)
if (distance_to_object(obj_Player) < 400) {
scr_Pathplan(obj_Player.x, obj_Player.y);
isChasing = true;
}

Made isChasing for debuggin purposes for now.
I'm drawing the path in the Draw Event.

I deactivated my player colliders and went thru the wall to check and he drops the pathfinding when i get out of the room, but when i go back into the room he starts the pathfinding again, however when i collide specifically with the right wall and then he touches it, he freezes just like in the pictures.
Also, my player don't move around within the grid if this could lead to a problem, but the thing is that i want to use pathfinding only when there's obstacles between player and the enemy or when you walk to a point and there's a obstacle for the player to avoid, otherwise it would move_towards_point wich is working perfectly.
 

Attachments

Last edited:
Top